2 //----------------------------------------------------------------------------------------------------------------
3 // Class definition include
4 //----------------------------------------------------------------------------------------------------------------
5 #include "wxContourViewPanel.h"
8 //----------------------------------------------------------------------------------------------------------------
10 //----------------------------------------------------------------------------------------------------------------
11 #include "ConceptDataWrap.h"
13 //----------------------------------------------------------------------------------------------------------------
14 // Class implementation
15 //----------------------------------------------------------------------------------------------------------------
16 /** @file wxContourViewPanel.cxx */
18 //----------------------------------------------------------------------------------------------------------------
19 // Throwed Events definition
20 //----------------------------------------------------------------------------------------------------------------
22 DEFINE_EVENT_TYPE( wxINSTANT_CHANGE )
25 //------------------------------------------------------------------------------------------------------------
26 // Constructors & Destructors
27 //------------------------------------------------------------------------------------------------------------
29 wxContourViewPanel :: wxContourViewPanel ( vtkImageData * theShowingImage, wxWindow *parent, const wxPoint& pos, const wxSize& size,long style, int vertStart, int vertEnd, int horzStart, int horzEnd )
30 //:wxScrolledWindow(parent, -1, pos, size, style)
31 :wxPanel(parent, -1, pos, size, style)
34 showingVID = theShowingImage;
37 createHorizontalBar(1,80);
38 createVerticalBar(1,200);
41 wxFlexGridSizer * panelSizer = new wxFlexGridSizer(3,1,0,0);
42 panelSizer->AddSpacer(gapV);
43 panelSizer -> AddGrowableCol(1);
44 panelSizer->Add(theViewPanel, 1, wxEXPAND);
45 panelSizer->AddSpacer(gapV);
47 wxFlexGridSizer * downSizer = new wxFlexGridSizer(1,3,gapV,gapH);
48 downSizer->Add(_verticalBar, 1, wxEXPAND);
49 //downSizer->AddSpacer(gapH);
50 downSizer -> AddGrowableCol(1);
51 downSizer->Add(panelSizer, 1, wxEXPAND|wxALL|wxCENTER);
52 //downSizer->AddSpacer(gapH);
53 outSizer = new wxFlexGridSizer(3,1,1,1);
54 outSizer->Add(_horizontalBar, 1, wxEXPAND);
55 outSizer -> AddGrowableRow(1);
56 outSizer -> AddGrowableCol(1);
57 outSizer->Add(downSizer, 1, wxEXPAND);
59 _horizontalBar->setDeviceBlitStart( _verticalBar->GetWidth() + gapH, gapV);
60 _horizontalBar->setDeviceEndMargin( gapH+10 );
62 //Connecting the events to the horizontal bar
63 Connect(_horizontalBar->GetId(),wxEVT_TSBAR,(wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onBarrange_Horizontal );
64 Connect(_horizontalBar->GetId(),wxEVT_TSBAR_ACTUAL,(wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onActualChange_Bar_Horizontal );
65 Connect(_horizontalBar->GetId(),wxEVT_TSBAR_START,(wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onStartChange_Bar_Horizontal );
66 Connect(_horizontalBar->GetId(),wxEVT_TSBAR_END,(wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onEndChange_Bar_Horizontal );
67 Connect(_horizontalBar->GetId(),wxEVT_SELECTION_END,(wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onSelectionEnd_Horizontal );
68 Connect(_horizontalBar->GetId(),wxEVT_TSBAR_MOVED,(wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onMovedBar_Horizontal );
70 //Connecting the events to the vertical bar
71 Connect(_verticalBar->GetId(),wxEVT_TSBAR,(wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onBarrange_Vertical );
72 Connect(_verticalBar->GetId(),wxEVT_TSBAR_ACTUAL,(wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onActualChange_Bar_Vertical );
73 Connect(_verticalBar->GetId(),wxEVT_TSBAR_START,(wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onStartChange_Bar_Vertical );
74 Connect(_verticalBar->GetId(),wxEVT_TSBAR_END,(wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onEndChange_Bar_Vertical );
75 Connect(_verticalBar->GetId(),wxEVT_SELECTION_END,(wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onSelectionEnd_Vertical );
76 Connect(_verticalBar->GetId(),wxEVT_TSBAR_MOVED,(wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onMovedBar_Vertical );
79 this->SetAutoLayout( true );
84 theViewPanel->SetSize(800,600);
85 theViewPanel->GetWindow(1)->SetSize(800,600);
87 outSizer->Fit( this );
88 SetBackgroundColour(wxColour(255,0,0));
92 theShowingImage->GetSpacing(last_spacing);
94 showingVID = theShowingImage;
97 _verticalConceptName = "";
98 _horizontalConceptName = "";
99 createHorizontalBar(1,80);
100 createVerticalBar(1,200);
103 wxFlexGridSizer * panelSizer = new wxFlexGridSizer(1, 4, gapV, gapH);
104 panelSizer -> AddGrowableCol(2);
105 panelSizer -> AddGrowableRow(2);
106 panelSizer->Add(_verticalBar, 1, wxGROW);
107 panelSizer->AddSpacer(gapV);
108 panelSizer->Add(theViewPanel, 1, wxGROW);
109 panelSizer->AddSpacer(gapV);
111 outSizer = new wxFlexGridSizer(3, 1, gapH, gapV);
112 outSizer -> AddGrowableCol(1);
113 outSizer -> AddGrowableRow(1);
114 outSizer->Add( _horizontalBar, 1, wxGROW);
115 outSizer->Add( panelSizer, 1, wxGROW);
116 outSizer->AddSpacer(gapH);
118 _horizontalBar->setDeviceBlitStart( _verticalBar->GetWidth() + 2*gapH, gapV);
119 _horizontalBar->setDeviceEndMargin( 2*gapH+10 );
121 //Connecting the events to the horizontal bar
122 Connect(_horizontalBar->GetId(),wxEVT_TSBAR,(wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onBarrange_Horizontal );
123 Connect(_horizontalBar->GetId(),wxEVT_TSBAR_ACTUAL,(wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onActualChange_Bar_Horizontal );
124 Connect(_horizontalBar->GetId(),wxEVT_TSBAR_START,(wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onStartChange_Bar_Horizontal );
125 Connect(_horizontalBar->GetId(),wxEVT_TSBAR_END,(wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onEndChange_Bar_Horizontal );
126 Connect(_horizontalBar->GetId(),wxEVT_SELECTION_END,(wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onSelectionEnd_Horizontal );
127 Connect(_horizontalBar->GetId(),wxEVT_TSBAR_MOVED,(wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onMovedBar_Horizontal );
129 //Connecting the events to the vertical bar
130 Connect(_verticalBar->GetId(),wxEVT_TSBAR,(wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onBarrange_Vertical );
131 Connect(_verticalBar->GetId(),wxEVT_TSBAR_ACTUAL,(wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onActualChange_Bar_Vertical );
132 Connect(_verticalBar->GetId(),wxEVT_TSBAR_START,(wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onStartChange_Bar_Vertical );
133 Connect(_verticalBar->GetId(),wxEVT_TSBAR_END,(wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onEndChange_Bar_Vertical );
134 Connect(_verticalBar->GetId(),wxEVT_SELECTION_END,(wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onSelectionEnd_Vertical );
135 Connect(_verticalBar->GetId(),wxEVT_TSBAR_MOVED,(wxObjectEventFunction) (wxCommandEventFunction) &wxContourViewPanel::onMovedBar_Vertical );
138 SetSizer( outSizer );
139 this->SetAutoLayout( true );
142 //SetSize(1900,1900);
143 //theViewPanel->SetSize(800,600);
144 //theViewPanel->GetWindow(1)->SetSize(800,600);
146 //outSizer->Fit( this );
150 wxContourViewPanel :: ~wxContourViewPanel()
155 //------------------------------------------------------------------------------------------------------------
156 // Creational and initialization methods
157 //------------------------------------------------------------------------------------------------------------
159 void wxContourViewPanel :: setWxEventHandler( wxEvtHandler * theEventHandler )
161 _eventHandler = theEventHandler;
164 void wxContourViewPanel :: createHorizontalBar(int horzStart, int horzEnd)
166 _horizontalBar = new mBarRange(this, 1500,80);
167 _horizontalBar -> setVisibleLabels (true);
168 _horizontalBar -> setRepresentedValues (horzStart, horzEnd);
169 _horizontalBar -> setActiveStateTo(true);
170 _horizontalBar -> SetActual( horzStart );
171 _horizontalBar -> setDeviceBlitStart (10,10);
172 _horizontalBar -> setDeviceEndMargin (10);
175 void wxContourViewPanel :: createVerticalBar(int vertStart, int vertEnd)
177 _verticalBar = new mBarRange(this, 1500,40);
178 _verticalBar -> SetOrientation(false);
179 _verticalBar -> setVisibleLabels (false);
180 _verticalBar -> setRepresentedValues (vertStart, vertEnd);
181 _verticalBar -> setActiveStateTo(true);
182 _verticalBar -> SetActual( vertStart );
183 _verticalBar -> setDeviceBlitStart (10,10);
184 _verticalBar -> setDeviceEndMargin (10);
186 //------------------------------------------------------------------------------------------------------------
188 void wxContourViewPanel :: createViewPanel()
190 std::vector<int> * numViews = new std::vector<int> ();
191 numViews->push_back(2);
192 theViewPanel = new wxMaracas_N_ViewersWidget( this, showingVID, numViews );
193 SetVisibleAxis(false);
195 theViewPanel->SetBackgroundColour(wxColour(0,0,0));
197 theViewPanel->SetSize(800,600);
198 theViewPanel->GetWindow(1)->SetSize(800,600);
200 //------------------------------------------------------------------------------------------------------------
202 wxVtkMPR2DView * wxContourViewPanel::GetwxVtkMPR2DView()
204 return (wxVtkMPR2DView *) (theViewPanel->GetwxVtkBaseView(1));
207 //------------------------------------------------------------------------------------------------------------
208 void wxContourViewPanel::SetVisibleAxis(bool ok)
210 GetwxVtkMPR2DView()->SetVisibleAxis(ok);
213 //------------------------------------------------------------------------------------------------------------
214 int wxContourViewPanel::GetX()
216 return GetwxVtkMPR2DView()->GetVtkmprbasedata()->GetX();
218 //------------------------------------------------------------------------------------------------------------
219 int wxContourViewPanel::GetY()
221 return GetwxVtkMPR2DView()->GetVtkmprbasedata()->GetY();
223 //------------------------------------------------------------------------------------------------------------
224 int wxContourViewPanel::GetZ()
226 return GetwxVtkMPR2DView()->GetVtkmprbasedata()->GetZ();
229 //------------------------------------------------------------------------------------------------------------
230 void wxContourViewPanel::Refresh()
232 GetwxVtkMPR2DView()->GetRenWin()->Render();
236 //------------------------------------------------------------------------------------------------------------
237 // Methods for capturing events from the horizontal bar
238 //------------------------------------------------------------------------------------------------------------
241 * Handles the event wxEVT_TSBAR from the horizontal bar
243 void wxContourViewPanel :: onBarrange_Horizontal(wxCommandEvent& event)
248 * Handles the event wxEVT_TSBAR_ACTUAL from the horizontal bar
250 void wxContourViewPanel :: onActualChange_Bar_Horizontal(wxCommandEvent& event)
252 int nxActual_h = getActualHorizontal();
254 if (_eventHandler!=NULL)
256 //-------------------------------------------------
257 // Sending the event of wxINSTANT_CHANGE
258 //-------------------------------------------------
259 wxCommandEvent newevent(wxINSTANT_CHANGE,GetId());
261 ConceptDataWrap * cWrap = new ConceptDataWrap( _horizontalConceptName );
262 cWrap->setActualValue( nxActual_h );
264 newevent.SetClientData( (void *)cWrap );
265 _eventHandler->ProcessEvent(newevent);
269 * Handles the event wxEVT_TSBAR_START from the horizontal bar
271 void wxContourViewPanel :: onStartChange_Bar_Horizontal(wxCommandEvent& event)
273 int nxStart_h = getStartHorizontal();
276 * Handles the event wxEVT_TSBAR_END from the horizontal bar
278 void wxContourViewPanel :: onEndChange_Bar_Horizontal(wxCommandEvent& event)
280 int nxEnd_h = getEndHorizontal();
283 * Handles the event wxEVT_SELECTION_END from the horizontal bar
285 void wxContourViewPanel :: onSelectionEnd_Horizontal(wxCommandEvent& event)
290 * Handles the event wxEVT_TSBAR_MOVED from the horizontal bar
292 void wxContourViewPanel :: onMovedBar_Horizontal(wxCommandEvent& event)
294 int nxStart_h = getStartHorizontal();
295 int nxEnd_h = getEndHorizontal();
299 //------------------------------------------------------------------------------------------------------------
300 // Methods for capturing events from the vertical bar
301 //------------------------------------------------------------------------------------------------------------
304 * Handles the event wxEVT_TSBAR from the vertical bar
306 void wxContourViewPanel :: onBarrange_Vertical(wxCommandEvent& event)
311 * Handles the event wxEVT_TSBAR_ACTUAL from the vertical bar
313 void wxContourViewPanel :: onActualChange_Bar_Vertical(wxCommandEvent& event)
315 int nxActual_v = getActualVertical();
317 if (_eventHandler!=NULL)
319 //-------------------------------------------------
320 // Sending the event of wxINSTANT_CHANGE
321 //-------------------------------------------------
322 wxCommandEvent newevent(wxINSTANT_CHANGE,GetId());
324 ConceptDataWrap * cWrap = new ConceptDataWrap( _verticalConceptName );
325 cWrap->setActualValue( nxActual_v );
327 newevent.SetClientData( (void *)cWrap );
328 _eventHandler->ProcessEvent(newevent);
332 * Handles the event wxEVT_TSBAR_START from the vertical bar
334 void wxContourViewPanel :: onStartChange_Bar_Vertical(wxCommandEvent& event)
336 int nxStart_v = getStartVertical();
339 * Handles the event wxEVT_TSBAR_END from the vertical bar
341 void wxContourViewPanel :: onEndChange_Bar_Vertical(wxCommandEvent& event)
343 int nxEnd_v = getEndVertical();
346 * Handles the event wxEVT_SELECTION_END from the vertical bar
348 void wxContourViewPanel :: onSelectionEnd_Vertical(wxCommandEvent& event)
353 * Handles the event wxEVT_TSBAR_MOVED from the vertical bar
355 void wxContourViewPanel :: onMovedBar_Vertical(wxCommandEvent& event)
357 int nxStart_v = getStartVertical();
358 int nxEnd_v = getEndVertical();
362 //------------------------------------------------------------------------------------------------------------
363 // Methods for sending events
364 //------------------------------------------------------------------------------------------------------------
366 //------------------------------------------------------------------------------------------------------------
367 // Attributes getters and setters
368 //------------------------------------------------------------------------------------------------------------
371 * Sets the represented values of the vertical bar
372 * @param minRepresented In the minimum represented value of the bar
373 * @param maxRepresented In the maximum represented value of the bar
375 void wxContourViewPanel :: setVerticalRepresentedValues( int minRepresented, int maxRepresented )
377 if( _verticalBar != NULL && _useVerticalBar )
379 _verticalBar -> setRepresentedValues( minRepresented, maxRepresented );
384 * Sets the represented values of the horizontal bar
385 * @param minRepresented In the minimum represented value of the bar
386 * @param maxRepresented In the maximum represented value of the bar
388 void wxContourViewPanel :: setHorizontalRepresentedValues( int minRepresented, int maxRepresented )
390 if( _horizontalBar != NULL && _useHorizontalBar )
392 _horizontalBar -> setRepresentedValues( minRepresented, maxRepresented );
397 * Gets the StartVertical value
398 * @return The StartVertical
400 int wxContourViewPanel :: getStartVertical()
402 return _verticalBar->GetActual();
405 * Gets the EndVertical value
406 * @return The EndVertical
408 int wxContourViewPanel :: getEndVertical()
410 return _verticalBar->GetEnd();
413 * Gets the ActualVertical value
414 * @return The ActualVertical
416 int wxContourViewPanel :: getActualVertical()
418 return _verticalBar->GetEnd();
422 * Sets the StartVertical value
423 * @param nwValue The new value for the StartVertical
425 void wxContourViewPanel :: setStartVertical( int nwValue )
427 _verticalBar->SetEnd( nwValue );
430 * Sets the EndVertical value
431 * @param nwValue The new value for the EndVertical
433 void wxContourViewPanel :: setEndVertical( int nwValue )
435 _verticalBar->SetEnd( nwValue );
438 * Sets the ActualVertical value
439 * @param nwValue The new value for the ActualVertical
441 void wxContourViewPanel :: setActualVertical( int nwValue )
443 _verticalBar->SetActual( nwValue );
447 * Gets the StartHorizontal value
448 * @return The StartHorizontal
450 int wxContourViewPanel :: getStartHorizontal()
452 return _horizontalBar->GetStart();
455 * Gets the EndHorizontal value
456 * @return The EndHorizontal
458 int wxContourViewPanel :: getEndHorizontal()
460 return _horizontalBar->GetEnd();
463 * Gets the ActualHorizontal value
464 * @return The ActualHorizontal
466 int wxContourViewPanel :: getActualHorizontal()
468 return _horizontalBar->GetActual();
472 * Sets the StartHorizontal value
473 * @param nwValue The new value for the StartHorizontal
475 void wxContourViewPanel :: setStartHorizontal( int nwValue )
477 _horizontalBar->SetStart( nwValue );
480 * Sets the EndHorizontal value
481 * @param nwValue The new value for the EndHorizontal
483 void wxContourViewPanel :: setEndHorizontal( int nwValue )
485 _horizontalBar->SetEnd( nwValue );
488 * Sets the ActualHorizontal value
489 * @param nwValue The new value for the ActualHorizontal
491 void wxContourViewPanel :: setActualHorizontal( int nwValue )
493 _horizontalBar->SetActual( nwValue );
497 * Sets the horizontal concept values and name
498 * @param theHorizontalConcept The name of the concept for setting at the horizontal bar
499 * @param minRepresent The minRepresent value of the concept for setting at the horizontal bar
500 * @param maxRepresent The maxRepresent value of the concept for setting at the horizontal bar
501 * @param minShowed The minShowed value of the concept for setting at the horizontal bar
502 * @param maxShowed The maxShowed value of the concept for setting at the horizontal bar
503 * @param actualShow The actualShow value of the concept for setting at the horizontal bar
505 void wxContourViewPanel :: setHorizontalConcept( std::string theHorizontalConcept, int minRepresent, int maxRepresent, int minShowed, int maxShowed, int actualShow )
507 setHorizontalConceptName( theHorizontalConcept );
508 setHorizontalRepresentedValues( minRepresent, maxRepresent );
509 setActualHorizontal( actualShow );
510 setStartHorizontal( minShowed );
511 setEndHorizontal( maxShowed );
515 * Sets the vertical concept values and name
516 * @param theVerticalConcept The name of the concept for setting at the vertical bar
517 * @param minRepresent The minRepresent value of the concept for setting at the vertical bar
518 * @param maxRepresent The maxRepresent value of the concept for setting at the vertical bar
519 * @param minShowed The minShowed value of the concept for setting at the vertical bar
520 * @param maxShowed The maxShowed value of the concept for setting at the vertical bar
521 * @param actualShow The actualShow value of the concept for setting at the vertical bar
523 void wxContourViewPanel :: setVerticalConcept( std::string theVerticalConcept, int minRepresent, int maxRepresent, int minShowed, int maxShowed, int actualShow )
525 setVerticalConceptName( theVerticalConcept );
526 setVerticalRepresentedValues( minRepresent, maxRepresent );
527 setActualVertical( actualShow );
528 setStartVertical( minShowed );
529 setEndVertical( maxShowed );
534 * Sets the horizontal concept name
535 * @param theHorizontalConcept The name of the concept for setting at the horizontal bar
537 void wxContourViewPanel :: setHorizontalConceptName( std::string theHorizontalConcept )
539 _horizontalConceptName = theHorizontalConcept;
543 * Gets the horizontal concept name
544 * @return _horizontalConceptName The name of the concept for setting at the horizontal bar
546 std::string wxContourViewPanel :: getHorizontalConceptName( )
548 return _horizontalConceptName;
552 * Sets the vertical concept name
553 * @param theVerticalConcept The name of the concept for setting at the vertical bar
555 void wxContourViewPanel :: setVerticalConceptName( std::string theVerticalConcept )
557 _verticalConceptName = theVerticalConcept;
561 * Gets the vertical concept name
562 * @return _verticalConceptName The name of the concept for setting at the vertical bar
564 std::string wxContourViewPanel :: getVerticalConceptName( )
566 return _verticalConceptName;
569 //------------------------------------------------------------------------------------------------------------
570 // Other functional methods
571 //------------------------------------------------------------------------------------------------------------
573 void wxContourViewPanel :: getSpacing( double * spacing )
575 spacing[0] = last_spacing[0];
576 spacing[1] = last_spacing[1];
577 spacing[2] = last_spacing[2];
580 wxVtkBaseView* wxContourViewPanel :: getWxVtkBaseView()
582 return theViewPanel->GetwxVtkBaseView(1);
585 double wxContourViewPanel :: getCurrentDeep()
588 // return theViewPanel->GetZ(1);
589 return theViewPanel->GetZ();