]> Creatis software - creaMaracasVisu.git/blob - bbtk/src/bbcreaMaracasVisuManualPaint.cxx
3bde3b50196625739569c2731b969896ab721623
[creaMaracasVisu.git] / bbtk / src / bbcreaMaracasVisuManualPaint.cxx
1 //=====
2 // Don't edit this file. This file is generated from xml description..
3 //=====
4 #include "bbcreaMaracasVisuManualPaint.h"
5 #include "bbcreaMaracasVisuPackage.h"
6
7 #include "wxVtk2DBaseView.h"
8 #include "wxVTKRenderWindowInteractor.h"
9
10 namespace bbcreaMaracasVisu
11 {
12
13
14
15 vtkInteractorManualPaint::vtkInteractorManualPaint()
16 {
17         _state  =   false;
18         _image  =   NULL;
19         _auxZ   =   0;
20 }
21
22 //---------------------------------------------------------------------------
23 vtkInteractorManualPaint::~vtkInteractorManualPaint()
24 {
25 }
26
27 //---------------------------------------------------------------------------
28 bool vtkInteractorManualPaint::OnLeftButtonDown()
29 {
30         vtkRenderWindowInteractor *interactor = _vtkInteractorStyleBaseView->GetInteractor();
31         if ((interactor->GetControlKey()==1) || (interactor->GetShiftKey()==1) ){
32         _state  =   true;
33         wxVtk2DBaseView             *wxvtk2Dbaseview    = (wxVtk2DBaseView*)_vtkInteractorStyleBaseView->GetWxVtk2DBaseView();
34         _Z      =   wxvtk2Dbaseview->GetActualSlice();
35 //              _sliceZ         = ((wxVtk2DBaseView*)_vtkInteractorStyleBaseView->GetWxVtk2DBaseView())->GetActualSlice();
36         }
37         return true;
38 }
39
40 //---------------------------------------------------------------------------
41 bool vtkInteractorManualPaint::OnLeftButtonUp()
42 {
43         _state = false;
44         return true;
45 }
46
47 //---------------------------------------------------------------------------
48 bool vtkInteractorManualPaint::OnMouseMove ()
49 {
50     printf("EED vtkInteractorManualPaint::OnMouseMove \n");
51         if (_state==true)
52         {
53         int px,py;
54         wxVtk2DBaseView             *wxvtk2Dbaseview    = (wxVtk2DBaseView*)_vtkInteractorStyleBaseView->GetWxVtk2DBaseView();
55         wxVTKRenderWindowInteractor *wxVTKiren          = wxvtk2Dbaseview->GetWxVTKRenderWindowInteractor();
56
57         wxVTKiren->GetEventPosition(px,py);
58
59         double X = (double)px;
60         double Y = (double)py;
61         double Z = _Z;
62         int typeView = 2;
63         wxvtk2Dbaseview->TransFromCoordScreenToWorld(X, Y, Z,false, typeView);
64
65 //        int px = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[0];
66 //        int py = _vtkInteractorStyleBaseView->GetInteractor()->GetEventPosition()[1];
67         printf("EED vtkInteractorManualPaint::OnMouseMove  -----------------  %f %f %f\n", X,Y,Z);
68
69         PaintImage((int)X,(int)Y,(int)Z);
70
71         wxvtk2Dbaseview->Refresh();
72         wxvtk2Dbaseview->RefreshView();
73 //        wxvtk2Dbaseview->SetActualSlice(_Z+_auxZ);
74         _auxZ=(_auxZ+1)%2;
75         wxvtk2Dbaseview->_imageViewer2XYZ->GetVtkImageViewer2()->GetRenderer()->Render();
76         this->_vtkInteractorStyleBaseView->SetParent_refresh_waiting();
77 //        wxvtk2Dbaseview->SetActualSlice(Z);
78         }// if _state
79         return true;
80 }
81
82 //---------------------------------------------------------------------------
83 void vtkInteractorManualPaint::SetImage(vtkImageData *image)
84 {
85         _image = image;
86 }
87
88
89 void vtkInteractorManualPaint::PaintImage(int px,int py, int pz)
90 {
91     if (_image!=NULL)
92     {
93         float value=0;
94         printf("EED vtkInteractorManualPaint::PaintImage   %d %d %d\n", px,py,pz);
95         _image->SetScalarComponentFromFloat (px,py,pz, 0, value );
96         _image->Modified();
97     } else  {
98         printf("ERROR : bbcreaMaracasvisu::vtkInteractorManualPaint::PaintImage :  Image not set. \n");
99     }
100 }
101
102
103
104 //---------------------------------------------------------------------------------
105 //---------------------------------------------------------------------------------
106 //---------------------------------------------------------------------------------
107
108
109
110
111
112 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,ManualPaint)
113 BBTK_BLACK_BOX_IMPLEMENTATION(ManualPaint,bbtk::WxBlackBox);
114 //=====
115 // Don't edit this file. This file is generated from xml description..
116 //=====
117 void ManualPaint::Process()
118 {
119
120 /*
121    std::string msg;
122     if (bbGetInputTitle()!="")
123       {
124         msg = bbGetInputTitle()+": " + bbGetInputIn();
125       }
126     else
127       {
128         msg = bbGetInputIn();
129       }
130    ((wxStaticText*)bbGetOutputWidget())->SetLabel( bbtk::std2wx( msg ) );
131   */
132
133     if (bbGetInputWxVtkBaseView()==NULL)
134     {
135         printf("WARNING : package creaMaracasVisu box ManualPaint : input WxVtkBaseView have to be defferent of NULL\n");
136     }
137
138     if (bbGetInputIn()==NULL)
139     {
140         printf("WARNING : package creaMaracasVisu box ManualPaint : input In (vtkImageData*) have to be defferent of NULL\n");
141     }
142
143
144     if (imp==NULL)
145     {
146         imp=new vtkInteractorManualPaint();
147         imp->SetImage( bbGetInputIn() );
148         vtkInteractorStyleBaseView *isbv = (vtkInteractorStyleBaseView*)(bbGetInputWxVtkBaseView()->GetInteractorStyleBaseView());
149         isbv->AddInteractorStyleMaracas(imp);
150     }
151
152 }
153 //=====
154 // Don't edit this file. This file is generated from xml description..
155 //=====
156 void ManualPaint::CreateWidget(wxWindow* parent)
157 {
158
159    bbSetOutputWidget( new wxStaticText ( parent , -1 , _T("UPS") ) );
160
161 }
162 //=====
163 // Don't edit this file. This file is generated from xml description..
164 //=====
165 void ManualPaint::bbUserSetDefaultValues()
166 {
167     imp=NULL;
168     bbSetInputIn(NULL);
169 }
170 //=====
171 // Don't edit this file. This file is generated from xml description..
172 //=====
173 void ManualPaint::bbUserInitializeProcessing()
174 {
175
176 }
177 //=====
178 // Don't edit this file. This file is generated from xml description..
179 //=====
180 void ManualPaint::bbUserFinalizeProcessing()
181 {
182
183 }
184
185 } // EO namespace bbcreaMaracasVisu
186
187