//---------------------------------------------------------------------------------------------------------------- // Class definition include //---------------------------------------------------------------------------------------------------------------- #include "wxContourViewPanel.h" //---------------------------------------------------------------------------------------------------------------- // Other includes //---------------------------------------------------------------------------------------------------------------- #include "ConceptDataWrap.h" //---------------------------------------------------------------------------------------------------------------- // Class implementation //---------------------------------------------------------------------------------------------------------------- /** @file wxContourViewPanel.cxx */ //---------------------------------------------------------------------------------------------------------------- // Throwed Events definition //---------------------------------------------------------------------------------------------------------------- DEFINE_EVENT_TYPE( wxINSTANT_CHANGE ) //------------------------------------------------------------------------------------------------------------ // Constructors & Destructors //------------------------------------------------------------------------------------------------------------ wxContourViewPanel :: wxContourViewPanel ( vtkImageData * theShowingImage, wxWindow *parent, const wxPoint& pos, const wxSize& size,long style, int vertStart, int vertEnd, int horzStart, int horzEnd ) //:wxScrolledWindow(parent, -1, pos, size, style) :wxPanel(parent, -1, pos, size, style) /*{ showingVID = theShowingImage; int gapH = 20; int gapV = 10; createHorizontalBar(1,80); createVerticalBar(1,200); createViewPanel(); wxFlexGridSizer * panelSizer = new wxFlexGridSizer(3,1,0,0); panelSizer->AddSpacer(gapV); panelSizer -> AddGrowableCol(1); panelSizer->Add(theViewPanel, 1, wxEXPAND); panelSizer->AddSpacer(gapV); wxFlexGridSizer * downSizer = new wxFlexGridSizer(1,3,gapV,gapH); downSizer->Add(_verticalBar, 1, wxEXPAND); //downSizer->AddSpacer(gapH); downSizer -> AddGrowableCol(1); downSizer->Add(panelSizer, 1, wxEXPAND|wxALL|wxCENTER); //downSizer->AddSpacer(gapH); outSizer = new wxFlexGridSizer(3,1,1,1); outSizer->Add(_horizontalBar, 1, wxEXPAND); outSizer -> AddGrowableRow(1); outSizer -> AddGrowableCol(1); outSizer->Add(downSizer, 1, wxEXPAND); _horizontalBar->setDeviceBlitStart( _verticalBar->GetWidth() + gapH, gapV); _horizontalBar->setDeviceEndMargin( gapH+10 ); //Connecting the events to the horizontal bar Connect(_horizontalBar->GetId(),wxEVT_TSBAR,(wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onBarrange_Horizontal ); Connect(_horizontalBar->GetId(),wxEVT_TSBAR_ACTUAL,(wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onActualChange_Bar_Horizontal ); Connect(_horizontalBar->GetId(),wxEVT_TSBAR_START,(wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onStartChange_Bar_Horizontal ); Connect(_horizontalBar->GetId(),wxEVT_TSBAR_END,(wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onEndChange_Bar_Horizontal ); Connect(_horizontalBar->GetId(),wxEVT_SELECTION_END,(wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onSelectionEnd_Horizontal ); Connect(_horizontalBar->GetId(),wxEVT_TSBAR_MOVED,(wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onMovedBar_Horizontal ); //Connecting the events to the vertical bar Connect(_verticalBar->GetId(),wxEVT_TSBAR,(wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onBarrange_Vertical ); Connect(_verticalBar->GetId(),wxEVT_TSBAR_ACTUAL,(wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onActualChange_Bar_Vertical ); Connect(_verticalBar->GetId(),wxEVT_TSBAR_START,(wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onStartChange_Bar_Vertical ); Connect(_verticalBar->GetId(),wxEVT_TSBAR_END,(wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onEndChange_Bar_Vertical ); Connect(_verticalBar->GetId(),wxEVT_SELECTION_END,(wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onSelectionEnd_Vertical ); Connect(_verticalBar->GetId(),wxEVT_TSBAR_MOVED,(wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onMovedBar_Vertical ); this->SetAutoLayout( true ); SetSizer( outSizer ); this->Layout(); SetSize(900,700); theViewPanel->SetSize(800,600); theViewPanel->GetWindow(1)->SetSize(800,600); outSizer->Fit( this ); SetBackgroundColour(wxColour(255,0,0)); }*/ { theShowingImage->GetSpacing(last_spacing); showingVID = theShowingImage; int gapH = 20; int gapV = 10; _verticalConceptName = ""; _horizontalConceptName = ""; createHorizontalBar(1,80); createVerticalBar(1,200); createViewPanel(); wxFlexGridSizer * panelSizer = new wxFlexGridSizer(1, 4, gapV, gapH); panelSizer -> AddGrowableCol(2); panelSizer -> AddGrowableRow(2); panelSizer->Add(_verticalBar, 1, wxGROW); panelSizer->AddSpacer(gapV); panelSizer->Add(theViewPanel, 1, wxGROW); panelSizer->AddSpacer(gapV); outSizer = new wxFlexGridSizer(3, 1, gapH, gapV); outSizer -> AddGrowableCol(1); outSizer -> AddGrowableRow(1); outSizer->Add( _horizontalBar, 1, wxGROW); outSizer->Add( panelSizer, 1, wxGROW); outSizer->AddSpacer(gapH); _horizontalBar->setDeviceBlitStart( _verticalBar->GetWidth() + 2*gapH, gapV); _horizontalBar->setDeviceEndMargin( 2*gapH+10 ); //Connecting the events to the horizontal bar Connect(_horizontalBar->GetId(),wxEVT_TSBAR,(wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onBarrange_Horizontal ); Connect(_horizontalBar->GetId(),wxEVT_TSBAR_ACTUAL,(wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onActualChange_Bar_Horizontal ); Connect(_horizontalBar->GetId(),wxEVT_TSBAR_START,(wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onStartChange_Bar_Horizontal ); Connect(_horizontalBar->GetId(),wxEVT_TSBAR_END,(wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onEndChange_Bar_Horizontal ); Connect(_horizontalBar->GetId(),wxEVT_SELECTION_END,(wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onSelectionEnd_Horizontal ); Connect(_horizontalBar->GetId(),wxEVT_TSBAR_MOVED,(wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onMovedBar_Horizontal ); //Connecting the events to the vertical bar Connect(_verticalBar->GetId(),wxEVT_TSBAR,(wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onBarrange_Vertical ); Connect(_verticalBar->GetId(),wxEVT_TSBAR_ACTUAL,(wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onActualChange_Bar_Vertical ); Connect(_verticalBar->GetId(),wxEVT_TSBAR_START,(wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onStartChange_Bar_Vertical ); Connect(_verticalBar->GetId(),wxEVT_TSBAR_END,(wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onEndChange_Bar_Vertical ); Connect(_verticalBar->GetId(),wxEVT_SELECTION_END,(wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onSelectionEnd_Vertical ); Connect(_verticalBar->GetId(),wxEVT_TSBAR_MOVED,(wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onMovedBar_Vertical ); SetSizer( outSizer ); this->SetAutoLayout( true ); this->Layout(); //SetSize(1900,1900); //theViewPanel->SetSize(800,600); //theViewPanel->GetWindow(1)->SetSize(800,600); //outSizer->Fit( this ); } wxContourViewPanel :: ~wxContourViewPanel() { } //------------------------------------------------------------------------------------------------------------ // Creational and initialization methods //------------------------------------------------------------------------------------------------------------ void wxContourViewPanel :: setWxEventHandler( wxEvtHandler * theEventHandler ) { _eventHandler = theEventHandler; } void wxContourViewPanel :: createHorizontalBar(int horzStart, int horzEnd) { _horizontalBar = new mBarRange(this, 1500,80); _horizontalBar -> setVisibleLabels (true); _horizontalBar -> setRepresentedValues (horzStart, horzEnd); _horizontalBar -> setActiveStateTo(true); _horizontalBar -> SetActual( horzStart ); _horizontalBar -> setDeviceBlitStart (10,10); _horizontalBar -> setDeviceEndMargin (10); } void wxContourViewPanel :: createVerticalBar(int vertStart, int vertEnd) { _verticalBar = new mBarRange(this, 1500,40); _verticalBar -> SetOrientation(false); _verticalBar -> setVisibleLabels (false); _verticalBar -> setRepresentedValues (vertStart, vertEnd); _verticalBar -> setActiveStateTo(true); _verticalBar -> SetActual( vertStart ); _verticalBar -> setDeviceBlitStart (10,10); _verticalBar -> setDeviceEndMargin (10); } //------------------------------------------------------------------------------------------------------------ void wxContourViewPanel :: createViewPanel() { std::vector * numViews = new std::vector (); numViews->push_back(2); theViewPanel = new wxMaracas_N_ViewersWidget( this, showingVID, numViews ); SetVisibleAxis(false); theViewPanel->SetBackgroundColour(wxColour(0,0,0)); theViewPanel->SetSize(800,600); theViewPanel->GetWindow(1)->SetSize(800,600); } //------------------------------------------------------------------------------------------------------------ wxVtkMPR2DView * wxContourViewPanel::GetwxVtkMPR2DView() { return (wxVtkMPR2DView *) (theViewPanel->GetwxVtkBaseView(1)); } //------------------------------------------------------------------------------------------------------------ void wxContourViewPanel::SetVisibleAxis(bool ok) { GetwxVtkMPR2DView()->SetVisibleAxis(ok); } //------------------------------------------------------------------------------------------------------------ int wxContourViewPanel::GetX() { return GetwxVtkMPR2DView()->GetVtkmprbasedata()->GetX(); } //------------------------------------------------------------------------------------------------------------ int wxContourViewPanel::GetY() { return GetwxVtkMPR2DView()->GetVtkmprbasedata()->GetY(); } //------------------------------------------------------------------------------------------------------------ int wxContourViewPanel::GetZ() { return GetwxVtkMPR2DView()->GetVtkmprbasedata()->GetZ(); } //------------------------------------------------------------------------------------------------------------ void wxContourViewPanel::Refresh() { GetwxVtkMPR2DView()->GetRenWin()->Render(); } //------------------------------------------------------------------------------------------------------------ // Methods for capturing events from the horizontal bar //------------------------------------------------------------------------------------------------------------ /** * Handles the event wxEVT_TSBAR from the horizontal bar */ void wxContourViewPanel :: onBarrange_Horizontal(wxCommandEvent& event) { } /** * Handles the event wxEVT_TSBAR_ACTUAL from the horizontal bar */ void wxContourViewPanel :: onActualChange_Bar_Horizontal(wxCommandEvent& event) { int nxActual_h = getActualHorizontal(); if (_eventHandler!=NULL) { //------------------------------------------------- // Sending the event of wxINSTANT_CHANGE //------------------------------------------------- wxCommandEvent newevent(wxINSTANT_CHANGE,GetId()); ConceptDataWrap * cWrap = new ConceptDataWrap( _horizontalConceptName ); cWrap->setActualValue( nxActual_h ); newevent.SetClientData( (void *)cWrap ); _eventHandler->ProcessEvent(newevent); } } /** * Handles the event wxEVT_TSBAR_START from the horizontal bar */ void wxContourViewPanel :: onStartChange_Bar_Horizontal(wxCommandEvent& event) { int nxStart_h = getStartHorizontal(); } /** * Handles the event wxEVT_TSBAR_END from the horizontal bar */ void wxContourViewPanel :: onEndChange_Bar_Horizontal(wxCommandEvent& event) { int nxEnd_h = getEndHorizontal(); } /** * Handles the event wxEVT_SELECTION_END from the horizontal bar */ void wxContourViewPanel :: onSelectionEnd_Horizontal(wxCommandEvent& event) { } /** * Handles the event wxEVT_TSBAR_MOVED from the horizontal bar */ void wxContourViewPanel :: onMovedBar_Horizontal(wxCommandEvent& event) { int nxStart_h = getStartHorizontal(); int nxEnd_h = getEndHorizontal(); } //------------------------------------------------------------------------------------------------------------ // Methods for capturing events from the vertical bar //------------------------------------------------------------------------------------------------------------ /** * Handles the event wxEVT_TSBAR from the vertical bar */ void wxContourViewPanel :: onBarrange_Vertical(wxCommandEvent& event) { } /** * Handles the event wxEVT_TSBAR_ACTUAL from the vertical bar */ void wxContourViewPanel :: onActualChange_Bar_Vertical(wxCommandEvent& event) { int nxActual_v = getActualVertical(); if (_eventHandler!=NULL) { //------------------------------------------------- // Sending the event of wxINSTANT_CHANGE //------------------------------------------------- wxCommandEvent newevent(wxINSTANT_CHANGE,GetId()); ConceptDataWrap * cWrap = new ConceptDataWrap( _verticalConceptName ); cWrap->setActualValue( nxActual_v ); newevent.SetClientData( (void *)cWrap ); _eventHandler->ProcessEvent(newevent); } } /** * Handles the event wxEVT_TSBAR_START from the vertical bar */ void wxContourViewPanel :: onStartChange_Bar_Vertical(wxCommandEvent& event) { int nxStart_v = getStartVertical(); } /** * Handles the event wxEVT_TSBAR_END from the vertical bar */ void wxContourViewPanel :: onEndChange_Bar_Vertical(wxCommandEvent& event) { int nxEnd_v = getEndVertical(); } /** * Handles the event wxEVT_SELECTION_END from the vertical bar */ void wxContourViewPanel :: onSelectionEnd_Vertical(wxCommandEvent& event) { } /** * Handles the event wxEVT_TSBAR_MOVED from the vertical bar */ void wxContourViewPanel :: onMovedBar_Vertical(wxCommandEvent& event) { int nxStart_v = getStartVertical(); int nxEnd_v = getEndVertical(); } //------------------------------------------------------------------------------------------------------------ // Methods for sending events //------------------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------------------ // Attributes getters and setters //------------------------------------------------------------------------------------------------------------ /** * Sets the represented values of the vertical bar * @param minRepresented In the minimum represented value of the bar * @param maxRepresented In the maximum represented value of the bar */ void wxContourViewPanel :: setVerticalRepresentedValues( int minRepresented, int maxRepresented ) { if( _verticalBar != NULL && _useVerticalBar ) { _verticalBar -> setRepresentedValues( minRepresented, maxRepresented ); } } /** * Sets the represented values of the horizontal bar * @param minRepresented In the minimum represented value of the bar * @param maxRepresented In the maximum represented value of the bar */ void wxContourViewPanel :: setHorizontalRepresentedValues( int minRepresented, int maxRepresented ) { if( _horizontalBar != NULL && _useHorizontalBar ) { _horizontalBar -> setRepresentedValues( minRepresented, maxRepresented ); } } /** * Gets the StartVertical value * @return The StartVertical */ int wxContourViewPanel :: getStartVertical() { return _verticalBar->GetActual(); } /** * Gets the EndVertical value * @return The EndVertical */ int wxContourViewPanel :: getEndVertical() { return _verticalBar->GetEnd(); } /** * Gets the ActualVertical value * @return The ActualVertical */ int wxContourViewPanel :: getActualVertical() { return _verticalBar->GetEnd(); } /** * Sets the StartVertical value * @param nwValue The new value for the StartVertical */ void wxContourViewPanel :: setStartVertical( int nwValue ) { _verticalBar->SetEnd( nwValue ); } /** * Sets the EndVertical value * @param nwValue The new value for the EndVertical */ void wxContourViewPanel :: setEndVertical( int nwValue ) { _verticalBar->SetEnd( nwValue ); } /** * Sets the ActualVertical value * @param nwValue The new value for the ActualVertical */ void wxContourViewPanel :: setActualVertical( int nwValue ) { _verticalBar->SetActual( nwValue ); } /** * Gets the StartHorizontal value * @return The StartHorizontal */ int wxContourViewPanel :: getStartHorizontal() { return _horizontalBar->GetStart(); } /** * Gets the EndHorizontal value * @return The EndHorizontal */ int wxContourViewPanel :: getEndHorizontal() { return _horizontalBar->GetEnd(); } /** * Gets the ActualHorizontal value * @return The ActualHorizontal */ int wxContourViewPanel :: getActualHorizontal() { return _horizontalBar->GetActual(); } /** * Sets the StartHorizontal value * @param nwValue The new value for the StartHorizontal */ void wxContourViewPanel :: setStartHorizontal( int nwValue ) { _horizontalBar->SetStart( nwValue ); } /** * Sets the EndHorizontal value * @param nwValue The new value for the EndHorizontal */ void wxContourViewPanel :: setEndHorizontal( int nwValue ) { _horizontalBar->SetEnd( nwValue ); } /** * Sets the ActualHorizontal value * @param nwValue The new value for the ActualHorizontal */ void wxContourViewPanel :: setActualHorizontal( int nwValue ) { _horizontalBar->SetActual( nwValue ); } /** * Sets the horizontal concept values and name * @param theHorizontalConcept The name of the concept for setting at the horizontal bar * @param minRepresent The minRepresent value of the concept for setting at the horizontal bar * @param maxRepresent The maxRepresent value of the concept for setting at the horizontal bar * @param minShowed The minShowed value of the concept for setting at the horizontal bar * @param maxShowed The maxShowed value of the concept for setting at the horizontal bar * @param actualShow The actualShow value of the concept for setting at the horizontal bar */ void wxContourViewPanel :: setHorizontalConcept( std::string theHorizontalConcept, int minRepresent, int maxRepresent, int minShowed, int maxShowed, int actualShow ) { setHorizontalConceptName( theHorizontalConcept ); setHorizontalRepresentedValues( minRepresent, maxRepresent ); setActualHorizontal( actualShow ); setStartHorizontal( minShowed ); setEndHorizontal( maxShowed ); } /** * Sets the vertical concept values and name * @param theVerticalConcept The name of the concept for setting at the vertical bar * @param minRepresent The minRepresent value of the concept for setting at the vertical bar * @param maxRepresent The maxRepresent value of the concept for setting at the vertical bar * @param minShowed The minShowed value of the concept for setting at the vertical bar * @param maxShowed The maxShowed value of the concept for setting at the vertical bar * @param actualShow The actualShow value of the concept for setting at the vertical bar */ void wxContourViewPanel :: setVerticalConcept( std::string theVerticalConcept, int minRepresent, int maxRepresent, int minShowed, int maxShowed, int actualShow ) { setVerticalConceptName( theVerticalConcept ); setVerticalRepresentedValues( minRepresent, maxRepresent ); setActualVertical( actualShow ); setStartVertical( minShowed ); setEndVertical( maxShowed ); } /** * Sets the horizontal concept name * @param theHorizontalConcept The name of the concept for setting at the horizontal bar */ void wxContourViewPanel :: setHorizontalConceptName( std::string theHorizontalConcept ) { _horizontalConceptName = theHorizontalConcept; } /** * Gets the horizontal concept name * @return _horizontalConceptName The name of the concept for setting at the horizontal bar */ std::string wxContourViewPanel :: getHorizontalConceptName( ) { return _horizontalConceptName; } /** * Sets the vertical concept name * @param theVerticalConcept The name of the concept for setting at the vertical bar */ void wxContourViewPanel :: setVerticalConceptName( std::string theVerticalConcept ) { _verticalConceptName = theVerticalConcept; } /** * Gets the vertical concept name * @return _verticalConceptName The name of the concept for setting at the vertical bar */ std::string wxContourViewPanel :: getVerticalConceptName( ) { return _verticalConceptName; } //------------------------------------------------------------------------------------------------------------ // Other functional methods //------------------------------------------------------------------------------------------------------------ void wxContourViewPanel :: getSpacing( double * spacing ) { spacing[0] = last_spacing[0]; spacing[1] = last_spacing[1]; spacing[2] = last_spacing[2]; } wxVtkBaseView* wxContourViewPanel :: getWxVtkBaseView() { return theViewPanel->GetwxVtkBaseView(1); } double wxContourViewPanel :: getCurrentDeep() { //EED 08/04/2008 // return theViewPanel->GetZ(1); return theViewPanel->GetZ(); }