1 /*=========================================================================
7 =========================================================================*/
9 /* ---------------------------------------------------------------------
11 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
12 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
14 * This software is governed by the CeCILL-B license under French law and
15 * abiding by the rules of distribution of free software. You can use,
16 * modify and/ or redistribute the software under the terms of the CeCILL-B
17 * license as circulated by CEA, CNRS and INRIA at the following URL
18 * http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
19 * or in the file LICENSE.txt.
21 * As a counterpart to the access to the source code and rights to copy,
22 * modify and redistribute granted by the license, users are provided only
23 * with a limited warranty and the software's author, the holder of the
24 * economic rights, and the successive licensors have only limited
27 * The fact that you are presently reading this means that you have had
28 * knowledge of the CeCILL-B license and that you accept its terms.
29 * ------------------------------------------------------------------------ */
33 * \brief Class bbtk::wxVtkSceneManager .
37 #include "wxVtkSceneManager.h"
43 //=========================================================================
44 wxVtkSceneManager::wxVtkSceneManager(wxDropTarget *parent, wxVtk3DBaseView *baseView,int id)
51 _baseView->GetWxVTKRenderWindowInteractor()->SetDropTarget(parent);
52 registerController(this);
56 vtkConeSource *cone = vtkConeSource::New();
58 cone->SetResolution(10);
60 vtkPolyDataMapper *map = vtkPolyDataMapper::New();
61 map->SetInput(cone->GetOutput());
63 vtkActor *act = vtkActor::New();
70 vtkPoints *_pts = vtkPoints::New();
71 _pts->SetNumberOfPoints(4);
73 _pts->SetPoint(0, -1 , -1 , 0 );
74 _pts->SetPoint(1, 1 , -1 , 0 );
75 _pts->SetPoint(2, 1 , 1 , 0 );
76 _pts->SetPoint(3, -1 , 1 , 0 );
78 vtkCellArray *lines = vtkCellArray::New();
79 lines->InsertNextCell(5);
80 lines->InsertCellPoint(0);
81 lines->InsertCellPoint(1);
82 lines->InsertCellPoint(2);
83 lines->InsertCellPoint(3);
84 lines->InsertCellPoint(0);
86 vtkPolyData *_pd = vtkPolyData::New();
87 _pd->SetPoints( _pts );
88 _pd->SetLines( lines );
90 vtkActor *_pointVtkActor = vtkActor::New();
91 vtkPolyDataMapper* _bboxMapper = vtkPolyDataMapper::New();
93 _bboxMapper->SetInput(_pd);
94 _pointVtkActor->SetMapper(_bboxMapper);
96 getRenderer()->AddActor(_pointVtkActor);
100 /////////////////////
102 //getRenderer()->AddActor(act);
104 //getRenderer()->Render();
110 //=========================================================================
111 void wxVtkSceneManager::disconnectDrop()
113 _baseView->GetWxVTKRenderWindowInteractor()->SetDropTarget(NULL);
115 //=========================================================================
116 wxVtkSceneManager::~wxVtkSceneManager()
119 //=========================================================================
121 void wxVtkSceneManager::configureBaseView()
123 vtkInteractorStyleImage *temp = vtkInteractorStyleImage::New();
124 _baseView->GetWxVTKRenderWindowInteractor()->SetInteractorStyle(temp);
125 //_baseView->GetRenderer()->SetActiveCamera(_baseView->GetCamera());
126 //_baseView->GetRenderer()->ResetCamera ();
127 //_baseView->GetCamera()->SetParallelProjection(true);
129 _baseView->GetRenderer()->SetBackground(1,1,1);
130 _baseView->Refresh();
133 //=========================================================================
135 void wxVtkSceneManager::createGBlackBox(int x, int y, std::string packageName, std::string boxName)
137 int type = GBLACKBOX;
139 //Create the MVC Objects
140 GObjectModel *model = GObjectsMVCFactory::getInstance()->createGObjectModel(type);
141 vtkGObjectView *view = GObjectsMVCFactory::getInstance()->createGObjectView(type);
142 GObjectController* controller = GObjectsMVCFactory::getInstance()->createGObjectController(type);
144 //Prepares the initial model
145 cout<<"RaC Size:"<<_baseView->GetRenWin()->GetSize()[1]<<endl;
147 double yy = _baseView->GetRenWin()->GetSize()[1]-y;
150 _baseView->TransCoordScreenToWorld(xx,yy,zz);
152 //Associates the view with the correspondent renderer and the model.
153 //(NOTE: Refresh is only made by the view)
154 model->setInicPoint(xx,yy,zz);
155 view->setModel(model);
156 view->setBaseView(_baseView);
157 view->initVtkObjects();
159 //Refresh renderwindow with new objects
160 refreshRenderWindow();
162 //Associates the controller with the correspondent model and view
163 controller->setModelAndView(model,view);
165 registerController((InteractorStyleMaracas*) controller);
168 //=========================================================================
170 void wxVtkSceneManager::registerController(InteractorStyleMaracas *param)
172 cout<<"RaC wxVtkSceneManager::registerController param:"<<param<<endl;
173 vtkInteractorStyleBaseView* baseViewControlManager = (vtkInteractorStyleBaseView*)_baseView->GetInteractorStyleBaseView();
174 baseViewControlManager->AddInteractorStyleMaracas( param );
177 //=========================================================================
179 vtkRenderer* wxVtkSceneManager::getRenderer()
181 return _baseView->GetRenderer();
184 //=========================================================================
186 vtkRenderWindow* wxVtkSceneManager::getRenderWindow()
188 return _baseView->GetRenWin();
190 //=========================================================================
192 void wxVtkSceneManager::refreshRenderWindow()
194 _baseView->GetRenWin()->Render();
196 //=========================================================================
198 bool wxVtkSceneManager::OnMouseMove()
200 cout<<"RaC wxVtkSceneManager::OnMouseMove "<<endl;
203 //=========================================================================
204 } // EO namespace bbtk