wxWidgetMesure2D_Plane.cxx

Go to the documentation of this file.
00001 #include "wxWidgetMesure2D_Plane.h"
00002 
00003 #include "vtkPlane2DView.h"
00004 
00005 wxWidgetMesure2D_Plane::wxWidgetMesure2D_Plane(wxWindow *parent)
00006 : wxWidgetMesure2D(parent)
00007 {
00008         // Circle 1
00009         _ptsCircle1             = NULL;
00010         _circle1Actor   = NULL;
00011         _circle1Mapper  = NULL;
00012     _pdCircle1          = NULL;
00013         // Circle 2
00014         _ptsCircle2             = NULL;
00015         _circle2Actor   = NULL;
00016         _circle2Mapper  = NULL;
00017     _pdCircle2          = NULL;
00018         // line reference 1
00019         _ptsLineRef1    = NULL;
00020         _lineRef1Actor  = NULL;
00021         _lineRef1Mapper = NULL;
00022     _pdLineRef1         = NULL;
00023         // line reference 2
00024         _ptsLineRef2    = NULL;
00025         _lineRef2Actor  = NULL;
00026         _lineRef2Mapper = NULL;
00027     _pdLineRef2         = NULL;
00028 
00029 }
00030 
00031 //-------------------------------------------------------------------
00032 
00033 wxWidgetMesure2D_Plane::~wxWidgetMesure2D_Plane()
00034 {
00035         // Circle 1
00036     if (        _ptsCircle1             != NULL){       _ptsCircle1                     -> Delete(); }
00037     if (        _circle1Actor   != NULL){       _circle1Actor           -> Delete(); }
00038     if (        _circle1Mapper  != NULL){       _circle1Mapper          -> Delete(); }
00039     if (    _pdCircle1          != NULL){       _pdCircle1                      -> Delete(); }
00040         // Circle 2
00041     if (        _ptsCircle2             != NULL){       _ptsCircle2                     -> Delete(); }
00042     if (        _circle2Actor   != NULL){       _circle2Actor           -> Delete(); }
00043     if (        _circle2Mapper  != NULL){       _circle2Mapper          -> Delete(); }
00044     if (    _pdCircle2          != NULL){       _pdCircle2                      -> Delete(); }
00045         // line reference 1
00046     if (        _ptsLineRef1    != NULL){       _ptsLineRef1            -> Delete(); }
00047     if (        _lineRef1Actor  != NULL){       _lineRef1Actor          -> Delete(); }
00048     if (        _lineRef1Mapper != NULL){       _lineRef1Mapper         -> Delete(); }
00049      if (   _pdLineRef1         != NULL){       _pdLineRef1                     -> Delete(); }
00050         // line reference 2
00051     if (        _ptsLineRef2    != NULL){       _ptsLineRef2            -> Delete(); }
00052     if (        _lineRef2Actor  != NULL){       _lineRef2Actor          -> Delete(); }
00053     if (        _lineRef2Mapper != NULL){       _lineRef2Mapper         -> Delete(); }
00054     if (    _pdLineRef2         != NULL){       _pdLineRef2                     -> Delete(); }
00055 }
00056 
00057 //-------------------------------------------------------------------
00058 
00059 wxWindow *wxWidgetMesure2D_Plane::CreateWin1a(wxWindow *parent) // virtual
00060 {
00061         wxPanel *panel = new wxPanel(parent,-1);
00062 
00063         _cb_circle              = new wxCheckBox(panel,-1,_T("Circle        ")); 
00064         _cb_line                = new wxCheckBox(panel,-1,_T("Rotation Axe ")); 
00065 
00066 
00067         wxBoxSizer *sizerA = new wxBoxSizer(wxHORIZONTAL);
00068         sizerA->Add(_cb_circle);
00069         sizerA->Add(_cb_line);
00070 
00071 
00072         wxFlexGridSizer *sizer = new wxFlexGridSizer(1);
00073         sizer->Add( sizerA );
00074         sizer->Add( wxWidgetMesure2D::CreateWin1a(panel) );
00075 
00076         panel->SetAutoLayout(true);
00077         panel->SetSizer(sizer);
00078         panel->SetSize(400,30);
00079         panel->Layout();
00080 //EEDxx2.4
00081 //      panel->FitInside();
00082 
00083         Connect(_cb_line->GetId()        , wxEVT_COMMAND_CHECKBOX_CLICKED         , (wxObjectEventFunction) &wxWidgetMesure2D_Plane::OnActiveLine                       );
00084         Connect(_cb_circle->GetId()      , wxEVT_COMMAND_CHECKBOX_CLICKED         , (wxObjectEventFunction) &wxWidgetMesure2D_Plane::OnActiveCirlcle            );
00085 
00086         return panel;
00087 }
00088 
00089 
00090 //-------------------------------------------------------------------
00091 void wxWidgetMesure2D_Plane::OnActiveCirlcle(wxCommandEvent& event)
00092 {
00093         SetVisibleCircle( _cb_circle->GetValue() );
00094         _wxvtk2Dbaseview->RefreshView();
00095 }
00096 
00097 //-------------------------------------------------------------------
00098 void wxWidgetMesure2D_Plane::SetVisibleCircle( bool ok )
00099 {
00100         double opacity;
00101         if (ok==true)
00102         {
00103                 opacity=1;
00104         } else {
00105                 opacity=0;
00106         } 
00107         _lineRef1Actor->GetProperty()->SetOpacity( opacity );
00108         _lineRef2Actor->GetProperty()->SetOpacity( opacity );
00109         _circle1Actor->GetProperty()->SetOpacity( opacity );
00110         _circle2Actor->GetProperty()->SetOpacity( opacity );
00111 }
00112 //-------------------------------------------------------------------
00113 void wxWidgetMesure2D_Plane::OnActiveLine(wxCommandEvent& event)
00114 {
00115         vtkPlane2DView *vtkplane2Dview = (vtkPlane2DView*)_wxvtk2Dbaseview;
00116         vtkplane2Dview->SetVisibleLine( _cb_line->GetValue() );
00117         _wxvtk2Dbaseview->RefreshView();
00118 }
00119 
00120 
00121 //-------------------------------------------------------------------
00122 void wxWidgetMesure2D_Plane::ConfigureA(wxVtk2DBaseView *wxvtk2Dbaseview) // virtual
00123 {
00124         wxWidgetMesure2D::ConfigureA(wxvtk2Dbaseview);
00125         CircleLine();
00126         ConfigureCircleLine();
00127         SetVisibleCircle(false);        
00128 }
00129 
00130 
00131 //-------------------------------------------------------------------
00132 void wxWidgetMesure2D_Plane::ConfigureCircleLine()
00133 {
00134         double ang;
00135 
00136         vtkPlane2DView *vtkplane2Dview = (vtkPlane2DView*)_wxvtk2Dbaseview;
00137         int sizeIma = vtkplane2Dview->GetImgSize();
00138 
00139         double i,maxPts=20;
00140         double k=(360/(maxPts-1)) * (3.1416/180);
00141         double x,y,r1=5,r2=10,r3=15;
00142         for (i=0;i<maxPts;i++)
00143         {
00144                 x=cos( k*i ) ;
00145                 y=sin( k*i ) ;
00146                 _ptsCircle1->SetPoint( (int)i , (sizeIma/2) + x*r1      , (sizeIma/2) + y*r1    , 1 );
00147                 _ptsCircle2->SetPoint( (int)i , (sizeIma/2) + x*r2      , (sizeIma/2) + y*r2    , 1 );
00148         }
00149 
00150         //
00151         ang=(45) * (3.1416/180);
00152         x=cos( ang ) ;
00153         y=sin( ang ) ;
00154         _ptsLineRef1->SetPoint( 0 , (sizeIma/2) + x*r3  , (sizeIma/2) + y*r3    , 1 );
00155         
00156         ang=(45+180) * (3.1416/180);
00157         x=cos( ang ) ;
00158         y=sin( ang ) ;
00159         _ptsLineRef1->SetPoint( 1 , (sizeIma/2) + x*r3  , (sizeIma/2) + y*r3    , 1 );
00160 
00161         //
00162         ang=(135) * (3.1416/180);
00163         x=cos( ang ) ;
00164         y=sin( ang ) ;
00165         _ptsLineRef2->SetPoint( 0 , (sizeIma/2) + x*r3  , (sizeIma/2) + y*r3    , 1 );
00166         
00167         ang=(135+180) * (3.1416/180);
00168         x=cos( ang ) ;
00169         y=sin( ang ) ;
00170         _ptsLineRef2->SetPoint( 1 , (sizeIma/2) + x*r3  , (sizeIma/2) + y*r3    , 1 );
00171 }
00172 
00173 
00174 
00175 //-------------------------------------------------------------------
00176 void wxWidgetMesure2D_Plane::CircleLine()
00177 {
00178         int i,maxPts=20;
00179         vtkCellArray *lines;
00180 
00181         vtkImageViewer2_XYZ *imageViewer2XYZ = _wxvtk2Dbaseview->_imageViewer2XYZ;
00182         
00183 
00184 // Circle 1 Horizontal
00185         _ptsCircle1 = vtkPoints::New();
00186         _ptsCircle1->SetNumberOfPoints(maxPts);
00187         lines = vtkCellArray::New();
00188         lines->InsertNextCell(maxPts);
00189         for (i=0;i<maxPts;i++)
00190         {
00191                 lines->InsertCellPoint(i);
00192                 _ptsCircle1->SetPoint(i, 0      , 0     , 0 );
00193         }
00194         lines->InsertCellPoint(0);
00195         _ptsCircle1->SetPoint(0, -1000  , -1000 , -1000 );
00196         _ptsCircle1->SetPoint(1,  1000  ,  1000 ,  1000 );
00197 
00198         _pdCircle1 = vtkPolyData::New();
00199     _pdCircle1->SetPoints( _ptsCircle1 );
00200     _pdCircle1->SetLines( lines );
00201         lines->Delete();  //do not delete lines ??
00202         _circle1Actor                                   =       vtkActor::New();
00203     _circle1Mapper                                      =       vtkPolyDataMapper::New();
00204         _circle1Mapper->SetInput(_pdCircle1);
00205         _circle1Mapper->ImmediateModeRenderingOn();
00206         _circle1Actor->SetMapper(_circle1Mapper);
00207         _circle1Actor->GetProperty()->BackfaceCullingOn();
00208         _circle1Actor->GetProperty()->SetDiffuseColor(0,0,1);
00209         _circle1Actor->GetProperty()->SetLineWidth(2);
00210     imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->AddActor( _circle1Actor );
00211 
00212 // Circle 2 Horizontal
00213         _ptsCircle2 = vtkPoints::New();
00214         _ptsCircle2->SetNumberOfPoints(maxPts);
00215         lines = vtkCellArray::New();
00216         lines->InsertNextCell(maxPts);
00217         for (i=0;i<maxPts;i++)
00218         {
00219                 lines->InsertCellPoint(i);
00220                 _ptsCircle2->SetPoint(i, 0      , 0     , 0 );
00221         }
00222         _ptsCircle2->SetPoint(0, -1000  , -1000 , -1000 );
00223         _ptsCircle2->SetPoint(1,  1000  ,  1000 ,  1000 );
00224 
00225         _pdCircle2 = vtkPolyData::New();
00226     _pdCircle2->SetPoints( _ptsCircle2 );
00227     _pdCircle2->SetLines( lines );
00228         lines->Delete();  //do not delete lines ??
00229         _circle2Actor                                   =       vtkActor::New();
00230     _circle2Mapper                                      =       vtkPolyDataMapper::New();
00231         _circle2Mapper->SetInput(_pdCircle2);
00232         _circle2Mapper->ImmediateModeRenderingOn();
00233         _circle2Actor->SetMapper(_circle2Mapper);
00234         _circle2Actor->GetProperty()->BackfaceCullingOn();
00235         _circle2Actor->GetProperty()->SetDiffuseColor(0,0,1);
00236         _circle2Actor->GetProperty()->SetLineWidth(2);
00237     imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->AddActor( _circle2Actor );
00238 
00239 // Line Referance 1
00240         _ptsLineRef1 = vtkPoints::New();
00241         _ptsLineRef1->SetNumberOfPoints(2);
00242         _ptsLineRef1->SetPoint(0, -1000 , -1000 , -1000 );
00243         _ptsLineRef1->SetPoint(1,  1000 ,  1000 ,  1000 );
00244         lines = vtkCellArray::New();
00245         lines->InsertNextCell(2);
00246         lines->InsertCellPoint(0);
00247         lines->InsertCellPoint(1);
00248 
00249         _pdLineRef1 = vtkPolyData::New();
00250     _pdLineRef1->SetPoints( _ptsLineRef1 );
00251     _pdLineRef1->SetLines( lines );
00252         lines->Delete();  //do not delete lines ??
00253         _lineRef1Actor                                  =       vtkActor::New();
00254     _lineRef1Mapper                                     =       vtkPolyDataMapper::New();
00255         _lineRef1Mapper->SetInput(_pdLineRef1);
00256         _lineRef1Mapper->ImmediateModeRenderingOn();
00257         _lineRef1Actor->SetMapper(_lineRef1Mapper);
00258         _lineRef1Actor->GetProperty()->BackfaceCullingOn();
00259         _lineRef1Actor->GetProperty()->SetDiffuseColor(0,0,1);
00260         _lineRef1Actor->GetProperty()->SetLineWidth(2);
00261     imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->AddActor( _lineRef1Actor );
00262 
00263 // Line Referance 2
00264         _ptsLineRef2 = vtkPoints::New();
00265         _ptsLineRef2->SetNumberOfPoints(2);
00266         _ptsLineRef2->SetPoint(0, -1000 , -1000 , -1000 );
00267         _ptsLineRef2->SetPoint(1,  1000 ,  1000 ,  1000 );
00268         lines = vtkCellArray::New();
00269         lines->InsertNextCell(2);
00270         lines->InsertCellPoint(0);
00271         lines->InsertCellPoint(1);
00272 
00273         _pdLineRef2 = vtkPolyData::New();
00274     _pdLineRef2->SetPoints( _ptsLineRef2 );
00275     _pdLineRef2->SetLines( lines );
00276         lines->Delete();  //do not delete lines ??
00277         _lineRef2Actor                                  =       vtkActor::New();
00278     _lineRef2Mapper                                     =       vtkPolyDataMapper::New();
00279         _lineRef2Mapper->SetInput(_pdLineRef2);
00280         _lineRef2Mapper->ImmediateModeRenderingOn();
00281         _lineRef2Actor->SetMapper(_lineRef2Mapper);
00282         _lineRef2Actor->GetProperty()->BackfaceCullingOn();
00283         _lineRef2Actor->GetProperty()->SetDiffuseColor(0,0,1);
00284         _lineRef2Actor->GetProperty()->SetLineWidth(2);
00285     imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->AddActor( _lineRef2Actor );
00286 
00287 
00288 }
00289 

Generated on 18 Mar 2010 for creaMaracasVisu_lib by  doxygen 1.6.1