2 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
4 #include "bbcreaMaracasVisuTransformWidget2.h"
5 #include "bbcreaMaracasVisuPackage.h"
6 namespace bbcreaMaracasVisu
10 // The widget created by the box
11 class TransformWidgetPanel : public wxPanel
14 TransformWidgetPanel(TransformWidget2* box, wxWindow *parent);
15 ~TransformWidgetPanel ();
16 void OnSetPoint (wxCommandEvent& event);
17 void Release (wxSlider *slider);
18 void Track (double angle ,int idVector);
19 void SetPossiblePoint (std::vector<double> possiblePoint);
23 void OnSliderTrackX (wxScrollEvent& event);
24 void OnSliderTrackY (wxScrollEvent& event);
25 void OnSliderTrackZ (wxScrollEvent& event);
26 void OnSliderReleaseX (wxScrollEvent& event);
27 void OnSliderReleaseY (wxScrollEvent& event);
28 void OnSliderReleaseZ (wxScrollEvent& event);
31 void OnRadioButtonX(wxEvent& event);
32 void OnRadioButtonY(wxEvent& event);
33 void OnRadioButtonZ(wxEvent& event);
34 void OnRadioButtonN(wxEvent& event);
35 void OnReset(wxCommandEvent& event);
36 void OnMoveDown(wxCommandEvent& event);
37 void OnMoveUp(wxCommandEvent& event);
38 void OnSliderGeneralTrack(wxScrollEvent& event);
39 void OnSliderGeneralRelease(wxScrollEvent& event);
44 std::vector<double> mPossiblePoint;
45 std::vector<double> mActualPoint;
46 TransformWidget2 *mBox;
49 wxSlider *mSliderRotationX;
50 wxSlider *mSliderRotationY;
51 wxSlider *mSliderRotationZ;
54 wxSlider *mSliderGeneral;
57 //------------------------------------------------------------------------
58 //------------------------------------------------------------------------
59 //------------------------------------------------------------------------
61 TransformWidgetPanel::TransformWidgetPanel(TransformWidget2* box, wxWindow *parent)
62 : wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL),
65 t = vtkTransform::New();
66 tt = vtkTransform::New();
67 mActualPoint.push_back(0);
68 mActualPoint.push_back(0);
69 mActualPoint.push_back(0);
71 mPossiblePoint.push_back(0);
72 mPossiblePoint.push_back(0);
73 mPossiblePoint.push_back(0);
75 wxSize sizeSliderWidget;
78 if (mBox->bbGetInputType()==0)
80 sizeSliderWidget.Set(25,25);
81 sizeButton.Set( 45 , -1 );
82 mSliderRotationX = new wxSlider( this, -1, 0 , -180, 180 , wxDefaultPosition,sizeSliderWidget, wxSL_HORIZONTAL, wxDefaultValidator );
83 mSliderRotationY = new wxSlider( this, -1, 0 , -180, 180 , wxDefaultPosition,sizeSliderWidget, wxSL_HORIZONTAL, wxDefaultValidator );
84 mSliderRotationZ = new wxSlider( this, -1, 0 , -180, 180 , wxDefaultPosition,sizeSliderWidget, wxSL_HORIZONTAL, wxDefaultValidator );
85 wxButton *mBtnSetPoint = new wxButton( this, -1, _T("Set Point") , wxDefaultPosition, sizeButton );
86 Connect(mBtnSetPoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction)(void (wxPanel::*)(wxScrollEvent&)) &TransformWidgetPanel::OnSetPoint );
87 Connect( mSliderRotationX->GetId(), wxEVT_SCROLL_THUMBRELEASE , (wxObjectEventFunction)(void (wxPanel::*)(wxScrollEvent&)) &TransformWidgetPanel::OnSliderReleaseX );
88 Connect( mSliderRotationX->GetId(), wxEVT_SCROLL_THUMBTRACK , (wxObjectEventFunction)(void (wxPanel::*)(wxScrollEvent&)) &TransformWidgetPanel::OnSliderTrackX );
89 Connect( mSliderRotationX->GetId(), wxEVT_SCROLL_CHANGED , (wxObjectEventFunction)(void (wxPanel::*)(wxScrollEvent&)) &TransformWidgetPanel::OnSliderTrackX );
90 Connect( mSliderRotationY->GetId(), wxEVT_SCROLL_THUMBRELEASE , (wxObjectEventFunction)(void (wxPanel::*)(wxScrollEvent&)) &TransformWidgetPanel::OnSliderReleaseY );
91 Connect( mSliderRotationY->GetId(), wxEVT_SCROLL_THUMBTRACK , (wxObjectEventFunction)(void (wxPanel::*)(wxScrollEvent&)) &TransformWidgetPanel::OnSliderTrackY );
92 Connect( mSliderRotationY->GetId(), wxEVT_SCROLL_CHANGED , (wxObjectEventFunction)(void (wxPanel::*)(wxScrollEvent&)) &TransformWidgetPanel::OnSliderTrackY );
93 Connect( mSliderRotationZ->GetId(), wxEVT_SCROLL_THUMBRELEASE , (wxObjectEventFunction)(void (wxPanel::*)(wxScrollEvent&)) &TransformWidgetPanel::OnSliderReleaseZ );
94 Connect( mSliderRotationZ->GetId(), wxEVT_SCROLL_THUMBTRACK , (wxObjectEventFunction)(void (wxPanel::*)(wxScrollEvent&)) &TransformWidgetPanel::OnSliderTrackZ );
95 Connect( mSliderRotationZ->GetId(), wxEVT_SCROLL_CHANGED , (wxObjectEventFunction)(void (wxPanel::*)(wxScrollEvent&)) &TransformWidgetPanel::OnSliderTrackZ );
96 wxBoxSizer *sizer = new wxBoxSizer(wxHORIZONTAL);
97 sizer->Add( mSliderRotationX , 1 );
98 sizer->Add( mSliderRotationY , 1 );
99 sizer->Add( mSliderRotationZ , 1 );
100 sizer->Add( mBtnSetPoint , 1 );
104 if (mBox->bbGetInputType()==1)
107 sizeSliderWidget.Set(250,-1 );
108 sizeButton.Set( 65 , -1 );
109 wxRadioButton *rBtnX = new wxRadioButton( this, -1, _T("X") ,wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
110 wxRadioButton *rBtnY = new wxRadioButton( this, -1, _T("Y") ,wxDefaultPosition, wxDefaultSize, 0);
111 wxRadioButton *rBtnZ = new wxRadioButton( this, -1, _T("Z") ,wxDefaultPosition, wxDefaultSize, 0);
112 wxRadioButton *rBtnN = new wxRadioButton( this, -1, _T("N") ,wxDefaultPosition, wxDefaultSize, 0);
113 mSliderGeneral = new wxSlider( this, -1, 0 , -180, 180 , wxDefaultPosition,sizeSliderWidget, wxSL_HORIZONTAL, wxDefaultValidator );
114 wxButton *mBtnMoveDown = new wxButton( this, -1, _T("-") , wxDefaultPosition, sizeButton );
115 wxButton *mBtnMoveUp = new wxButton( this, -1, _T("+") , wxDefaultPosition, sizeButton );
116 wxButton *mBtnSetPoint = new wxButton( this, -1, _T("Set") , wxDefaultPosition, sizeButton );
117 wxButton *mBtnReset = new wxButton( this, -1, _T("Reset") , wxDefaultPosition, sizeButton );
118 Connect( rBtnX->GetId() , wxEVT_COMMAND_RADIOBUTTON_SELECTED, (wxObjectEventFunction) (void (wxPanel::*)(wxEvent&)) &TransformWidgetPanel::OnRadioButtonX );
119 Connect( rBtnY->GetId() , wxEVT_COMMAND_RADIOBUTTON_SELECTED, (wxObjectEventFunction) (void (wxPanel::*)(wxEvent&)) &TransformWidgetPanel::OnRadioButtonY );
120 Connect( rBtnZ->GetId() , wxEVT_COMMAND_RADIOBUTTON_SELECTED, (wxObjectEventFunction) (void (wxPanel::*)(wxEvent&)) &TransformWidgetPanel::OnRadioButtonZ );
121 Connect( rBtnN->GetId() , wxEVT_COMMAND_RADIOBUTTON_SELECTED, (wxObjectEventFunction) (void (wxPanel::*)(wxEvent&)) &TransformWidgetPanel::OnRadioButtonN );
122 Connect(mBtnSetPoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction)(void (wxPanel::*)(wxScrollEvent&)) &TransformWidgetPanel::OnSetPoint );
123 Connect(mBtnReset->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction)(void (wxPanel::*)(wxScrollEvent&)) &TransformWidgetPanel::OnReset );
124 Connect(mBtnMoveDown->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction)(void (wxPanel::*)(wxScrollEvent&)) &TransformWidgetPanel::OnMoveDown );
125 Connect(mBtnMoveUp->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction)(void (wxPanel::*)(wxScrollEvent&)) &TransformWidgetPanel::OnMoveUp );
126 Connect( mSliderGeneral->GetId(), wxEVT_SCROLL_THUMBRELEASE , (wxObjectEventFunction)(void (wxPanel::*)(wxScrollEvent&)) &TransformWidgetPanel::OnSliderGeneralRelease );
127 Connect( mSliderGeneral->GetId(), wxEVT_SCROLL_THUMBTRACK , (wxObjectEventFunction)(void (wxPanel::*)(wxScrollEvent&)) &TransformWidgetPanel::OnSliderGeneralTrack );
128 Connect( mSliderGeneral->GetId(), wxEVT_SCROLL_CHANGED , (wxObjectEventFunction)(void (wxPanel::*)(wxScrollEvent&)) &TransformWidgetPanel::OnSliderGeneralTrack );
129 rBtnX->SetValue(true);
131 wxBoxSizer *sizerD = new wxBoxSizer(wxHORIZONTAL);
132 sizerD->Add( mBtnSetPoint , 1 );
133 sizerD->Add( mBtnReset , 1 );
134 wxBoxSizer *sizerA = new wxBoxSizer(wxHORIZONTAL);
135 sizerA->Add( rBtnX , 1 );
136 sizerA->Add( rBtnY , 1 );
137 sizerA->Add( rBtnZ , 1 );
138 sizerA->Add( rBtnN , 1 );
139 wxBoxSizer *sizerB = new wxBoxSizer(wxHORIZONTAL);
140 sizerB->Add( mSliderGeneral , 0 );
141 wxBoxSizer *sizerC = new wxBoxSizer(wxHORIZONTAL);
142 sizerC->Add( mBtnMoveDown , 1 );
143 sizerC->Add( mBtnMoveUp , 1 );
144 wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
145 sizer->Add( sizerD , 0 );
146 sizer->Add( sizerA , 0 );
147 sizer->Add( sizerB , 0 );
148 sizer->Add( sizerC , 0 );
155 TransformWidgetPanel::~TransformWidgetPanel()
159 void TransformWidgetPanel::Release( wxSlider * slider )
167 t->Concatenate ( tt->GetMatrix() ); t->Update();
168 tt->GetMatrix()->Identity(); tt->Update();
169 mBox->bbSetOutputOut( t );
170 mBox->bbSignalOutputModification(std::string("Out"));
173 void TransformWidgetPanel::OnSliderReleaseX(wxScrollEvent& event)
175 Release( mSliderRotationX );
178 void TransformWidgetPanel::OnSliderReleaseY(wxScrollEvent& event)
180 Release( mSliderRotationY );
183 void TransformWidgetPanel::OnSliderReleaseZ(wxScrollEvent& event)
185 Release( mSliderRotationZ );
188 void TransformWidgetPanel::Track( double angle, int idVector)
195 vtkMatrix4x4 *tm = t->GetMatrix();
196 double tvx = tm->GetElement(0,idVector);
197 double tvy = tm->GetElement(1,idVector);
198 double tvz = tm->GetElement(2,idVector);
199 tt = vtkTransform::New();
203 tt->RotateWXYZ( angle , tvx,tvy,tvz); tt->Update();
204 vtkTransform *result=vtkTransform::New();
205 result->PostMultiply();
206 result->Concatenate ( t->GetMatrix() ); result->Update();
207 result->Concatenate ( tt->GetMatrix() ); result->Update();
208 mBox->bbSetOutputOut( result );
209 mBox->bbSignalOutputModification(std::string("Out"));
212 void TransformWidgetPanel::OnSliderTrackX(wxScrollEvent& event)
214 Track(mSliderRotationX->GetValue() ,0);
217 void TransformWidgetPanel::OnSliderTrackY(wxScrollEvent& event)
219 Track(mSliderRotationY->GetValue() ,1);
222 void TransformWidgetPanel::OnSliderTrackZ(wxScrollEvent& event)
224 Track(mSliderRotationZ->GetValue() ,2);
227 void TransformWidgetPanel::SetPossiblePoint(std::vector<double> possiblePoint)
229 mPossiblePoint = possiblePoint;
232 void TransformWidgetPanel::_OnSetPoint()
234 mActualPoint = mPossiblePoint;
235 mBox->bbSetOutputActualPoint( mActualPoint );
236 mBox->bbSignalOutputModification(std::string("ActualPoint"));
239 void TransformWidgetPanel::OnSetPoint(wxCommandEvent& event)
244 //------------------------------------------------------------------------
246 void TransformWidgetPanel::OnRadioButtonX(wxEvent& event)
251 void TransformWidgetPanel::OnRadioButtonY(wxEvent& event)
256 void TransformWidgetPanel::OnRadioButtonZ(wxEvent& event)
261 void TransformWidgetPanel::OnRadioButtonN(wxEvent& event)
266 void TransformWidgetPanel::OnReset(wxCommandEvent& event)
268 if ((mTool>=0) && (mTool<=2))
270 tt->GetMatrix()->Identity(); tt->Update();
271 t->GetMatrix()->Identity(); t->Update();
279 t->RotateWXYZ( 90 , 1,0,0); tt->Update();
285 t->RotateWXYZ( 90 , 0,1,0); tt->Update();
288 } // if mTool >=0 <=2
291 void TransformWidgetPanel::OnMoveDown(wxCommandEvent& event)
293 if ((mTool>=0) && (mTool<=2))
300 void TransformWidgetPanel::OnMoveUp(wxCommandEvent& event)
302 if ((mTool>=0) && (mTool<=2))
309 void TransformWidgetPanel::OnSliderGeneralRelease(wxScrollEvent& event)
311 Release( mSliderGeneral );
314 void TransformWidgetPanel::OnSliderGeneralTrack(wxScrollEvent& event)
316 if ((mTool>=0) && (mTool<=2))
318 Track( mSliderGeneral->GetValue() , mTool );
323 //------------------------------------------------------------------------
324 //------------------------------------------------------------------------
325 //------------------------------------------------------------------------
327 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,TransformWidget2)
328 BBTK_BLACK_BOX_IMPLEMENTATION(TransformWidget2,bbtk::WxBlackBox);
330 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
332 void TransformWidget2::Process()
334 TransformWidgetPanel *w = (TransformWidgetPanel*) bbGetOutputWidget( );
335 w->SetPossiblePoint( bbGetInputPossiblePoint() );
344 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
346 void TransformWidget2::CreateWidget(wxWindow* parent)
348 TransformWidgetPanel *w = new TransformWidgetPanel(this,parent);
349 bbSetOutputWidget( w );
353 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
355 void TransformWidget2::bbUserSetDefaultValues()
362 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
364 void TransformWidget2::bbUserInitializeProcessing()
369 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
371 void TransformWidget2::bbUserFinalizeProcessing()
375 }// EO namespace bbcreaMaracasVisu