{
public:
TransformWidgetPanel(TransformWidget2* box, wxWindow *parent);
- ~TransformWidgetPanel();
- void OnSliderTrackX(wxScrollEvent& event);
- void OnSliderTrackY(wxScrollEvent& event);
- void OnSliderTrackZ(wxScrollEvent& event);
- void OnSliderReleaseX(wxScrollEvent& event);
- void OnSliderReleaseY(wxScrollEvent& event);
- void OnSliderReleaseZ(wxScrollEvent& event);
- void Release( wxSlider * slider );
- void Track( wxSlider * slider ,int idVector);
-
+ ~TransformWidgetPanel ();
+ void OnSetPoint (wxCommandEvent& event);
+ void Release (wxSlider *slider);
+ void Track (double angle ,int idVector);
+ void SetPossiblePoint (std::vector<double> possiblePoint);
+ void _OnSetPoint();
+
+ // Type : Module A
+ void OnSliderTrackX (wxScrollEvent& event);
+ void OnSliderTrackY (wxScrollEvent& event);
+ void OnSliderTrackZ (wxScrollEvent& event);
+ void OnSliderReleaseX (wxScrollEvent& event);
+ void OnSliderReleaseY (wxScrollEvent& event);
+ void OnSliderReleaseZ (wxScrollEvent& event);
+
+ // Type : Module B
+ void OnRadioButtonX(wxEvent& event);
+ void OnRadioButtonY(wxEvent& event);
+ void OnRadioButtonZ(wxEvent& event);
+ void OnRadioButtonN(wxEvent& event);
+ void OnReset(wxCommandEvent& event);
+ void OnMoveDown(wxCommandEvent& event);
+ void OnMoveUp(wxCommandEvent& event);
+ void OnSliderGeneralTrack(wxScrollEvent& event);
+ void OnSliderGeneralRelease(wxScrollEvent& event);
+
private:
- TransformWidget2 *mBox;
- wxSlider *mSliderRotationX;
- wxSlider *mSliderRotationY;
- wxSlider *mSliderRotationZ;
- vtkTransform *t;
- vtkTransform *tt;
+ vtkTransform *t;
+ vtkTransform *tt;
+ std::vector<double> mPossiblePoint;
+ std::vector<double> mActualPoint;
+ TransformWidget2 *mBox;
+
+ // Type : Module A
+ wxSlider *mSliderRotationX;
+ wxSlider *mSliderRotationY;
+ wxSlider *mSliderRotationZ;
+ // Type : Module B
+ char mTool;
+ wxSlider *mSliderGeneral;
};
+
//------------------------------------------------------------------------
//------------------------------------------------------------------------
//------------------------------------------------------------------------
: wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL),
mBox(box)
{
- t = vtkTransform::New();
- tt = NULL;
- wxSize sizeSliderWidget(25,25);
- mSliderRotationX = new wxSlider( this, -1, 0 , -180, 180 , wxDefaultPosition,sizeSliderWidget, wxSL_HORIZONTAL, wxDefaultValidator);
- mSliderRotationY = new wxSlider( this, -1, 0 , -180, 180 , wxDefaultPosition,sizeSliderWidget, wxSL_HORIZONTAL, wxDefaultValidator);
- mSliderRotationZ = new wxSlider( this, -1, 0 , -180, 180 , wxDefaultPosition,sizeSliderWidget, wxSL_HORIZONTAL, wxDefaultValidator);
-// mSliderRotationX = new wxSlider( this, -1, 0 , -180, 180 , wxDefaultPosition,sizeSliderWidget, wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
-// mSliderRotationY = new wxSlider( this, -1, 0 , -180, 180 , wxDefaultPosition,sizeSliderWidget, wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
-// mSliderRotationZ = new wxSlider( this, -1, 0 , -180, 180 , wxDefaultPosition,sizeSliderWidget, wxSL_HORIZONTAL|wxSL_LABELS, wxDefaultValidator);
-
- Connect( mSliderRotationX->GetId(),wxEVT_SCROLL_THUMBRELEASE,(wxObjectEventFunction)(void (wxPanel::*)(wxScrollEvent&)) &TransformWidgetPanel::OnSliderReleaseX );
- Connect( mSliderRotationX->GetId(),wxEVT_SCROLL_THUMBTRACK ,(wxObjectEventFunction)(void (wxPanel::*)(wxScrollEvent&)) &TransformWidgetPanel::OnSliderTrackX );
- Connect( mSliderRotationX->GetId(),wxEVT_SCROLL_CHANGED ,(wxObjectEventFunction)(void (wxPanel::*)(wxScrollEvent&)) &TransformWidgetPanel::OnSliderTrackX );
- Connect( mSliderRotationY->GetId(),wxEVT_SCROLL_THUMBRELEASE,(wxObjectEventFunction)(void (wxPanel::*)(wxScrollEvent&)) &TransformWidgetPanel::OnSliderReleaseY );
- Connect( mSliderRotationY->GetId(),wxEVT_SCROLL_THUMBTRACK ,(wxObjectEventFunction)(void (wxPanel::*)(wxScrollEvent&)) &TransformWidgetPanel::OnSliderTrackY );
- Connect( mSliderRotationY->GetId(),wxEVT_SCROLL_CHANGED ,(wxObjectEventFunction)(void (wxPanel::*)(wxScrollEvent&)) &TransformWidgetPanel::OnSliderTrackY );
- Connect( mSliderRotationZ->GetId(),wxEVT_SCROLL_THUMBRELEASE,(wxObjectEventFunction)(void (wxPanel::*)(wxScrollEvent&)) &TransformWidgetPanel::OnSliderReleaseZ );
- Connect( mSliderRotationZ->GetId(),wxEVT_SCROLL_THUMBTRACK ,(wxObjectEventFunction)(void (wxPanel::*)(wxScrollEvent&)) &TransformWidgetPanel::OnSliderTrackZ );
- Connect( mSliderRotationZ->GetId(),wxEVT_SCROLL_CHANGED ,(wxObjectEventFunction)(void (wxPanel::*)(wxScrollEvent&)) &TransformWidgetPanel::OnSliderTrackZ );
- wxBoxSizer *sizer = new wxBoxSizer(wxHORIZONTAL);
- sizer->Add( mSliderRotationX,1 );
- sizer->Add( mSliderRotationY,1 );
- sizer->Add( mSliderRotationZ,1 );
- SetSizer(sizer);
+ t = vtkTransform::New();
+ tt = vtkTransform::New();
+ mActualPoint.push_back(0);
+ mActualPoint.push_back(0);
+ mActualPoint.push_back(0);
+
+ mPossiblePoint.push_back(0);
+ mPossiblePoint.push_back(0);
+ mPossiblePoint.push_back(0);
+
+ wxSize sizeSliderWidget;
+ wxSize sizeButton;
+
+ if (mBox->bbGetInputType()==0)
+ {
+ sizeSliderWidget.Set(25,25);
+ sizeButton.Set( 45 , -1 );
+ mSliderRotationX = new wxSlider( this, -1, 0 , -180, 180 , wxDefaultPosition,sizeSliderWidget, wxSL_HORIZONTAL, wxDefaultValidator );
+ mSliderRotationY = new wxSlider( this, -1, 0 , -180, 180 , wxDefaultPosition,sizeSliderWidget, wxSL_HORIZONTAL, wxDefaultValidator );
+ mSliderRotationZ = new wxSlider( this, -1, 0 , -180, 180 , wxDefaultPosition,sizeSliderWidget, wxSL_HORIZONTAL, wxDefaultValidator );
+ wxButton *mBtnSetPoint = new wxButton( this, -1, _T("Set Point") , wxDefaultPosition, sizeButton );
+ Connect(mBtnSetPoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction)(void (wxPanel::*)(wxScrollEvent&)) &TransformWidgetPanel::OnSetPoint );
+ Connect( mSliderRotationX->GetId(), wxEVT_SCROLL_THUMBRELEASE , (wxObjectEventFunction)(void (wxPanel::*)(wxScrollEvent&)) &TransformWidgetPanel::OnSliderReleaseX );
+ Connect( mSliderRotationX->GetId(), wxEVT_SCROLL_THUMBTRACK , (wxObjectEventFunction)(void (wxPanel::*)(wxScrollEvent&)) &TransformWidgetPanel::OnSliderTrackX );
+ Connect( mSliderRotationX->GetId(), wxEVT_SCROLL_CHANGED , (wxObjectEventFunction)(void (wxPanel::*)(wxScrollEvent&)) &TransformWidgetPanel::OnSliderTrackX );
+ Connect( mSliderRotationY->GetId(), wxEVT_SCROLL_THUMBRELEASE , (wxObjectEventFunction)(void (wxPanel::*)(wxScrollEvent&)) &TransformWidgetPanel::OnSliderReleaseY );
+ Connect( mSliderRotationY->GetId(), wxEVT_SCROLL_THUMBTRACK , (wxObjectEventFunction)(void (wxPanel::*)(wxScrollEvent&)) &TransformWidgetPanel::OnSliderTrackY );
+ Connect( mSliderRotationY->GetId(), wxEVT_SCROLL_CHANGED , (wxObjectEventFunction)(void (wxPanel::*)(wxScrollEvent&)) &TransformWidgetPanel::OnSliderTrackY );
+ Connect( mSliderRotationZ->GetId(), wxEVT_SCROLL_THUMBRELEASE , (wxObjectEventFunction)(void (wxPanel::*)(wxScrollEvent&)) &TransformWidgetPanel::OnSliderReleaseZ );
+ Connect( mSliderRotationZ->GetId(), wxEVT_SCROLL_THUMBTRACK , (wxObjectEventFunction)(void (wxPanel::*)(wxScrollEvent&)) &TransformWidgetPanel::OnSliderTrackZ );
+ Connect( mSliderRotationZ->GetId(), wxEVT_SCROLL_CHANGED , (wxObjectEventFunction)(void (wxPanel::*)(wxScrollEvent&)) &TransformWidgetPanel::OnSliderTrackZ );
+ wxBoxSizer *sizer = new wxBoxSizer(wxHORIZONTAL);
+ sizer->Add( mSliderRotationX , 1 );
+ sizer->Add( mSliderRotationY , 1 );
+ sizer->Add( mSliderRotationZ , 1 );
+ sizer->Add( mBtnSetPoint , 1 );
+ SetSizer(sizer);
+ } // if Type == 0
+
+ if (mBox->bbGetInputType()==1)
+ {
+ mTool=0;
+ sizeSliderWidget.Set(250,-1 );
+ sizeButton.Set( 65 , -1 );
+ wxRadioButton *rBtnX = new wxRadioButton( this, -1, _T("X") ,wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
+ wxRadioButton *rBtnY = new wxRadioButton( this, -1, _T("Y") ,wxDefaultPosition, wxDefaultSize, 0);
+ wxRadioButton *rBtnZ = new wxRadioButton( this, -1, _T("Z") ,wxDefaultPosition, wxDefaultSize, 0);
+ wxRadioButton *rBtnN = new wxRadioButton( this, -1, _T("N") ,wxDefaultPosition, wxDefaultSize, 0);
+ mSliderGeneral = new wxSlider( this, -1, 0 , -180, 180 , wxDefaultPosition,sizeSliderWidget, wxSL_HORIZONTAL, wxDefaultValidator );
+ wxButton *mBtnMoveDown = new wxButton( this, -1, _T("-") , wxDefaultPosition, sizeButton );
+ wxButton *mBtnMoveUp = new wxButton( this, -1, _T("+") , wxDefaultPosition, sizeButton );
+ wxButton *mBtnSetPoint = new wxButton( this, -1, _T("Set") , wxDefaultPosition, sizeButton );
+ wxButton *mBtnReset = new wxButton( this, -1, _T("Reset") , wxDefaultPosition, sizeButton );
+ Connect( rBtnX->GetId() , wxEVT_COMMAND_RADIOBUTTON_SELECTED, (wxObjectEventFunction) (void (wxPanel::*)(wxEvent&)) &TransformWidgetPanel::OnRadioButtonX );
+ Connect( rBtnY->GetId() , wxEVT_COMMAND_RADIOBUTTON_SELECTED, (wxObjectEventFunction) (void (wxPanel::*)(wxEvent&)) &TransformWidgetPanel::OnRadioButtonY );
+ Connect( rBtnZ->GetId() , wxEVT_COMMAND_RADIOBUTTON_SELECTED, (wxObjectEventFunction) (void (wxPanel::*)(wxEvent&)) &TransformWidgetPanel::OnRadioButtonZ );
+ Connect( rBtnN->GetId() , wxEVT_COMMAND_RADIOBUTTON_SELECTED, (wxObjectEventFunction) (void (wxPanel::*)(wxEvent&)) &TransformWidgetPanel::OnRadioButtonN );
+ Connect(mBtnSetPoint->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction)(void (wxPanel::*)(wxScrollEvent&)) &TransformWidgetPanel::OnSetPoint );
+ Connect(mBtnReset->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction)(void (wxPanel::*)(wxScrollEvent&)) &TransformWidgetPanel::OnReset );
+ Connect(mBtnMoveDown->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction)(void (wxPanel::*)(wxScrollEvent&)) &TransformWidgetPanel::OnMoveDown );
+ Connect(mBtnMoveUp->GetId() , wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction)(void (wxPanel::*)(wxScrollEvent&)) &TransformWidgetPanel::OnMoveUp );
+ Connect( mSliderGeneral->GetId(), wxEVT_SCROLL_THUMBRELEASE , (wxObjectEventFunction)(void (wxPanel::*)(wxScrollEvent&)) &TransformWidgetPanel::OnSliderGeneralRelease );
+ Connect( mSliderGeneral->GetId(), wxEVT_SCROLL_THUMBTRACK , (wxObjectEventFunction)(void (wxPanel::*)(wxScrollEvent&)) &TransformWidgetPanel::OnSliderGeneralTrack );
+ Connect( mSliderGeneral->GetId(), wxEVT_SCROLL_CHANGED , (wxObjectEventFunction)(void (wxPanel::*)(wxScrollEvent&)) &TransformWidgetPanel::OnSliderGeneralTrack );
+ rBtnX->SetValue(true);
+
+ wxBoxSizer *sizerD = new wxBoxSizer(wxHORIZONTAL);
+ sizerD->Add( mBtnSetPoint , 1 );
+ sizerD->Add( mBtnReset , 1 );
+ wxBoxSizer *sizerA = new wxBoxSizer(wxHORIZONTAL);
+ sizerA->Add( rBtnX , 1 );
+ sizerA->Add( rBtnY , 1 );
+ sizerA->Add( rBtnZ , 1 );
+ sizerA->Add( rBtnN , 1 );
+ wxBoxSizer *sizerB = new wxBoxSizer(wxHORIZONTAL);
+ sizerB->Add( mSliderGeneral , 0 );
+ wxBoxSizer *sizerC = new wxBoxSizer(wxHORIZONTAL);
+ sizerC->Add( mBtnMoveDown , 1 );
+ sizerC->Add( mBtnMoveUp , 1 );
+ wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
+ sizer->Add( sizerD , 0 );
+ sizer->Add( sizerA , 0 );
+ sizer->Add( sizerB , 0 );
+ sizer->Add( sizerC , 0 );
+
+ SetSizer(sizer);
+ } // if
+
}
TransformWidgetPanel::~TransformWidgetPanel()
void TransformWidgetPanel::Release( wxSlider * slider )
{
- slider->SetValue(0);
+ if (slider!=NULL)
+ {
+ slider->SetValue(0);
+ }
// t = t*tt
t->PostMultiply();
t->Concatenate ( tt->GetMatrix() ); t->Update();
Release( mSliderRotationZ );
}
-void TransformWidgetPanel::Track( wxSlider *slider, int idVector)
+void TransformWidgetPanel::Track( double angle, int idVector)
{
// out = t*tt
if (tt!=NULL)
tt = vtkTransform::New();
tt->PostMultiply();
- double angle = slider->GetValue()/2;
+ angle = angle/2;
tt->RotateWXYZ( angle , tvx,tvy,tvz); tt->Update();
vtkTransform *result=vtkTransform::New();
result->PostMultiply();
void TransformWidgetPanel::OnSliderTrackX(wxScrollEvent& event)
{
- Track(mSliderRotationX ,0);
+ Track(mSliderRotationX->GetValue() ,0);
}
void TransformWidgetPanel::OnSliderTrackY(wxScrollEvent& event)
{
- Track(mSliderRotationY ,1);
+ Track(mSliderRotationY->GetValue() ,1);
}
void TransformWidgetPanel::OnSliderTrackZ(wxScrollEvent& event)
{
- Track(mSliderRotationZ ,2);
+ Track(mSliderRotationZ->GetValue() ,2);
+}
+
+void TransformWidgetPanel::SetPossiblePoint(std::vector<double> possiblePoint)
+{
+ mPossiblePoint = possiblePoint;
+}
+
+void TransformWidgetPanel::_OnSetPoint()
+{
+ mActualPoint = mPossiblePoint;
+ mBox->bbSetOutputActualPoint( mActualPoint );
+ mBox->bbSignalOutputModification(std::string("ActualPoint"));
+}
+
+void TransformWidgetPanel::OnSetPoint(wxCommandEvent& event)
+{
+ _OnSetPoint();
+}
+
+//------------------------------------------------------------------------
+
+void TransformWidgetPanel::OnRadioButtonX(wxEvent& event)
+{
+ mTool = 0;
+}
+
+void TransformWidgetPanel::OnRadioButtonY(wxEvent& event)
+{
+ mTool = 1;
+}
+
+void TransformWidgetPanel::OnRadioButtonZ(wxEvent& event)
+{
+ mTool = 2;
+}
+
+void TransformWidgetPanel::OnRadioButtonN(wxEvent& event)
+{
+ mTool = 3;
+}
+
+void TransformWidgetPanel::OnReset(wxCommandEvent& event)
+{
+ if ((mTool>=0) && (mTool<=2))
+ {
+ tt->GetMatrix()->Identity(); tt->Update();
+ t->GetMatrix()->Identity(); t->Update();
+ if (mTool==0)
+ {
+ Release( NULL );
+ } // if
+
+ if (mTool==1)
+ {
+ t->RotateWXYZ( 90 , 1,0,0); tt->Update();
+ Release( NULL );
+ } // if
+
+ if (mTool==2)
+ {
+ t->RotateWXYZ( 90 , 0,1,0); tt->Update();
+ Release( NULL );
+ } // if
+ } // if mTool >=0 <=2
+}
+
+void TransformWidgetPanel::OnMoveDown(wxCommandEvent& event)
+{
+ if ((mTool>=0) && (mTool<=2))
+ {
+ Track( -2 , mTool );
+ Release( NULL );
+ }
+}
+
+void TransformWidgetPanel::OnMoveUp(wxCommandEvent& event)
+{
+ if ((mTool>=0) && (mTool<=2))
+ {
+ Track( 2 , mTool );
+ Release( NULL );
+ }
+}
+
+void TransformWidgetPanel::OnSliderGeneralRelease(wxScrollEvent& event)
+{
+ Release( mSliderGeneral );
+}
+
+void TransformWidgetPanel::OnSliderGeneralTrack(wxScrollEvent& event)
+{
+ if ((mTool>=0) && (mTool<=2))
+ {
+ Track( mSliderGeneral->GetValue() , mTool );
+ }
}
//=====
void TransformWidget2::Process()
{
-
+ TransformWidgetPanel *w = (TransformWidgetPanel*) bbGetOutputWidget( );
+ w->SetPossiblePoint( bbGetInputPossiblePoint() );
+ if (firsttime==true)
+ {
+ firsttime=false;
+ w->_OnSetPoint();
+ }// if
}
//=====
//=====
void TransformWidget2::bbUserSetDefaultValues()
{
+ firsttime=true;
bbSetInputType(0);
}