TCircleBasedParamsGuiComp.h
Go to the documentation of this file.
1 #ifndef iqt2d_TCircleBasedParamsGuiComp_included
2 #define iqt2d_TCircleBasedParamsGuiComp_included
3 
4 
5 // ACF includes
7 
8 #include <GeneratedFiles/iqt2d/ui_CCircleParamsGuiComp.h>
9 
10 
11 namespace iqt2d
12 {
13 
14 
15 template <class CircleBasedShape, class CircleBasedModel>
18  Ui::CCircleParamsGuiComp,
19  CircleBasedShape,
20  CircleBasedModel>
21 {
22 public:
24  Ui::CCircleParamsGuiComp,
25  CircleBasedShape,
26  CircleBasedModel> BaseClass;
27 
28  I_BEGIN_BASE_COMPONENT(TCircleBasedParamsGuiComp);
29  I_END_COMPONENT;
30 
31 protected:
32  // reimplemented (iqtgui::TGuiObserverWrap)
33  virtual void OnGuiModelAttached();
34  virtual void UpdateModel() const;
35  virtual void UpdateGui(const istd::IChangeable::ChangeSet& changeSet);
36 
37  // reimplemented (iqtgui::CGuiComponentBase)
38  virtual void OnGuiCreated();
39  virtual void OnGuiRetranslate();
40 
41 protected:
48  using BaseClass::tr;
50  using BaseClass::XSpin;
51  using BaseClass::YSpin;
52  using BaseClass::RadiusSpin;
53  using BaseClass::ToolsButton;
55  using BaseClass::PositionUnitLabel;
56  using BaseClass::RadiusUnitLabel;
57 };
58 
59 
60 // protected methods
61 
62 // reimplemented (iqtgui::TGuiObserverWrap)
63 
64 template <class CircleBasedShape, class CircleBasedModel>
66 {
67  BaseClass::OnGuiModelAttached();
68 }
69 
70 
71 template <class CircleBasedShape, class CircleBasedModel>
73 {
74  Q_ASSERT(BaseClass::IsGuiCreated());
75 
76  CircleBasedModel* objectPtr = GetObservedObject();
77  Q_ASSERT(objectPtr != NULL);
78 
79  istd::CChangeGroup changeGroup(objectPtr);
80  Q_UNUSED(changeGroup);
81 
82  i2d::CVector2d postion(XSpin->value(), YSpin->value());
83  objectPtr->SetPosition(postion);
84 
85  double radius = RadiusSpin->value();
86  objectPtr->SetRadius(radius);
87 }
88 
89 
90 template <class CircleBasedShape, class CircleBasedModel>
92 {
93  Q_ASSERT(BaseClass::IsGuiCreated());
94 
95  CircleBasedModel* objectPtr = GetObservedObject();
96  if (objectPtr != NULL){
97  const i2d::CVector2d& center = objectPtr->GetCenter();
98 
99  XSpin->setValue(center.GetX());
100  YSpin->setValue(center.GetY());
101 
102  RadiusSpin->setValue(objectPtr->GetRadius());
103 
104  UpdateAllViews();
105  }
106 
107  // tools actions
108  CreateToolsMenu(ToolsButton);
109 }
110 
111 
112 // reimplemented (iqtgui::CGuiComponentBase)
113 
114 template <class CircleBasedShape, class CircleBasedModel>
116 {
117  BaseClass::OnGuiCreated();
118 
119  if (IsPositionFixed()){
120  XSpin->setEnabled(false);
121  YSpin->setEnabled(false);
122  }
123  else{
124  QObject::connect(XSpin, SIGNAL(valueChanged(double)), this, SLOT(OnParamsChanged(double)));
125  QObject::connect(YSpin, SIGNAL(valueChanged(double)), this, SLOT(OnParamsChanged(double)));
126  }
127 
128  QObject::connect(RadiusSpin, SIGNAL(valueChanged(double)), this, SLOT(OnParamsChanged(double)));
129 }
130 
131 
132 // reimplemented (iqtgui::CGuiComponentBase)
133 
134 template <class CircleBasedShape, class CircleBasedModel>
136 {
137  BaseClass::OnGuiRetranslate();
138 
139  QString unitName = GetUnitName();
140 
141  if (!unitName.isEmpty()){
142  PositionUnitLabel->setText(unitName);
143  RadiusUnitLabel->setText(unitName);
144  PositionUnitLabel->setVisible(true);
145  RadiusUnitLabel->setVisible(true);
146  }
147  else{
148  PositionUnitLabel->setVisible(false);
149  RadiusUnitLabel->setVisible(false);
150  }
151 }
152 
153 
154 } // namespace iqt2d
155 
156 
157 #endif // !iqt2d_TCircleBasedParamsGuiComp_included
158 
159 
virtual void UpdateGui(const istd::IChangeable::ChangeSet &changeSet)
Do update of the GUI to reflect the state of model.
virtual void OnGuiCreated()
Called just after GUI is initialized.
virtual void OnGuiRetranslate()
Called from widget event filter when GUI should be retranslated.
CircleBasedModel * GetObservedObject() const
Get instance of observed object.
Help class which provides the group of changes for update mechanism of the model. ...
Definition: CChangeGroup.h:21
double GetY() const
Get Y position of this vector.
Definition: CVector2d.h:184
iqt2d::TShapeParamsGuiCompBase< Ui::CCircleParamsGuiComp, CircleBasedShape, CircleBasedModel > BaseClass
imod::IModel * GetObservedModel() const
Get access to observed model.
Definition of position or mathematical vector on 2D plane.
Definition: CVector2d.h:28
#define NULL
Definition: istd.h:64
virtual void CreateToolsMenu(QAbstractButton *buttonPtr)
Maintenance of the tools actions.
virtual void OnGuiModelAttached()
Called when model is attached and GUI is created.
virtual void UpdateModel() const
Do update of the model to reflect the current contents of GUI.
Set of change flags (its IDs).
Definition: IChangeable.h:30
double GetX() const
Get X position of this vector.
Definition: CVector2d.h:172
virtual QWidget * GetQtWidget() const

© 2007-2017 Witold Gantzke and Kirill Lepskiy