ClockProcessor::ClockProcessor() : Processor(), counter_(0), highResCounter_(0.0f), period_(1), timerIsActive_(false), timer_(0), eventHandler_(), enableTimerProp_("enableTimerProp", "enable timer", false), intervalProp_("intervalProp", "interval (ms)", 1000, 1, 10 * 1000), counterStyleProp_("counterStyle", "counter style"), periodProp_("period", "period (counts)", 2, 1, 1000), tickCounterProp_("tickCounterProp", "counter", 0, 0, 1000), useHighResCounterProp_("useHighResCounterProp", "use high resolution counter", false), resolutionProp_("resolutionProp", "resolution (1/counts)", 0.5f, 0.0f, 1.0f), highResCounterProp_("highResCounterProp", "high resolution counter:", 0.0f, 0.0f, 1000.f), resetProp_("resetProp", "reset counters") { eventHandler_.addListenerToBack(this); timer_ = VoreenApplication::app()->createTimer(&eventHandler_); enableTimerProp_.onChange(CallMemberAction<ClockProcessor>(this, &ClockProcessor::toggleTimer)); intervalProp_.onChange(CallMemberAction<ClockProcessor>(this, &ClockProcessor::onIntervalChange)); periodProp_.onChange(CallMemberAction<ClockProcessor>(this, &ClockProcessor::onPeriodChange)); resetProp_.onChange(CallMemberAction<ClockProcessor>(this, &ClockProcessor::resetCounter)); useHighResCounterProp_.onChange(CallMemberAction<ClockProcessor>(this, &ClockProcessor::onUseHighResCounterChange)); tickCounterProp_.setWidgetsEnabled(false); highResCounterProp_.setWidgetsEnabled(false); counterStyleProp_.addOption("linear", "linear", ClockProcessor::COUNTER_LINEAR); counterStyleProp_.addOption("cyclic", "cyclic", ClockProcessor::COUNTER_CYCLIC); counterStyleProp_.addOption("reversing", "reversing", ClockProcessor::COUNTER_REVERSING); counterStyleProp_.onChange(CallMemberAction<ClockProcessor>(this, &ClockProcessor::onCounterStyleChange)); counterStyleProp_.set("cyclic"); addProperty(enableTimerProp_); addProperty(intervalProp_); addProperty(counterStyleProp_); addProperty(periodProp_); addProperty(tickCounterProp_); addProperty(useHighResCounterProp_); addProperty(resolutionProp_); addProperty(highResCounterProp_); addProperty(resetProp_); onCounterStyleChange(); onPeriodChange(); onUseHighResCounterChange(); }
void SpeedWidget::loadSettings() { Preferences *preferences = Preferences::instance(); int periodIndex = preferences->getSpeedWidgetPeriod(); m_periodCombobox->setCurrentIndex(periodIndex); onPeriodChange(static_cast<SpeedPlotView::TimePeriod>(periodIndex)); for (int id = SpeedPlotView::UP; id < SpeedPlotView::NB_GRAPHS; ++id) { QAction *action = m_graphsMenuActions.at(id); bool enable = preferences->getSpeedWidgetGraphEnable(id); action->setChecked(enable); m_plot->setGraphEnable(static_cast<SpeedPlotView::GraphID>(id), enable); } }