27 #include <KLocalizedString> 28 #include <KMainWindow> 41 #define ZOOM_DATA_PREDEFINED (Qt::UserRole + 0) 44 #define ZOOM_DATA_TIME (Qt::UserRole + 1) 47 #define ELEMENTS_OF(__x__) (sizeof(__x__) / sizeof(__x__[0])) 51 :KToolBar(name, parent, true),
53 m_action_zoomselection(Q_NULLPTR),
54 m_action_zoomin(Q_NULLPTR),
55 m_action_zoomout(Q_NULLPTR),
56 m_action_zoomnormal(Q_NULLPTR),
57 m_action_zoomall(Q_NULLPTR),
58 m_action_zoomselect(Q_NULLPTR),
59 m_zoomselect(Q_NULLPTR)
62 QIcon::fromTheme(
_(
"kwave_viewmag")),
63 i18n(
"Zoom to selection"),
67 QIcon::fromTheme(
_(
"kwave_zoom_in")),
72 QIcon::fromTheme(
_(
"kwave_zoom_out")),
77 QIcon::fromTheme(
_(
"kwave_zoom_original")),
82 QIcon::fromTheme(
_(
"kwave_viewmagfit")),
100 { i18n(
"%1 ms", 1), 1L},
101 { i18n(
"%1 ms", 10), 10L},
102 { i18n(
"%1 ms", 100), 100L},
103 { i18n(
"%1 sec", 1), 1000L},
104 { i18n(
"%1 sec", 10), 10L*1000L},
105 { i18n(
"%1 sec", 30), 30L*1000L},
106 { i18n(
"%1 min", 1), 1L*60L*1000L},
107 { i18n(
"%1 min", 3), 3L*60L*1000L},
108 { i18n(
"%1 min", 5), 5L*60L*1000L},
109 { i18n(
"%1 min", 10), 10L*60L*1000L},
110 { i18n(
"%1 min", 30), 30L*60L*1000L},
111 { i18n(
"%1 min", 60), 60L*60L*1000L},
114 for (
unsigned int i = 0; i <
ELEMENTS_OF(zoom_factors); i++) {
117 unsigned int time = zoom_factors[i].ms;
126 parent, SLOT(forwardCommand(QString)));
130 m_zoomselect->setFocusPolicy(Qt::FocusPolicy(Qt::ClickFocus | Qt::TabFocus));
158 bool have_signal =
false;
159 bool have_selection =
false;
160 bool is_closed =
true;
164 Q_ASSERT(signal_manager);
165 if (!signal_manager)
return;
166 have_signal = (signal_manager->
tracks() != 0);
168 is_closed = signal_manager->
isClosed();
187 if (!v.isValid() || !v.toBool()) {
203 Q_ASSERT(signal_manager);
205 if (!signal_manager)
return;
207 if (index < 0)
return;
213 if (v.isValid()) ms = v.toUInt(&ok);
218 if (!zoomable)
return;
220 const double rate = signal_manager->
rate();
223 if (width <= 1) width = 2;
224 const double new_zoom = rint(((rate * ms) / 1.0E3) -1 ) /
225 static_cast<double>(width - 1);
243 if (zoom <= 0.0)
return;
246 double rate = (signal_manager) ? signal_manager->
rate() : 0.0;
247 double ms = ((rate > 0) && (zoomable)) ?
251 if ((signal_manager) && (signal_manager->
tracks())) {
258 strZoom = strZoom.sprintf(
"%02d:%02d min", m, s % 60);
259 }
else if (ms >= 1000) {
260 strZoom = strZoom.sprintf(
"%d sec", s);
261 }
else if (ms >= 1) {
262 strZoom = strZoom.sprintf(
"%d ms",
264 }
else if (ms >= 0.01) {
265 strZoom = strZoom.sprintf(
"%0.3g ms", ms);
269 double percent = 100.0 / zoom;
284 while (i < m_zoomselect->count()) {
286 if (!v.isValid() || !v.toBool()) {
291 double t = vz.toDouble(&ok);
292 if (ok && (t > 0) && fabs(1 - (t / ms)) < (1.0 / 60.0)) {
302 }
else if (rate > 0) {
308 double t = v.toDouble(&ok);
virtual sample_index_t visibleSamples() const =0
Kwave::Selection & selection()
QString Q_DECL_EXPORT zoom2string(double percent)
bool connect(Kwave::StreamObject &source, const char *output, Kwave::StreamObject &sink, const char *input)
virtual int visibleWidth() const =0
sample_index_t length() const
virtual double zoom() const =0
virtual void setZoom(double factor)=0
Kwave::Zoomable * zoomable() const
Kwave::SignalManager * signalManager() const