Merge lp:dspatcher/1.01 into lp:dspatcher

Proposed by Marcus Tomlinson
Status: Merged
Merged at revision: 13
Proposed branch: lp:dspatcher/1.01
Merge into: lp:dspatcher
Diff against target: 775 lines (+306/-118)
9 files modified
dspatcher/CMakeLists.txt (+4/-0)
dspatcher/include/DsprController.h (+9/-2)
dspatcher/include/DsprParam.h (+7/-5)
dspatcher/src/DsprController.cpp (+127/-22)
dspatcher/src/DsprParam.cpp (+133/-43)
dspatcher/src/main.cpp (+1/-42)
dspatcher/update_install_names.sh (+9/-0)
qtpatcher/include/QtpMain.h (+1/-0)
qtpatcher/src/QtpMain.cpp (+15/-4)
To merge this branch: bzr merge lp:dspatcher/1.01
Reviewer Review Type Date Requested Status
Marcus Tomlinson Pending
Review via email: mp+255604@code.launchpad.net

Commit message

* Improved null / error checking
* Show construction menu when placing a component with constructor params
* Allow direct text input for Int, Float and FilePath parameter types
* Support for read-only component parameters
* Fixed component panel dynamic resizing
* Fixed build failures on Mac

To post a comment you must log in.
lp:dspatcher/1.01 updated
20. By Marcus Tomlinson

Disable auto loading of new plugins for now, somethings borked

21. By Marcus Tomlinson

Fixed Mac build

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'dspatcher/CMakeLists.txt'
--- dspatcher/CMakeLists.txt 2015-04-07 15:48:58 +0000
+++ dspatcher/CMakeLists.txt 2015-04-09 13:24:26 +0000
@@ -21,6 +21,10 @@
21 QtPatcher21 QtPatcher
22)22)
2323
24if(APPLE)
25 execute_process(COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/update_install_names.sh)
26endif(APPLE)
27
24if(WIN32)28if(WIN32)
25 add_custom_command(29 add_custom_command(
26 TARGET ${PROJECT_NAME} POST_BUILD30 TARGET ${PROJECT_NAME} POST_BUILD
2731
=== modified file 'dspatcher/include/DsprController.h'
--- dspatcher/include/DsprController.h 2015-04-06 14:19:57 +0000
+++ dspatcher/include/DsprController.h 2015-04-09 13:24:26 +0000
@@ -29,14 +29,17 @@
29#include <DsprParam.h>29#include <DsprParam.h>
30#include <QtpMain.h>30#include <QtpMain.h>
3131
32#include <QFileSystemWatcher>
32#include <QObject>33#include <QObject>
3334
35#include <set>
36
34class DsprController : public QObject37class DsprController : public QObject
35{38{
36 Q_OBJECT39 Q_OBJECT
3740
38public:41public:
39 DsprController(QtpDiag* diagram, std::vector<DspPluginLoader> const& pluginLoaders);42 DsprController(QtpMain& mainWindow);
40 ~DsprController();43 ~DsprController();
4144
42signals:45signals:
@@ -61,6 +64,8 @@
61 void triggerUpdated();64 void triggerUpdated();
6265
63private slots:66private slots:
67 void _loadPlugins();
68
64 void _inputAdded(DspComponent* component, int index);69 void _inputAdded(DspComponent* component, int index);
65 void _inputRemoved(DspComponent* component, int index);70 void _inputRemoved(DspComponent* component, int index);
66 void _outputAdded(DspComponent* component, int index);71 void _outputAdded(DspComponent* component, int index);
@@ -70,7 +75,9 @@
70 void _parameterUpdated(DspComponent* component, int index);75 void _parameterUpdated(DspComponent* component, int index);
7176
72private:77private:
73 bool _settingParam;78 QFileSystemWatcher _fileWatcher;
79 QtpMain& _mainWindow;
80 std::set<int> _settingParams;
74 std::vector<DspPluginLoader> _pluginLoaders;81 std::vector<DspPluginLoader> _pluginLoaders;
7582
76 std::map<DspComponent const*, QtpComp*> _qtpComps;83 std::map<DspComponent const*, QtpComp*> _qtpComps;
7784
=== modified file 'dspatcher/include/DsprParam.h'
--- dspatcher/include/DsprParam.h 2015-04-06 16:59:42 +0000
+++ dspatcher/include/DsprParam.h 2015-04-09 13:24:26 +0000
@@ -49,10 +49,11 @@
49public:49public:
50 DsprParam(int compId, int paramId, std::string const& name, DspParameter const& param, QMenu* contextMenu);50 DsprParam(int compId, int paramId, std::string const& name, DspParameter const& param, QMenu* contextMenu);
51 QWidgetAction* action();51 QWidgetAction* action();
52 DspParameter& param();52 DspParameter const& param();
5353
54 int compId();54 int compId() const;
55 int paramId();55 int paramId() const;
56 std::string name() const;
5657
57 bool SetBool(bool const& value);58 bool SetBool(bool const& value);
58 bool SetInt(int const& value);59 bool SetInt(int const& value);
@@ -70,17 +71,19 @@
70 void triggerUpdated();71 void triggerUpdated();
7172
72private slots:73private slots:
74 void paramChanged(bool value);
73 void paramChanged(int value);75 void paramChanged(int value);
74 void paramChanged(QString const&);76 void paramChanged(QString const&);
75 void paramChanged();77 void paramChanged();
7678
77 void updateFloatSlider(int value);79 void updateSlider(int value);
78 void browseForFile();80 void browseForFile();
7981
80private:82private:
81 bool _settingParam;83 bool _settingParam;
82 int _compId;84 int _compId;
83 int _paramId;85 int _paramId;
86 std::string _name;
84 DspParameter _param;87 DspParameter _param;
85 QMenu* _contextMenu;88 QMenu* _contextMenu;
86 QWidgetAction* _action;89 QWidgetAction* _action;
@@ -90,7 +93,6 @@
90 QLineEdit* _textBox;93 QLineEdit* _textBox;
91 QComboBox* _listBox;94 QComboBox* _listBox;
92 QPushButton* _button;95 QPushButton* _button;
93 QLabel* _vlabel;
94};96};
9597
96#endif // DSPRPARAM_H98#endif // DSPRPARAM_H
9799
=== removed directory 'dspatcher/link/Debug'
=== renamed file 'dspatcher/link/Debug/libDSPatch.dylib' => 'dspatcher/link/libDSPatch.dylib'
=== modified file 'dspatcher/src/DsprController.cpp'
--- dspatcher/src/DsprController.cpp 2015-04-06 14:19:57 +0000
+++ dspatcher/src/DsprController.cpp 2015-04-09 13:24:26 +0000
@@ -24,19 +24,26 @@
2424
25#include <DsprController.h>25#include <DsprController.h>
2626
27#include <DSPatch.h>
27#include <QtpDiag.h>28#include <QtpDiag.h>
2829
29DsprController::DsprController(QtpDiag* diagram, std::vector<DspPluginLoader> const& pluginLoaders)30#include <QDir>
30 : _settingParam(false)31
31 , _pluginLoaders(pluginLoaders)32DsprController::DsprController(QtpMain& mainWindow)
33 : _mainWindow(mainWindow)
32{34{
35 _fileWatcher.addPath(PLUGIN_DIR);
36 ///!connect(&_fileWatcher, SIGNAL(directoryChanged(QString const&)), this, SLOT(_loadPlugins()));
37
38 _loadPlugins();
39
33 _circuit.SetThreadCount(2);40 _circuit.SetThreadCount(2);
34 _circuit.StartAutoTick();41 _circuit.StartAutoTick();
3542
36 connect(diagram, &QtpDiag::compInserted, this, &DsprController::compInserted);43 connect(_mainWindow.diagram(), &QtpDiag::compInserted, this, &DsprController::compInserted);
37 connect(diagram, &QtpDiag::compRemoved, this, &DsprController::compRemoved);44 connect(_mainWindow.diagram(), &QtpDiag::compRemoved, this, &DsprController::compRemoved);
38 connect(diagram, &QtpDiag::wireConnected, this, &DsprController::wireConnected);45 connect(_mainWindow.diagram(), &QtpDiag::wireConnected, this, &DsprController::wireConnected);
39 connect(diagram, &QtpDiag::wireDisconnected, this, &DsprController::wireDisconnected);46 connect(_mainWindow.diagram(), &QtpDiag::wireDisconnected, this, &DsprController::wireDisconnected);
4047
41 connect(this, &DsprController::inputAdded, this, &DsprController::_inputAdded);48 connect(this, &DsprController::inputAdded, this, &DsprController::_inputAdded);
42 connect(this, &DsprController::inputRemoved, this, &DsprController::_inputRemoved);49 connect(this, &DsprController::inputRemoved, this, &DsprController::_inputRemoved);
@@ -108,7 +115,46 @@
108{115{
109 DspPluginLoader loader = _pluginLoaders[qtpComp->compInfo().typeId];116 DspPluginLoader loader = _pluginLoaders[qtpComp->compInfo().typeId];
110 std::map<std::string, DspParameter> params = loader.GetCreateParams();117 std::map<std::string, DspParameter> params = loader.GetCreateParams();
118
119 // Show construction menu
120 std::vector<DsprParam*> dsprParams;
121 typedef std::map<std::string, DspParameter>::iterator it_type;
122 for (it_type iterator = params.begin(); iterator != params.end(); iterator++)
123 {
124 DsprParam* param = new DsprParam(qtpComp->id(), 0, iterator->first,
125 iterator->second, qtpComp->contextMenu());
126 qtpComp->contextMenu()->addAction(param->action());
127 dsprParams.push_back(param);
128 }
129 if (params.size() > 0)
130 {
131 qtpComp->contextMenu()->exec(QCursor::pos());
132 }
133
134 // Construct component with values from menu
135 foreach (DsprParam* dsprParam, dsprParams)
136 {
137 params[dsprParam->name()] = dsprParam->param();
138 delete dsprParam;
139 }
140 qtpComp->contextMenu()->clear();
141
111 DspComponent* component = loader.Create(params);142 DspComponent* component = loader.Create(params);
143 if (component == NULL)
144 {
145 return;
146 }
147
148 qtpComp->removeInPins();
149 qtpComp->removeOutPins();
150 for (int i = 0; i < component->GetInputCount(); ++i)
151 {
152 qtpComp->addInPin(component->GetInputName(i).c_str());
153 }
154 for (int i = 0; i < component->GetOutputCount(); ++i)
155 {
156 qtpComp->addOutPin(component->GetOutputName(i).c_str());
157 }
112158
113 component->SetCallback(callback, this);159 component->SetCallback(callback, this);
114 _circuit.AddComponent(component);160 _circuit.AddComponent(component);
@@ -162,42 +208,54 @@
162208
163void DsprController::boolUpdated(bool value)209void DsprController::boolUpdated(bool value)
164{210{
165 _settingParam = true;
166 DsprParam* param = dynamic_cast<DsprParam*>(sender());211 DsprParam* param = dynamic_cast<DsprParam*>(sender());
167 _components[param->compId()]->SetParameter(param->paramId(), DspParameter(DspParameter::Bool, value));212 _settingParams.insert(param->paramId());
168 _settingParam = false;213 if (!_components[param->compId()]->SetParameter(param->paramId(), DspParameter(DspParameter::Bool, value)))
214 {
215 param->SetBool(*(_components[param->compId()]->GetParameter(param->paramId())->GetBool()));
216 }
217 _settingParams.erase(param->paramId());
169}218}
170219
171void DsprController::intUpdated(int value)220void DsprController::intUpdated(int value)
172{221{
173 _settingParam = true;
174 DsprParam* param = dynamic_cast<DsprParam*>(sender());222 DsprParam* param = dynamic_cast<DsprParam*>(sender());
175 _components[param->compId()]->SetParameter(param->paramId(), DspParameter(DspParameter::Int, value));223 _settingParams.insert(param->paramId());
176 _settingParam = false;224 if (!_components[param->compId()]->SetParameter(param->paramId(), DspParameter(DspParameter::Int, value)))
225 {
226 param->SetInt(*(_components[param->compId()]->GetParameter(param->paramId())->GetInt()));
227 }
228 _settingParams.erase(param->paramId());
177}229}
178230
179void DsprController::floatUpdated(float value)231void DsprController::floatUpdated(float value)
180{232{
181 _settingParam = true;
182 DsprParam* param = dynamic_cast<DsprParam*>(sender());233 DsprParam* param = dynamic_cast<DsprParam*>(sender());
183 _components[param->compId()]->SetParameter(param->paramId(), DspParameter(DspParameter::Float, value));234 _settingParams.insert(param->paramId());
184 _settingParam = false;235 if (!_components[param->compId()]->SetParameter(param->paramId(), DspParameter(DspParameter::Float, value)))
236 {
237 param->SetFloat(*(_components[param->compId()]->GetParameter(param->paramId())->GetFloat()));
238 }
239 _settingParams.erase(param->paramId());
185}240}
186241
187void DsprController::stringUpdated(std::string const& value)242void DsprController::stringUpdated(std::string const& value)
188{243{
189 _settingParam = true;
190 DsprParam* param = dynamic_cast<DsprParam*>(sender());244 DsprParam* param = dynamic_cast<DsprParam*>(sender());
191 _components[param->compId()]->SetParameter(param->paramId(), DspParameter(DspParameter::String, value));245 _settingParams.insert(param->paramId());
192 _settingParam = false;246 if (!_components[param->compId()]->SetParameter(param->paramId(), DspParameter(DspParameter::String, value)))
247 {
248 param->SetString(*(_components[param->compId()]->GetParameter(param->paramId())->GetString()));
249 }
250 _settingParams.erase(param->paramId());
193}251}
194252
195void DsprController::triggerUpdated()253void DsprController::triggerUpdated()
196{254{
197 _settingParam = true;
198 DsprParam* param = dynamic_cast<DsprParam*>(sender());255 DsprParam* param = dynamic_cast<DsprParam*>(sender());
256 _settingParams.insert(param->paramId());
199 _components[param->compId()]->SetParameter(param->paramId(), DspParameter(DspParameter::Trigger));257 _components[param->compId()]->SetParameter(param->paramId(), DspParameter(DspParameter::Trigger));
200 _settingParam = false;258 _settingParams.erase(param->paramId());
201}259}
202260
203void DsprController::_inputAdded(DspComponent* component, int index)261void DsprController::_inputAdded(DspComponent* component, int index)
@@ -275,7 +333,8 @@
275333
276void DsprController::_parameterUpdated(DspComponent* component, int index)334void DsprController::_parameterUpdated(DspComponent* component, int index)
277{335{
278 if (_settingParam)336 // don't react if we are the one setting the parameter
337 if (_settingParams.find(index) != _settingParams.end())
279 {338 {
280 return;339 return;
281 }340 }
@@ -314,3 +373,49 @@
314 break;373 break;
315 }374 }
316}375}
376
377void DsprController::_loadPlugins()
378{
379 _mainWindow.unregisterComponents();
380
381 // Load DSPatch plugins from "dspatchables" folder
382 QDir dir(PLUGIN_DIR);
383 QFileInfoList files = dir.entryInfoList();
384 foreach(QFileInfo const& file, files)
385 {
386 #ifdef _WIN32
387 if (file.isFile() && file.fileName().endsWith(".dll"))
388 #else
389 if (file.isFile())
390 #endif
391 {
392 QString path = file.absoluteFilePath();
393 DspPluginLoader loader(path.toUtf8().constData());
394 if (loader.IsLoaded())
395 {
396 _pluginLoaders.push_back(loader);
397 std::map<std::string, DspParameter> params = loader.GetCreateParams();
398 DspComponent* comp = loader.Create(params);
399
400 QtpComp::CompInfo compInfo;
401 compInfo.typeId = _pluginLoaders.size() - 1;
402 compInfo.typeName = file.baseName().mid(0, 3) == "lib" ? file.baseName().mid(3) : file.baseName();
403
404 if (comp)
405 {
406 for (int i = 0; i < comp->GetInputCount(); ++i)
407 {
408 compInfo.inPins.append(comp->GetInputName(i).c_str());
409 }
410 for (int i = 0; i < comp->GetOutputCount(); ++i)
411 {
412 compInfo.outPins.append(comp->GetOutputName(i).c_str());
413 }
414 }
415
416 _mainWindow.registerComponent(compInfo);
417 delete comp;
418 }
419 }
420 }
421}
317422
=== modified file 'dspatcher/src/DsprParam.cpp'
--- dspatcher/src/DsprParam.cpp 2015-04-06 16:59:42 +0000
+++ dspatcher/src/DsprParam.cpp 2015-04-09 13:24:26 +0000
@@ -28,18 +28,25 @@
28 : _settingParam(false)28 : _settingParam(false)
29 , _compId(compId)29 , _compId(compId)
30 , _paramId(paramId)30 , _paramId(paramId)
31 , _name(name)
31 , _param(param)32 , _param(param)
32 , _contextMenu(contextMenu)33 , _contextMenu(contextMenu)
33{34{
34 if (_param.Type() == DspParameter::Bool)35 if (_param.Type() == DspParameter::Bool)
35 {36 {
36 _checkbox = new QCheckBox(_contextMenu);37 _checkbox = new QCheckBox(_contextMenu);
38
39 if (_param.GetBool())
40 {
41 _checkbox->setChecked(*_param.GetBool());
42 }
43
37 _checkbox->setText(name.c_str());44 _checkbox->setText(name.c_str());
38 QWidgetAction* customAction = new QWidgetAction(_contextMenu);45 QWidgetAction* customAction = new QWidgetAction(_contextMenu);
39 customAction->setDefaultWidget(_checkbox);46 customAction->setDefaultWidget(_checkbox);
40 _action = customAction;47 _action = customAction;
4148
42 connect(_checkbox, SIGNAL(stateChanged(int)), this, SLOT(paramChanged(int)));49 connect(_checkbox, SIGNAL(toggled(bool)), this, SLOT(paramChanged(bool)));
43 }50 }
44 else if (_param.Type() == DspParameter::Int)51 else if (_param.Type() == DspParameter::Int)
45 {52 {
@@ -50,31 +57,43 @@
50 {57 {
51 _slider->setRange(_param.GetIntRange()->first, _param.GetIntRange()->second);58 _slider->setRange(_param.GetIntRange()->first, _param.GetIntRange()->second);
52 }59 }
53 else60 else if (_param.GetInt())
54 {61 {
55 _slider->setRange(0, *_param.GetInt() * 2);62 _slider->setRange(0, *_param.GetInt() * 2);
56 }63 }
57 _slider->setValue(*_param.GetInt());64 else
65 {
66 _slider->setRange(0, 10000);
67 }
68
69 if (_param.GetInt())
70 {
71 _slider->setValue(*_param.GetInt());
72 }
73 else
74 {
75 _slider->setValue(5000);
76 }
5877
59 QLabel* label = new QLabel(intSlider);78 QLabel* label = new QLabel(intSlider);
60 label->setText(name.c_str());79 label->setText(name.c_str());
6180
62 _vlabel = new QLabel(intSlider);81 _textBox = new QLineEdit(intSlider);
63 _vlabel->setNum(_slider->sliderPosition());82 _textBox->setText(QString::number(_slider->sliderPosition()));
64 _vlabel->setFixedWidth(45);83 _textBox->setFixedWidth(65);
6584
66 connect(_slider, SIGNAL(valueChanged(int)), _vlabel, SLOT(setNum(int)));85 connect(_slider, SIGNAL(valueChanged(int)), this, SLOT(updateSlider(int)));
6786
68 QHBoxLayout* layout = new QHBoxLayout(intSlider);87 QHBoxLayout* layout = new QHBoxLayout(intSlider);
69 layout->addWidget(label);88 layout->addWidget(label);
70 layout->addWidget(_slider);89 layout->addWidget(_slider);
71 layout->addWidget(_vlabel);90 layout->addWidget(_textBox);
7291
73 QWidgetAction* intSliderAction = new QWidgetAction(_contextMenu);92 QWidgetAction* intSliderAction = new QWidgetAction(_contextMenu);
74 intSliderAction->setDefaultWidget(intSlider);93 intSliderAction->setDefaultWidget(intSlider);
75 _action = intSliderAction;94 _action = intSliderAction;
7695
77 connect(_slider, SIGNAL(valueChanged(int)), this, SLOT(paramChanged(int)));96 connect(_textBox, SIGNAL(textChanged(QString const&)), this, SLOT(paramChanged(QString const&)));
78 }97 }
79 else if (_param.Type() == DspParameter::Float)98 else if (_param.Type() == DspParameter::Float)
80 {99 {
@@ -85,31 +104,43 @@
85 {104 {
86 _slider->setRange(_param.GetFloatRange()->first * 100, _param.GetFloatRange()->second * 100);105 _slider->setRange(_param.GetFloatRange()->first * 100, _param.GetFloatRange()->second * 100);
87 }106 }
88 else107 else if (_param.GetFloat())
89 {108 {
90 _slider->setRange(0, *_param.GetFloat() * 200);109 _slider->setRange(0, *_param.GetFloat() * 200);
91 }110 }
92 _slider->setValue(*_param.GetFloat() * 100);111 else
112 {
113 _slider->setRange(0, 10000 * 100);
114 }
115
116 if (_param.GetFloat())
117 {
118 _slider->setValue(*_param.GetFloat() * 100);
119 }
120 else
121 {
122 _slider->setValue(5000 * 100);
123 }
93124
94 QLabel* label = new QLabel(floatSlider);125 QLabel* label = new QLabel(floatSlider);
95 label->setText(name.c_str());126 label->setText(name.c_str());
96127
97 _vlabel = new QLabel(floatSlider);128 _textBox = new QLineEdit(floatSlider);
98 _vlabel->setNum(_slider->sliderPosition() / 100);129 _textBox->setText(QString::number((float)_slider->sliderPosition() / 100));
99 _vlabel->setFixedWidth(45);130 _textBox->setFixedWidth(65);
100131
101 connect(_slider, SIGNAL(valueChanged(int)), this, SLOT(updateFloatSlider(int)));132 connect(_slider, SIGNAL(valueChanged(int)), this, SLOT(updateSlider(int)));
102133
103 QHBoxLayout* layout = new QHBoxLayout(floatSlider);134 QHBoxLayout* layout = new QHBoxLayout(floatSlider);
104 layout->addWidget(label);135 layout->addWidget(label);
105 layout->addWidget(_slider);136 layout->addWidget(_slider);
106 layout->addWidget(_vlabel);137 layout->addWidget(_textBox);
107138
108 QWidgetAction* intSliderAction = new QWidgetAction(_contextMenu);139 QWidgetAction* intSliderAction = new QWidgetAction(_contextMenu);
109 intSliderAction->setDefaultWidget(floatSlider);140 intSliderAction->setDefaultWidget(floatSlider);
110 _action = intSliderAction;141 _action = intSliderAction;
111142
112 connect(_slider, SIGNAL(valueChanged(int)), this, SLOT(paramChanged(int)));143 connect(_textBox, SIGNAL(textChanged(QString const&)), this, SLOT(paramChanged(QString const&)));
113 }144 }
114 else if (_param.Type() == DspParameter::String)145 else if (_param.Type() == DspParameter::String)
115 {146 {
@@ -119,7 +150,11 @@
119 label->setText(name.c_str());150 label->setText(name.c_str());
120151
121 _textBox = new QLineEdit(textBox);152 _textBox = new QLineEdit(textBox);
122 _textBox->setText(_param.GetString()->c_str());153
154 if (_param.GetString())
155 {
156 _textBox->setText(_param.GetString()->c_str());
157 }
123158
124 QHBoxLayout* layout = new QHBoxLayout(textBox);159 QHBoxLayout* layout = new QHBoxLayout(textBox);
125 layout->addWidget(label);160 layout->addWidget(label);
@@ -139,8 +174,11 @@
139 label->setText(name.c_str());174 label->setText(name.c_str());
140175
141 _textBox = new QLineEdit(fileBrowser);176 _textBox = new QLineEdit(fileBrowser);
142 _textBox->setEnabled(false);177
143 _textBox->setText(_param.GetString()->c_str());178 if (_param.GetString())
179 {
180 _textBox->setText(_param.GetString()->c_str());
181 }
144182
145 QPushButton* btnBrowse = new QPushButton(fileBrowser);183 QPushButton* btnBrowse = new QPushButton(fileBrowser);
146 btnBrowse->setText("Browse");184 btnBrowse->setText("Browse");
@@ -165,9 +203,13 @@
165 label->setText(name.c_str());203 label->setText(name.c_str());
166204
167 _listBox = new QComboBox(listBox);205 _listBox = new QComboBox(listBox);
168 for (size_t i = 0; i < _param.GetList()->size(); ++i)206
207 if (_param.GetList())
169 {208 {
170 _listBox->addItem((*_param.GetList())[i].c_str());209 for (size_t i = 0; i < _param.GetList()->size(); ++i)
210 {
211 _listBox->addItem((*_param.GetList())[i].c_str());
212 }
171 }213 }
172214
173 QHBoxLayout* layout = new QHBoxLayout(listBox);215 QHBoxLayout* layout = new QHBoxLayout(listBox);
@@ -198,21 +240,26 @@
198 return _action;240 return _action;
199}241}
200242
201DspParameter& DsprParam::param()243DspParameter const& DsprParam::param()
202{244{
203 return _param;245 return _param;
204}246}
205247
206int DsprParam::compId()248int DsprParam::compId() const
207{249{
208 return _compId;250 return _compId;
209}251}
210252
211int DsprParam::paramId()253int DsprParam::paramId() const
212{254{
213 return _paramId;255 return _paramId;
214}256}
215257
258std::string DsprParam::name() const
259{
260 return _name;
261}
262
216bool DsprParam::SetBool(bool const& value)263bool DsprParam::SetBool(bool const& value)
217{264{
218 _settingParam = true;265 _settingParam = true;
@@ -320,26 +367,28 @@
320 return result;367 return result;
321}368}
322369
370void DsprParam::paramChanged(bool value)
371{
372 if (_settingParam)
373 {
374 return;
375 }
376 if (_param.Type() == DspParameter::Bool)
377 {
378 _param.SetBool(value != 0);
379 emit boolUpdated(value != 0);
380 }
381}
382
323void DsprParam::paramChanged(int value)383void DsprParam::paramChanged(int value)
324{384{
325 if (_settingParam)385 if (_settingParam)
326 {386 {
327 return;387 return;
328 }388 }
329 if (_param.Type() == DspParameter::Bool)389 if (_param.Type() == DspParameter::List)
330 {390 {
331 emit boolUpdated(value != 0);391 _param.SetInt(value);
332 }
333 else if (_param.Type() == DspParameter::Int)
334 {
335 emit intUpdated(value);
336 }
337 else if (_param.Type() == DspParameter::Float)
338 {
339 emit floatUpdated((float)value / 100.f);
340 }
341 else if (_param.Type() == DspParameter::List)
342 {
343 emit intUpdated(value);392 emit intUpdated(value);
344 }393 }
345}394}
@@ -350,12 +399,46 @@
350 {399 {
351 return;400 return;
352 }401 }
353 if (_param.Type() == DspParameter::String)402 if (_param.Type() == DspParameter::Int)
354 {403 {
404 int value = newString.toInt();
405
406 _settingParam = true;
407 _slider->setValue(value);
408 if (value < _slider->minimum() || value > _slider->maximum())
409 {
410 value = _slider->sliderPosition();
411 _textBox->setText(QString::number(value));
412 }
413 _settingParam = false;
414
415 _param.SetInt(value);
416 emit intUpdated(value);
417 }
418 else if (_param.Type() == DspParameter::Float)
419 {
420 float value = newString.toFloat();
421
422 _settingParam = true;
423 _slider->setValue(value * 100);
424 if (value * 100 < _slider->minimum() || value * 100 > _slider->maximum())
425 {
426 value = (float)_slider->sliderPosition() / 100;
427 _textBox->setText(QString::number(value));
428 }
429 _settingParam = false;
430
431 _param.SetFloat(value);
432 emit floatUpdated(value);
433 }
434 else if (_param.Type() == DspParameter::String)
435 {
436 _param.SetString(newString.toUtf8().constData());
355 emit stringUpdated(newString.toUtf8().constData());437 emit stringUpdated(newString.toUtf8().constData());
356 }438 }
357 else if (_param.Type() == DspParameter::FilePath)439 else if (_param.Type() == DspParameter::FilePath)
358 {440 {
441 _param.SetString(newString.toUtf8().constData());
359 emit stringUpdated(newString.toUtf8().constData());442 emit stringUpdated(newString.toUtf8().constData());
360 }443 }
361}444}
@@ -372,9 +455,16 @@
372 }455 }
373}456}
374457
375void DsprParam::updateFloatSlider(int value)458void DsprParam::updateSlider(int value)
376{459{
377 _vlabel->setNum((float)value / 100);460 if (_param.Type() == DspParameter::Int)
461 {
462 _textBox->setText(QString::number(value));
463 }
464 else if (_param.Type() == DspParameter::Float)
465 {
466 _textBox->setText(QString::number((float)value / 100));
467 }
378}468}
379469
380void DsprParam::browseForFile()470void DsprParam::browseForFile()
381471
=== modified file 'dspatcher/src/main.cpp'
--- dspatcher/src/main.cpp 2015-04-06 17:02:27 +0000
+++ dspatcher/src/main.cpp 2015-04-09 13:24:26 +0000
@@ -22,12 +22,10 @@
22MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.22MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
23************************************************************************/23************************************************************************/
2424
25#include <DSPatch.h>
26#include <DsprController.h>25#include <DsprController.h>
27#include <QtpMain.h>26#include <QtpMain.h>
2827
29#include <QApplication>28#include <QApplication>
30#include <QDir>
3129
32int main(int argv, char* args[])30int main(int argv, char* args[])
33{31{
@@ -35,46 +33,7 @@
35 QtpMain mainWindow;33 QtpMain mainWindow;
36 mainWindow.show();34 mainWindow.show();
3735
38 std::vector<DspPluginLoader> pluginLoaders;36 DsprController controller(mainWindow);
39
40 // Load DSPatch plugins from "dspatchables" folder
41 QDir dir(PLUGIN_DIR);
42 QFileInfoList files = dir.entryInfoList();
43 foreach(QFileInfo const& file, files)
44 {
45 #ifdef _WIN32
46 if (file.isFile() && file.fileName().endsWith(".dll"))
47 #else
48 if (file.isFile())
49 #endif
50 {
51 QString path = file.absoluteFilePath();
52 DspPluginLoader loader(path.toUtf8().constData());
53 if (loader.IsLoaded())
54 {
55 pluginLoaders.push_back(loader);
56 std::map<std::string, DspParameter> params = loader.GetCreateParams();
57 DspComponent* comp = loader.Create(params);
58
59 QtpComp::CompInfo compInfo;
60 compInfo.typeId = pluginLoaders.size() - 1;
61 compInfo.typeName = file.baseName().mid(0, 3) == "lib" ? file.baseName().mid(3) : file.baseName();
62 for (int i = 0; i < comp->GetInputCount(); ++i)
63 {
64 compInfo.inPins.append(comp->GetInputName(i).c_str());
65 }
66 for (int i = 0; i < comp->GetOutputCount(); ++i)
67 {
68 compInfo.outPins.append(comp->GetOutputName(i).c_str());
69 }
70 mainWindow.registerComponent(compInfo);
71
72 delete comp;
73 }
74 }
75 }
76
77 DsprController controller(mainWindow.diagram(), pluginLoaders);
7837
79 return app.exec();38 return app.exec();
80}39}
8140
=== added file 'dspatcher/update_install_names.sh'
--- dspatcher/update_install_names.sh 1970-01-01 00:00:00 +0000
+++ dspatcher/update_install_names.sh 2015-04-09 13:24:26 +0000
@@ -0,0 +1,9 @@
1#!/bin/bash
2dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
3
4install_name_tool -id $dir/link/libDSPatch.dylib $dir/link/libDSPatch.dylib
5
6for file in $dir/dspatchables/*.dylib; do
7 install_name_tool -id $file $file
8 install_name_tool -change $(cut -d ' ' -f 1 <<< $(otool -L $file | grep libDSPatch.dylib)) $dir/link/libDSPatch.dylib $file
9done
0\ No newline at end of file10\ No newline at end of file
111
=== modified file 'qtpatcher/include/QtpMain.h'
--- qtpatcher/include/QtpMain.h 2015-04-07 16:21:36 +0000
+++ qtpatcher/include/QtpMain.h 2015-04-09 13:24:26 +0000
@@ -46,6 +46,7 @@
46 QtpDiag* diagram();46 QtpDiag* diagram();
4747
48 void registerComponent(QtpComp::CompInfo const& compInfo);48 void registerComponent(QtpComp::CompInfo const& compInfo);
49 void unregisterComponents();
4950
50private slots:51private slots:
51 void buttonGroupClicked(int id);52 void buttonGroupClicked(int id);
5253
=== modified file 'qtpatcher/src/QtpMain.cpp'
--- qtpatcher/src/QtpMain.cpp 2015-04-07 16:21:36 +0000
+++ qtpatcher/src/QtpMain.cpp 2015-04-09 13:24:26 +0000
@@ -71,8 +71,7 @@
7171
72 _toolBox->deleteLater();72 _toolBox->deleteLater();
73 _toolBox = new QToolBox;73 _toolBox = new QToolBox;
74 _toolBox->setSizePolicy(QSizePolicy(QSizePolicy::Maximum, QSizePolicy::Ignored));74 _toolBox->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Ignored);
75 _toolBox->setMinimumWidth(_compWidget->sizeHint().width() + 15);
76 _toolBox->addItem(_compWidget, tr("Components"));75 _toolBox->addItem(_compWidget, tr("Components"));
7776
78 centralWidget()->layout()->removeWidget(_view);77 centralWidget()->layout()->removeWidget(_view);
@@ -80,6 +79,19 @@
80 centralWidget()->layout()->addWidget(_view);79 centralWidget()->layout()->addWidget(_view);
81}80}
8281
82void QtpMain::unregisterComponents()
83{
84 _buttonGroup->deleteLater();
85 _compWidget->deleteLater();
86 _toolBox->deleteLater();
87
88 createToolBox();
89
90 centralWidget()->layout()->removeWidget(_view);
91 centralWidget()->layout()->addWidget(_toolBox);
92 centralWidget()->layout()->addWidget(_view);
93}
94
83void QtpMain::buttonGroupClicked(int id)95void QtpMain::buttonGroupClicked(int id)
84{96{
85 QList<QAbstractButton*> buttons = _buttonGroup->buttons();97 QList<QAbstractButton*> buttons = _buttonGroup->buttons();
@@ -128,8 +140,7 @@
128 _compWidget->setLayout(compLayout);140 _compWidget->setLayout(compLayout);
129141
130 _toolBox = new QToolBox;142 _toolBox = new QToolBox;
131 _toolBox->setSizePolicy(QSizePolicy(QSizePolicy::Maximum, QSizePolicy::Ignored));143 _toolBox->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Ignored);
132 _toolBox->setMinimumWidth(150);
133 _toolBox->addItem(_compWidget, tr("Components"));144 _toolBox->addItem(_compWidget, tr("Components"));
134}145}
135146

Subscribers

People subscribed via source and target branches

to all changes: