funcsynth.cpp
1 /***************************************************************************
2  Copyright (C) 2002-2015 Kentaro Kitagawa
3  kitagawa@phys.s.u-tokyo.ac.jp
4 
5  This program is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Library General Public
7  License as published by the Free Software Foundation; either
8  version 2 of the License, or (at your option) any later version.
9 
10  You should have received a copy of the GNU Library General
11  Public License and a list of authors along with this program;
12  see the files COPYING and AUTHORS.
13 ***************************************************************************/
14 #include "funcsynth.h"
15 #include "ui_funcsynthform.h"
16 #include "interface.h"
17 #include "analyzer.h"
18 #include "xnodeconnector.h"
19 #include <QPushButton>
20 #include <qstatusbar.h>
21 #include <QCheckBox>
22 
23 XFuncSynth::XFuncSynth(const char *name, bool runtime,
24  Transaction &tr_meas, const shared_ptr<XMeasure> &meas) :
25  XPrimaryDriver(name, runtime, ref(tr_meas), meas),
26  m_output(create<XBoolNode>("Output", true)),
27  m_trig(create<XTouchableNode>("Trigger", true)),
28  m_mode(create<XComboNode>("Mode", false)),
29  m_function(create<XComboNode>("Function", false)),
30  m_freq(create<XDoubleNode>("Freq", false)),
31  m_amp(create<XDoubleNode>("Amplitude", false)),
32  m_phase(create<XDoubleNode>("Phase", false)),
33  m_offset(create<XDoubleNode>("Offset", false)),
34  m_form(new FrmFuncSynth(g_pFrmMain)) {
35 
36  m_form->statusBar()->hide();
37  m_form->setWindowTitle(i18n("Func. Synth. - ") + getLabel() );
38 
39  m_conOutput = xqcon_create<XQToggleButtonConnector>(m_output, m_form->m_ckbOutput);
40  m_conTrig = xqcon_create<XQButtonConnector>(m_trig, m_form->m_btnTrig);
41  m_conMode = xqcon_create<XQComboBoxConnector>(m_mode, m_form->m_cmbMode, Snapshot( *m_mode));
42  m_conFreq = xqcon_create<XQLineEditConnector>(m_freq, m_form->m_edFreq);
43  m_conFunction = xqcon_create<XQComboBoxConnector>(m_function, m_form->m_cmbFunc, Snapshot( *m_function));
44  m_conAmp = xqcon_create<XQLineEditConnector>(m_amp, m_form->m_edAmp);
45  m_conPhase = xqcon_create<XQLineEditConnector>(m_phase, m_form->m_edPhase);
46  m_conOffset = xqcon_create<XQLineEditConnector>(m_offset, m_form->m_edOffset);
47 
48  m_output->setUIEnabled(false);
49  m_trig->setUIEnabled(false);
50  m_mode->setUIEnabled(false);
51  m_freq->setUIEnabled(false);
52  m_function->setUIEnabled(false);
53  m_amp->setUIEnabled(false);
54  m_phase->setUIEnabled(false);
55  m_offset->setUIEnabled(false);
56 }
57 
58 void
60 //! impliment form->show() here
61  m_form->showNormal();
62  m_form->raise();
63 }
64 
65 void
67  m_output->setUIEnabled(true);
68  m_trig->setUIEnabled(true);
69  m_mode->setUIEnabled(true);
70  m_freq->setUIEnabled(true);
71  m_function->setUIEnabled(true);
72  m_amp->setUIEnabled(true);
73  m_phase->setUIEnabled(true);
74  m_offset->setUIEnabled(true);
75 
76  iterate_commit([=](Transaction &tr){
77  m_lsnOutput = tr[ *output()].onValueChanged().connectWeakly(
78  shared_from_this(), &XFuncSynth::onOutputChanged);
79  m_lsnMode = tr[ *mode()].onValueChanged().connectWeakly(
80  shared_from_this(), &XFuncSynth::onModeChanged);
81  m_lsnFreq = tr[ *freq()].onValueChanged().connectWeakly(
82  shared_from_this(), &XFuncSynth::onFreqChanged);
83  m_lsnFunction = tr[ *function()].onValueChanged().connectWeakly(
84  shared_from_this(), &XFuncSynth::onFunctionChanged);
85  m_lsnAmp = tr[ *amp()].onValueChanged().connectWeakly(
86  shared_from_this(), &XFuncSynth::onAmpChanged);
87  m_lsnPhase = tr[ *phase()].onValueChanged().connectWeakly(
88  shared_from_this(), &XFuncSynth::onPhaseChanged);
89  m_lsnOffset = tr[ *offset()].onValueChanged().connectWeakly(
90  shared_from_this(), &XFuncSynth::onOffsetChanged);
91  });
92 
93  iterate_commit([=](Transaction &tr){
94  m_lsnTrig = tr[ *trig()].onTouch().connectWeakly(
95  shared_from_this(), &XFuncSynth::onTrigTouched);
96  });
97 }
98 void
100  m_lsnOutput.reset();
101  m_lsnTrig.reset();
102  m_lsnMode.reset();
103  m_lsnFreq.reset();
104  m_lsnFunction.reset();
105  m_lsnAmp.reset();
106  m_lsnPhase.reset();
107  m_lsnOffset.reset();
108 
109  m_output->setUIEnabled(false);
110  m_trig->setUIEnabled(false);
111  m_mode->setUIEnabled(false);
112  m_freq->setUIEnabled(false);
113  m_function->setUIEnabled(false);
114  m_amp->setUIEnabled(false);
115  m_phase->setUIEnabled(false);
116  m_offset->setUIEnabled(false);
117 
118  closeInterface();
119 }
120 
121 void
123 }
124 void
126 }
127 

Generated for KAME4 by  doxygen 1.8.3