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 |
Related bugs: |
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
Description of the change
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
1 | === modified file 'dspatcher/CMakeLists.txt' |
2 | --- dspatcher/CMakeLists.txt 2015-04-07 15:48:58 +0000 |
3 | +++ dspatcher/CMakeLists.txt 2015-04-09 13:24:26 +0000 |
4 | @@ -21,6 +21,10 @@ |
5 | QtPatcher |
6 | ) |
7 | |
8 | +if(APPLE) |
9 | + execute_process(COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/update_install_names.sh) |
10 | +endif(APPLE) |
11 | + |
12 | if(WIN32) |
13 | add_custom_command( |
14 | TARGET ${PROJECT_NAME} POST_BUILD |
15 | |
16 | === modified file 'dspatcher/include/DsprController.h' |
17 | --- dspatcher/include/DsprController.h 2015-04-06 14:19:57 +0000 |
18 | +++ dspatcher/include/DsprController.h 2015-04-09 13:24:26 +0000 |
19 | @@ -29,14 +29,17 @@ |
20 | #include <DsprParam.h> |
21 | #include <QtpMain.h> |
22 | |
23 | +#include <QFileSystemWatcher> |
24 | #include <QObject> |
25 | |
26 | +#include <set> |
27 | + |
28 | class DsprController : public QObject |
29 | { |
30 | Q_OBJECT |
31 | |
32 | public: |
33 | - DsprController(QtpDiag* diagram, std::vector<DspPluginLoader> const& pluginLoaders); |
34 | + DsprController(QtpMain& mainWindow); |
35 | ~DsprController(); |
36 | |
37 | signals: |
38 | @@ -61,6 +64,8 @@ |
39 | void triggerUpdated(); |
40 | |
41 | private slots: |
42 | + void _loadPlugins(); |
43 | + |
44 | void _inputAdded(DspComponent* component, int index); |
45 | void _inputRemoved(DspComponent* component, int index); |
46 | void _outputAdded(DspComponent* component, int index); |
47 | @@ -70,7 +75,9 @@ |
48 | void _parameterUpdated(DspComponent* component, int index); |
49 | |
50 | private: |
51 | - bool _settingParam; |
52 | + QFileSystemWatcher _fileWatcher; |
53 | + QtpMain& _mainWindow; |
54 | + std::set<int> _settingParams; |
55 | std::vector<DspPluginLoader> _pluginLoaders; |
56 | |
57 | std::map<DspComponent const*, QtpComp*> _qtpComps; |
58 | |
59 | === modified file 'dspatcher/include/DsprParam.h' |
60 | --- dspatcher/include/DsprParam.h 2015-04-06 16:59:42 +0000 |
61 | +++ dspatcher/include/DsprParam.h 2015-04-09 13:24:26 +0000 |
62 | @@ -49,10 +49,11 @@ |
63 | public: |
64 | DsprParam(int compId, int paramId, std::string const& name, DspParameter const& param, QMenu* contextMenu); |
65 | QWidgetAction* action(); |
66 | - DspParameter& param(); |
67 | + DspParameter const& param(); |
68 | |
69 | - int compId(); |
70 | - int paramId(); |
71 | + int compId() const; |
72 | + int paramId() const; |
73 | + std::string name() const; |
74 | |
75 | bool SetBool(bool const& value); |
76 | bool SetInt(int const& value); |
77 | @@ -70,17 +71,19 @@ |
78 | void triggerUpdated(); |
79 | |
80 | private slots: |
81 | + void paramChanged(bool value); |
82 | void paramChanged(int value); |
83 | void paramChanged(QString const&); |
84 | void paramChanged(); |
85 | |
86 | - void updateFloatSlider(int value); |
87 | + void updateSlider(int value); |
88 | void browseForFile(); |
89 | |
90 | private: |
91 | bool _settingParam; |
92 | int _compId; |
93 | int _paramId; |
94 | + std::string _name; |
95 | DspParameter _param; |
96 | QMenu* _contextMenu; |
97 | QWidgetAction* _action; |
98 | @@ -90,7 +93,6 @@ |
99 | QLineEdit* _textBox; |
100 | QComboBox* _listBox; |
101 | QPushButton* _button; |
102 | - QLabel* _vlabel; |
103 | }; |
104 | |
105 | #endif // DSPRPARAM_H |
106 | |
107 | === removed directory 'dspatcher/link/Debug' |
108 | === renamed file 'dspatcher/link/Debug/libDSPatch.dylib' => 'dspatcher/link/libDSPatch.dylib' |
109 | === modified file 'dspatcher/src/DsprController.cpp' |
110 | --- dspatcher/src/DsprController.cpp 2015-04-06 14:19:57 +0000 |
111 | +++ dspatcher/src/DsprController.cpp 2015-04-09 13:24:26 +0000 |
112 | @@ -24,19 +24,26 @@ |
113 | |
114 | #include <DsprController.h> |
115 | |
116 | +#include <DSPatch.h> |
117 | #include <QtpDiag.h> |
118 | |
119 | -DsprController::DsprController(QtpDiag* diagram, std::vector<DspPluginLoader> const& pluginLoaders) |
120 | - : _settingParam(false) |
121 | - , _pluginLoaders(pluginLoaders) |
122 | +#include <QDir> |
123 | + |
124 | +DsprController::DsprController(QtpMain& mainWindow) |
125 | + : _mainWindow(mainWindow) |
126 | { |
127 | + _fileWatcher.addPath(PLUGIN_DIR); |
128 | + ///!connect(&_fileWatcher, SIGNAL(directoryChanged(QString const&)), this, SLOT(_loadPlugins())); |
129 | + |
130 | + _loadPlugins(); |
131 | + |
132 | _circuit.SetThreadCount(2); |
133 | _circuit.StartAutoTick(); |
134 | |
135 | - connect(diagram, &QtpDiag::compInserted, this, &DsprController::compInserted); |
136 | - connect(diagram, &QtpDiag::compRemoved, this, &DsprController::compRemoved); |
137 | - connect(diagram, &QtpDiag::wireConnected, this, &DsprController::wireConnected); |
138 | - connect(diagram, &QtpDiag::wireDisconnected, this, &DsprController::wireDisconnected); |
139 | + connect(_mainWindow.diagram(), &QtpDiag::compInserted, this, &DsprController::compInserted); |
140 | + connect(_mainWindow.diagram(), &QtpDiag::compRemoved, this, &DsprController::compRemoved); |
141 | + connect(_mainWindow.diagram(), &QtpDiag::wireConnected, this, &DsprController::wireConnected); |
142 | + connect(_mainWindow.diagram(), &QtpDiag::wireDisconnected, this, &DsprController::wireDisconnected); |
143 | |
144 | connect(this, &DsprController::inputAdded, this, &DsprController::_inputAdded); |
145 | connect(this, &DsprController::inputRemoved, this, &DsprController::_inputRemoved); |
146 | @@ -108,7 +115,46 @@ |
147 | { |
148 | DspPluginLoader loader = _pluginLoaders[qtpComp->compInfo().typeId]; |
149 | std::map<std::string, DspParameter> params = loader.GetCreateParams(); |
150 | + |
151 | + // Show construction menu |
152 | + std::vector<DsprParam*> dsprParams; |
153 | + typedef std::map<std::string, DspParameter>::iterator it_type; |
154 | + for (it_type iterator = params.begin(); iterator != params.end(); iterator++) |
155 | + { |
156 | + DsprParam* param = new DsprParam(qtpComp->id(), 0, iterator->first, |
157 | + iterator->second, qtpComp->contextMenu()); |
158 | + qtpComp->contextMenu()->addAction(param->action()); |
159 | + dsprParams.push_back(param); |
160 | + } |
161 | + if (params.size() > 0) |
162 | + { |
163 | + qtpComp->contextMenu()->exec(QCursor::pos()); |
164 | + } |
165 | + |
166 | + // Construct component with values from menu |
167 | + foreach (DsprParam* dsprParam, dsprParams) |
168 | + { |
169 | + params[dsprParam->name()] = dsprParam->param(); |
170 | + delete dsprParam; |
171 | + } |
172 | + qtpComp->contextMenu()->clear(); |
173 | + |
174 | DspComponent* component = loader.Create(params); |
175 | + if (component == NULL) |
176 | + { |
177 | + return; |
178 | + } |
179 | + |
180 | + qtpComp->removeInPins(); |
181 | + qtpComp->removeOutPins(); |
182 | + for (int i = 0; i < component->GetInputCount(); ++i) |
183 | + { |
184 | + qtpComp->addInPin(component->GetInputName(i).c_str()); |
185 | + } |
186 | + for (int i = 0; i < component->GetOutputCount(); ++i) |
187 | + { |
188 | + qtpComp->addOutPin(component->GetOutputName(i).c_str()); |
189 | + } |
190 | |
191 | component->SetCallback(callback, this); |
192 | _circuit.AddComponent(component); |
193 | @@ -162,42 +208,54 @@ |
194 | |
195 | void DsprController::boolUpdated(bool value) |
196 | { |
197 | - _settingParam = true; |
198 | DsprParam* param = dynamic_cast<DsprParam*>(sender()); |
199 | - _components[param->compId()]->SetParameter(param->paramId(), DspParameter(DspParameter::Bool, value)); |
200 | - _settingParam = false; |
201 | + _settingParams.insert(param->paramId()); |
202 | + if (!_components[param->compId()]->SetParameter(param->paramId(), DspParameter(DspParameter::Bool, value))) |
203 | + { |
204 | + param->SetBool(*(_components[param->compId()]->GetParameter(param->paramId())->GetBool())); |
205 | + } |
206 | + _settingParams.erase(param->paramId()); |
207 | } |
208 | |
209 | void DsprController::intUpdated(int value) |
210 | { |
211 | - _settingParam = true; |
212 | DsprParam* param = dynamic_cast<DsprParam*>(sender()); |
213 | - _components[param->compId()]->SetParameter(param->paramId(), DspParameter(DspParameter::Int, value)); |
214 | - _settingParam = false; |
215 | + _settingParams.insert(param->paramId()); |
216 | + if (!_components[param->compId()]->SetParameter(param->paramId(), DspParameter(DspParameter::Int, value))) |
217 | + { |
218 | + param->SetInt(*(_components[param->compId()]->GetParameter(param->paramId())->GetInt())); |
219 | + } |
220 | + _settingParams.erase(param->paramId()); |
221 | } |
222 | |
223 | void DsprController::floatUpdated(float value) |
224 | { |
225 | - _settingParam = true; |
226 | DsprParam* param = dynamic_cast<DsprParam*>(sender()); |
227 | - _components[param->compId()]->SetParameter(param->paramId(), DspParameter(DspParameter::Float, value)); |
228 | - _settingParam = false; |
229 | + _settingParams.insert(param->paramId()); |
230 | + if (!_components[param->compId()]->SetParameter(param->paramId(), DspParameter(DspParameter::Float, value))) |
231 | + { |
232 | + param->SetFloat(*(_components[param->compId()]->GetParameter(param->paramId())->GetFloat())); |
233 | + } |
234 | + _settingParams.erase(param->paramId()); |
235 | } |
236 | |
237 | void DsprController::stringUpdated(std::string const& value) |
238 | { |
239 | - _settingParam = true; |
240 | DsprParam* param = dynamic_cast<DsprParam*>(sender()); |
241 | - _components[param->compId()]->SetParameter(param->paramId(), DspParameter(DspParameter::String, value)); |
242 | - _settingParam = false; |
243 | + _settingParams.insert(param->paramId()); |
244 | + if (!_components[param->compId()]->SetParameter(param->paramId(), DspParameter(DspParameter::String, value))) |
245 | + { |
246 | + param->SetString(*(_components[param->compId()]->GetParameter(param->paramId())->GetString())); |
247 | + } |
248 | + _settingParams.erase(param->paramId()); |
249 | } |
250 | |
251 | void DsprController::triggerUpdated() |
252 | { |
253 | - _settingParam = true; |
254 | DsprParam* param = dynamic_cast<DsprParam*>(sender()); |
255 | + _settingParams.insert(param->paramId()); |
256 | _components[param->compId()]->SetParameter(param->paramId(), DspParameter(DspParameter::Trigger)); |
257 | - _settingParam = false; |
258 | + _settingParams.erase(param->paramId()); |
259 | } |
260 | |
261 | void DsprController::_inputAdded(DspComponent* component, int index) |
262 | @@ -275,7 +333,8 @@ |
263 | |
264 | void DsprController::_parameterUpdated(DspComponent* component, int index) |
265 | { |
266 | - if (_settingParam) |
267 | + // don't react if we are the one setting the parameter |
268 | + if (_settingParams.find(index) != _settingParams.end()) |
269 | { |
270 | return; |
271 | } |
272 | @@ -314,3 +373,49 @@ |
273 | break; |
274 | } |
275 | } |
276 | + |
277 | +void DsprController::_loadPlugins() |
278 | +{ |
279 | + _mainWindow.unregisterComponents(); |
280 | + |
281 | + // Load DSPatch plugins from "dspatchables" folder |
282 | + QDir dir(PLUGIN_DIR); |
283 | + QFileInfoList files = dir.entryInfoList(); |
284 | + foreach(QFileInfo const& file, files) |
285 | + { |
286 | + #ifdef _WIN32 |
287 | + if (file.isFile() && file.fileName().endsWith(".dll")) |
288 | + #else |
289 | + if (file.isFile()) |
290 | + #endif |
291 | + { |
292 | + QString path = file.absoluteFilePath(); |
293 | + DspPluginLoader loader(path.toUtf8().constData()); |
294 | + if (loader.IsLoaded()) |
295 | + { |
296 | + _pluginLoaders.push_back(loader); |
297 | + std::map<std::string, DspParameter> params = loader.GetCreateParams(); |
298 | + DspComponent* comp = loader.Create(params); |
299 | + |
300 | + QtpComp::CompInfo compInfo; |
301 | + compInfo.typeId = _pluginLoaders.size() - 1; |
302 | + compInfo.typeName = file.baseName().mid(0, 3) == "lib" ? file.baseName().mid(3) : file.baseName(); |
303 | + |
304 | + if (comp) |
305 | + { |
306 | + for (int i = 0; i < comp->GetInputCount(); ++i) |
307 | + { |
308 | + compInfo.inPins.append(comp->GetInputName(i).c_str()); |
309 | + } |
310 | + for (int i = 0; i < comp->GetOutputCount(); ++i) |
311 | + { |
312 | + compInfo.outPins.append(comp->GetOutputName(i).c_str()); |
313 | + } |
314 | + } |
315 | + |
316 | + _mainWindow.registerComponent(compInfo); |
317 | + delete comp; |
318 | + } |
319 | + } |
320 | + } |
321 | +} |
322 | |
323 | === modified file 'dspatcher/src/DsprParam.cpp' |
324 | --- dspatcher/src/DsprParam.cpp 2015-04-06 16:59:42 +0000 |
325 | +++ dspatcher/src/DsprParam.cpp 2015-04-09 13:24:26 +0000 |
326 | @@ -28,18 +28,25 @@ |
327 | : _settingParam(false) |
328 | , _compId(compId) |
329 | , _paramId(paramId) |
330 | + , _name(name) |
331 | , _param(param) |
332 | , _contextMenu(contextMenu) |
333 | { |
334 | if (_param.Type() == DspParameter::Bool) |
335 | { |
336 | _checkbox = new QCheckBox(_contextMenu); |
337 | + |
338 | + if (_param.GetBool()) |
339 | + { |
340 | + _checkbox->setChecked(*_param.GetBool()); |
341 | + } |
342 | + |
343 | _checkbox->setText(name.c_str()); |
344 | QWidgetAction* customAction = new QWidgetAction(_contextMenu); |
345 | customAction->setDefaultWidget(_checkbox); |
346 | _action = customAction; |
347 | |
348 | - connect(_checkbox, SIGNAL(stateChanged(int)), this, SLOT(paramChanged(int))); |
349 | + connect(_checkbox, SIGNAL(toggled(bool)), this, SLOT(paramChanged(bool))); |
350 | } |
351 | else if (_param.Type() == DspParameter::Int) |
352 | { |
353 | @@ -50,31 +57,43 @@ |
354 | { |
355 | _slider->setRange(_param.GetIntRange()->first, _param.GetIntRange()->second); |
356 | } |
357 | - else |
358 | + else if (_param.GetInt()) |
359 | { |
360 | _slider->setRange(0, *_param.GetInt() * 2); |
361 | } |
362 | - _slider->setValue(*_param.GetInt()); |
363 | + else |
364 | + { |
365 | + _slider->setRange(0, 10000); |
366 | + } |
367 | + |
368 | + if (_param.GetInt()) |
369 | + { |
370 | + _slider->setValue(*_param.GetInt()); |
371 | + } |
372 | + else |
373 | + { |
374 | + _slider->setValue(5000); |
375 | + } |
376 | |
377 | QLabel* label = new QLabel(intSlider); |
378 | label->setText(name.c_str()); |
379 | |
380 | - _vlabel = new QLabel(intSlider); |
381 | - _vlabel->setNum(_slider->sliderPosition()); |
382 | - _vlabel->setFixedWidth(45); |
383 | + _textBox = new QLineEdit(intSlider); |
384 | + _textBox->setText(QString::number(_slider->sliderPosition())); |
385 | + _textBox->setFixedWidth(65); |
386 | |
387 | - connect(_slider, SIGNAL(valueChanged(int)), _vlabel, SLOT(setNum(int))); |
388 | + connect(_slider, SIGNAL(valueChanged(int)), this, SLOT(updateSlider(int))); |
389 | |
390 | QHBoxLayout* layout = new QHBoxLayout(intSlider); |
391 | layout->addWidget(label); |
392 | layout->addWidget(_slider); |
393 | - layout->addWidget(_vlabel); |
394 | + layout->addWidget(_textBox); |
395 | |
396 | QWidgetAction* intSliderAction = new QWidgetAction(_contextMenu); |
397 | intSliderAction->setDefaultWidget(intSlider); |
398 | _action = intSliderAction; |
399 | |
400 | - connect(_slider, SIGNAL(valueChanged(int)), this, SLOT(paramChanged(int))); |
401 | + connect(_textBox, SIGNAL(textChanged(QString const&)), this, SLOT(paramChanged(QString const&))); |
402 | } |
403 | else if (_param.Type() == DspParameter::Float) |
404 | { |
405 | @@ -85,31 +104,43 @@ |
406 | { |
407 | _slider->setRange(_param.GetFloatRange()->first * 100, _param.GetFloatRange()->second * 100); |
408 | } |
409 | - else |
410 | + else if (_param.GetFloat()) |
411 | { |
412 | _slider->setRange(0, *_param.GetFloat() * 200); |
413 | } |
414 | - _slider->setValue(*_param.GetFloat() * 100); |
415 | + else |
416 | + { |
417 | + _slider->setRange(0, 10000 * 100); |
418 | + } |
419 | + |
420 | + if (_param.GetFloat()) |
421 | + { |
422 | + _slider->setValue(*_param.GetFloat() * 100); |
423 | + } |
424 | + else |
425 | + { |
426 | + _slider->setValue(5000 * 100); |
427 | + } |
428 | |
429 | QLabel* label = new QLabel(floatSlider); |
430 | label->setText(name.c_str()); |
431 | |
432 | - _vlabel = new QLabel(floatSlider); |
433 | - _vlabel->setNum(_slider->sliderPosition() / 100); |
434 | - _vlabel->setFixedWidth(45); |
435 | + _textBox = new QLineEdit(floatSlider); |
436 | + _textBox->setText(QString::number((float)_slider->sliderPosition() / 100)); |
437 | + _textBox->setFixedWidth(65); |
438 | |
439 | - connect(_slider, SIGNAL(valueChanged(int)), this, SLOT(updateFloatSlider(int))); |
440 | + connect(_slider, SIGNAL(valueChanged(int)), this, SLOT(updateSlider(int))); |
441 | |
442 | QHBoxLayout* layout = new QHBoxLayout(floatSlider); |
443 | layout->addWidget(label); |
444 | layout->addWidget(_slider); |
445 | - layout->addWidget(_vlabel); |
446 | + layout->addWidget(_textBox); |
447 | |
448 | QWidgetAction* intSliderAction = new QWidgetAction(_contextMenu); |
449 | intSliderAction->setDefaultWidget(floatSlider); |
450 | _action = intSliderAction; |
451 | |
452 | - connect(_slider, SIGNAL(valueChanged(int)), this, SLOT(paramChanged(int))); |
453 | + connect(_textBox, SIGNAL(textChanged(QString const&)), this, SLOT(paramChanged(QString const&))); |
454 | } |
455 | else if (_param.Type() == DspParameter::String) |
456 | { |
457 | @@ -119,7 +150,11 @@ |
458 | label->setText(name.c_str()); |
459 | |
460 | _textBox = new QLineEdit(textBox); |
461 | - _textBox->setText(_param.GetString()->c_str()); |
462 | + |
463 | + if (_param.GetString()) |
464 | + { |
465 | + _textBox->setText(_param.GetString()->c_str()); |
466 | + } |
467 | |
468 | QHBoxLayout* layout = new QHBoxLayout(textBox); |
469 | layout->addWidget(label); |
470 | @@ -139,8 +174,11 @@ |
471 | label->setText(name.c_str()); |
472 | |
473 | _textBox = new QLineEdit(fileBrowser); |
474 | - _textBox->setEnabled(false); |
475 | - _textBox->setText(_param.GetString()->c_str()); |
476 | + |
477 | + if (_param.GetString()) |
478 | + { |
479 | + _textBox->setText(_param.GetString()->c_str()); |
480 | + } |
481 | |
482 | QPushButton* btnBrowse = new QPushButton(fileBrowser); |
483 | btnBrowse->setText("Browse"); |
484 | @@ -165,9 +203,13 @@ |
485 | label->setText(name.c_str()); |
486 | |
487 | _listBox = new QComboBox(listBox); |
488 | - for (size_t i = 0; i < _param.GetList()->size(); ++i) |
489 | + |
490 | + if (_param.GetList()) |
491 | { |
492 | - _listBox->addItem((*_param.GetList())[i].c_str()); |
493 | + for (size_t i = 0; i < _param.GetList()->size(); ++i) |
494 | + { |
495 | + _listBox->addItem((*_param.GetList())[i].c_str()); |
496 | + } |
497 | } |
498 | |
499 | QHBoxLayout* layout = new QHBoxLayout(listBox); |
500 | @@ -198,21 +240,26 @@ |
501 | return _action; |
502 | } |
503 | |
504 | -DspParameter& DsprParam::param() |
505 | +DspParameter const& DsprParam::param() |
506 | { |
507 | return _param; |
508 | } |
509 | |
510 | -int DsprParam::compId() |
511 | +int DsprParam::compId() const |
512 | { |
513 | return _compId; |
514 | } |
515 | |
516 | -int DsprParam::paramId() |
517 | +int DsprParam::paramId() const |
518 | { |
519 | return _paramId; |
520 | } |
521 | |
522 | +std::string DsprParam::name() const |
523 | +{ |
524 | + return _name; |
525 | +} |
526 | + |
527 | bool DsprParam::SetBool(bool const& value) |
528 | { |
529 | _settingParam = true; |
530 | @@ -320,26 +367,28 @@ |
531 | return result; |
532 | } |
533 | |
534 | +void DsprParam::paramChanged(bool value) |
535 | +{ |
536 | + if (_settingParam) |
537 | + { |
538 | + return; |
539 | + } |
540 | + if (_param.Type() == DspParameter::Bool) |
541 | + { |
542 | + _param.SetBool(value != 0); |
543 | + emit boolUpdated(value != 0); |
544 | + } |
545 | +} |
546 | + |
547 | void DsprParam::paramChanged(int value) |
548 | { |
549 | if (_settingParam) |
550 | { |
551 | return; |
552 | } |
553 | - if (_param.Type() == DspParameter::Bool) |
554 | - { |
555 | - emit boolUpdated(value != 0); |
556 | - } |
557 | - else if (_param.Type() == DspParameter::Int) |
558 | - { |
559 | - emit intUpdated(value); |
560 | - } |
561 | - else if (_param.Type() == DspParameter::Float) |
562 | - { |
563 | - emit floatUpdated((float)value / 100.f); |
564 | - } |
565 | - else if (_param.Type() == DspParameter::List) |
566 | - { |
567 | + if (_param.Type() == DspParameter::List) |
568 | + { |
569 | + _param.SetInt(value); |
570 | emit intUpdated(value); |
571 | } |
572 | } |
573 | @@ -350,12 +399,46 @@ |
574 | { |
575 | return; |
576 | } |
577 | - if (_param.Type() == DspParameter::String) |
578 | - { |
579 | + if (_param.Type() == DspParameter::Int) |
580 | + { |
581 | + int value = newString.toInt(); |
582 | + |
583 | + _settingParam = true; |
584 | + _slider->setValue(value); |
585 | + if (value < _slider->minimum() || value > _slider->maximum()) |
586 | + { |
587 | + value = _slider->sliderPosition(); |
588 | + _textBox->setText(QString::number(value)); |
589 | + } |
590 | + _settingParam = false; |
591 | + |
592 | + _param.SetInt(value); |
593 | + emit intUpdated(value); |
594 | + } |
595 | + else if (_param.Type() == DspParameter::Float) |
596 | + { |
597 | + float value = newString.toFloat(); |
598 | + |
599 | + _settingParam = true; |
600 | + _slider->setValue(value * 100); |
601 | + if (value * 100 < _slider->minimum() || value * 100 > _slider->maximum()) |
602 | + { |
603 | + value = (float)_slider->sliderPosition() / 100; |
604 | + _textBox->setText(QString::number(value)); |
605 | + } |
606 | + _settingParam = false; |
607 | + |
608 | + _param.SetFloat(value); |
609 | + emit floatUpdated(value); |
610 | + } |
611 | + else if (_param.Type() == DspParameter::String) |
612 | + { |
613 | + _param.SetString(newString.toUtf8().constData()); |
614 | emit stringUpdated(newString.toUtf8().constData()); |
615 | } |
616 | else if (_param.Type() == DspParameter::FilePath) |
617 | { |
618 | + _param.SetString(newString.toUtf8().constData()); |
619 | emit stringUpdated(newString.toUtf8().constData()); |
620 | } |
621 | } |
622 | @@ -372,9 +455,16 @@ |
623 | } |
624 | } |
625 | |
626 | -void DsprParam::updateFloatSlider(int value) |
627 | +void DsprParam::updateSlider(int value) |
628 | { |
629 | - _vlabel->setNum((float)value / 100); |
630 | + if (_param.Type() == DspParameter::Int) |
631 | + { |
632 | + _textBox->setText(QString::number(value)); |
633 | + } |
634 | + else if (_param.Type() == DspParameter::Float) |
635 | + { |
636 | + _textBox->setText(QString::number((float)value / 100)); |
637 | + } |
638 | } |
639 | |
640 | void DsprParam::browseForFile() |
641 | |
642 | === modified file 'dspatcher/src/main.cpp' |
643 | --- dspatcher/src/main.cpp 2015-04-06 17:02:27 +0000 |
644 | +++ dspatcher/src/main.cpp 2015-04-09 13:24:26 +0000 |
645 | @@ -22,12 +22,10 @@ |
646 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
647 | ************************************************************************/ |
648 | |
649 | -#include <DSPatch.h> |
650 | #include <DsprController.h> |
651 | #include <QtpMain.h> |
652 | |
653 | #include <QApplication> |
654 | -#include <QDir> |
655 | |
656 | int main(int argv, char* args[]) |
657 | { |
658 | @@ -35,46 +33,7 @@ |
659 | QtpMain mainWindow; |
660 | mainWindow.show(); |
661 | |
662 | - std::vector<DspPluginLoader> pluginLoaders; |
663 | - |
664 | - // Load DSPatch plugins from "dspatchables" folder |
665 | - QDir dir(PLUGIN_DIR); |
666 | - QFileInfoList files = dir.entryInfoList(); |
667 | - foreach(QFileInfo const& file, files) |
668 | - { |
669 | - #ifdef _WIN32 |
670 | - if (file.isFile() && file.fileName().endsWith(".dll")) |
671 | - #else |
672 | - if (file.isFile()) |
673 | - #endif |
674 | - { |
675 | - QString path = file.absoluteFilePath(); |
676 | - DspPluginLoader loader(path.toUtf8().constData()); |
677 | - if (loader.IsLoaded()) |
678 | - { |
679 | - pluginLoaders.push_back(loader); |
680 | - std::map<std::string, DspParameter> params = loader.GetCreateParams(); |
681 | - DspComponent* comp = loader.Create(params); |
682 | - |
683 | - QtpComp::CompInfo compInfo; |
684 | - compInfo.typeId = pluginLoaders.size() - 1; |
685 | - compInfo.typeName = file.baseName().mid(0, 3) == "lib" ? file.baseName().mid(3) : file.baseName(); |
686 | - for (int i = 0; i < comp->GetInputCount(); ++i) |
687 | - { |
688 | - compInfo.inPins.append(comp->GetInputName(i).c_str()); |
689 | - } |
690 | - for (int i = 0; i < comp->GetOutputCount(); ++i) |
691 | - { |
692 | - compInfo.outPins.append(comp->GetOutputName(i).c_str()); |
693 | - } |
694 | - mainWindow.registerComponent(compInfo); |
695 | - |
696 | - delete comp; |
697 | - } |
698 | - } |
699 | - } |
700 | - |
701 | - DsprController controller(mainWindow.diagram(), pluginLoaders); |
702 | + DsprController controller(mainWindow); |
703 | |
704 | return app.exec(); |
705 | } |
706 | |
707 | === added file 'dspatcher/update_install_names.sh' |
708 | --- dspatcher/update_install_names.sh 1970-01-01 00:00:00 +0000 |
709 | +++ dspatcher/update_install_names.sh 2015-04-09 13:24:26 +0000 |
710 | @@ -0,0 +1,9 @@ |
711 | +#!/bin/bash |
712 | +dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) |
713 | + |
714 | +install_name_tool -id $dir/link/libDSPatch.dylib $dir/link/libDSPatch.dylib |
715 | + |
716 | +for file in $dir/dspatchables/*.dylib; do |
717 | + install_name_tool -id $file $file |
718 | + install_name_tool -change $(cut -d ' ' -f 1 <<< $(otool -L $file | grep libDSPatch.dylib)) $dir/link/libDSPatch.dylib $file |
719 | +done |
720 | \ No newline at end of file |
721 | |
722 | === modified file 'qtpatcher/include/QtpMain.h' |
723 | --- qtpatcher/include/QtpMain.h 2015-04-07 16:21:36 +0000 |
724 | +++ qtpatcher/include/QtpMain.h 2015-04-09 13:24:26 +0000 |
725 | @@ -46,6 +46,7 @@ |
726 | QtpDiag* diagram(); |
727 | |
728 | void registerComponent(QtpComp::CompInfo const& compInfo); |
729 | + void unregisterComponents(); |
730 | |
731 | private slots: |
732 | void buttonGroupClicked(int id); |
733 | |
734 | === modified file 'qtpatcher/src/QtpMain.cpp' |
735 | --- qtpatcher/src/QtpMain.cpp 2015-04-07 16:21:36 +0000 |
736 | +++ qtpatcher/src/QtpMain.cpp 2015-04-09 13:24:26 +0000 |
737 | @@ -71,8 +71,7 @@ |
738 | |
739 | _toolBox->deleteLater(); |
740 | _toolBox = new QToolBox; |
741 | - _toolBox->setSizePolicy(QSizePolicy(QSizePolicy::Maximum, QSizePolicy::Ignored)); |
742 | - _toolBox->setMinimumWidth(_compWidget->sizeHint().width() + 15); |
743 | + _toolBox->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Ignored); |
744 | _toolBox->addItem(_compWidget, tr("Components")); |
745 | |
746 | centralWidget()->layout()->removeWidget(_view); |
747 | @@ -80,6 +79,19 @@ |
748 | centralWidget()->layout()->addWidget(_view); |
749 | } |
750 | |
751 | +void QtpMain::unregisterComponents() |
752 | +{ |
753 | + _buttonGroup->deleteLater(); |
754 | + _compWidget->deleteLater(); |
755 | + _toolBox->deleteLater(); |
756 | + |
757 | + createToolBox(); |
758 | + |
759 | + centralWidget()->layout()->removeWidget(_view); |
760 | + centralWidget()->layout()->addWidget(_toolBox); |
761 | + centralWidget()->layout()->addWidget(_view); |
762 | +} |
763 | + |
764 | void QtpMain::buttonGroupClicked(int id) |
765 | { |
766 | QList<QAbstractButton*> buttons = _buttonGroup->buttons(); |
767 | @@ -128,8 +140,7 @@ |
768 | _compWidget->setLayout(compLayout); |
769 | |
770 | _toolBox = new QToolBox; |
771 | - _toolBox->setSizePolicy(QSizePolicy(QSizePolicy::Maximum, QSizePolicy::Ignored)); |
772 | - _toolBox->setMinimumWidth(150); |
773 | + _toolBox->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Ignored); |
774 | _toolBox->addItem(_compWidget, tr("Components")); |
775 | } |
776 |