SCIRun  5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ModuleDialogGeneric.h
Go to the documentation of this file.
1 /*
2  For more information, please see: http://software.sci.utah.edu
3 
4  The MIT License
5 
6  Copyright (c) 2012 Scientific Computing and Imaging Institute,
7  University of Utah.
8 
9  License for the specific language governing rights and limitations under
10  Permission is hereby granted, free of charge, to any person obtaining a
11  copy of this software and associated documentation files (the "Software"),
12  to deal in the Software without restriction, including without limitation
13  the rights to use, copy, modify, merge, publish, distribute, sublicense,
14  and/or sell copies of the Software, and to permit persons to whom the
15  Software is furnished to do so, subject to the following conditions:
16 
17  The above copyright notice and this permission notice shall be included
18  in all copies or substantial portions of the Software.
19 
20  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26  DEALINGS IN THE SOFTWARE.
27 */
28 
29 #ifndef INTERFACE_APPLICATION_MODULE_DIALOG_GENERIC_H
30 #define INTERFACE_APPLICATION_MODULE_DIALOG_GENERIC_H
31 
33 #include <Core/Algorithms/Base/AlgorithmBase.h> //TODO: split up this header!
34 #include <QtGui>
35 #include <boost/atomic.hpp>
36 #include <boost/noncopyable.hpp>
37 #include <boost/bimap.hpp>
39 
40 namespace SCIRun {
41 namespace Gui {
42 
43  typedef boost::bimap<std::string,std::string> GuiStringTranslationMap;
44 
45  class SCISHARE ModuleDialogGeneric : public QDialog, boost::noncopyable
46  {
47  Q_OBJECT
48  public:
49  virtual ~ModuleDialogGeneric();
50  bool isPulling() const { return pulling_; } //yuck
51 
52  //TODO: input state hookup?
53  //yeah: eventually replace int with generic dialog state object, but needs to be two-way (set/get)
54  //virtual int moduleExecutionTime() = 0;
55  //TODO: how to genericize this? do we need to?
56  public Q_SLOTS:
57  virtual void moduleExecuted() {}
58  //need a better name: read/updateUI
59  virtual void pull() = 0;
60  void pull_newVersionToReplaceOld();
61  Q_SIGNALS:
62  void executionTimeChanged(int time);
63  void executeButtonPressed();
64  protected:
65  explicit ModuleDialogGeneric(SCIRun::Dataflow::Networks::ModuleStateHandle state, QWidget* parent = 0);
66  void fixSize();
68 
69  //TODO: need a better push/pull model
70  boost::atomic<bool> pulling_;
71  struct Pulling
72  {
73  explicit Pulling(ModuleDialogGeneric* m) : m_(m) { m->pulling_ = true; }
74  ~Pulling() { m_->pulling_ = false; }
76  };
77 
78  void addComboBoxManager(QComboBox* comboBox, const Core::Algorithms::AlgorithmParameterName& stateKey);
79  void addComboBoxManager(QComboBox* comboBox, const Core::Algorithms::AlgorithmParameterName& stateKey, const GuiStringTranslationMap& stringMap);
80  void addTextEditManager(QTextEdit* textEdit, const Core::Algorithms::AlgorithmParameterName& stateKey);
81  void addLineEditManager(QLineEdit* lineEdit, const Core::Algorithms::AlgorithmParameterName& stateKey);
82  void addDoubleLineEditManager(QLineEdit* lineEdit, const Core::Algorithms::AlgorithmParameterName& stateKey);
83  void addSpinBoxManager(QSpinBox* spinBox, const Core::Algorithms::AlgorithmParameterName& stateKey);
84  void addDoubleSpinBoxManager(QDoubleSpinBox* spinBox, const Core::Algorithms::AlgorithmParameterName& stateKey);
85  void addCheckBoxManager(QCheckBox* checkBox, const Core::Algorithms::AlgorithmParameterName& stateKey);
86  void addCheckableButtonManager(QAbstractButton* checkable, const Core::Algorithms::AlgorithmParameterName& stateKey);
87  void addTwoChoiceBooleanComboBoxManager(QComboBox* comboBox, const Core::Algorithms::AlgorithmParameterName& stateKey);
88  private:
89  void addWidgetSlotManager(WidgetSlotManagerPtr ptr);
90  std::vector<WidgetSlotManagerPtr> slotManagers_;
91  };
92 
93 }
94 }
95 
96 #endif
Definition: AlgorithmBase.h:52
boost::bimap< std::string, std::string > GuiStringTranslationMap
Definition: ModuleDialogGeneric.h:43
virtual void moduleExecuted()
Definition: ModuleDialogGeneric.h:57
SCIRun::Dataflow::Networks::ModuleStateHandle state_
Definition: ModuleDialogGeneric.h:67
boost::shared_ptr< ModuleStateInterface > ModuleStateHandle
Definition: NetworkFwd.h:75
#define SCISHARE
Definition: share.h:39
~Pulling()
Definition: ModuleDialogGeneric.h:74
Definition: ModuleDialogGeneric.h:71
Definition: ModuleDialogGeneric.h:45
Pulling(ModuleDialogGeneric *m)
Definition: ModuleDialogGeneric.h:73
boost::atomic< bool > pulling_
Definition: ModuleDialogGeneric.h:70
boost::shared_ptr< WidgetSlotManager > WidgetSlotManagerPtr
Definition: WidgetSlotManagers.h:56
bool isPulling() const
Definition: ModuleDialogGeneric.h:50
ModuleDialogGeneric * m_
Definition: ModuleDialogGeneric.h:75