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);
57 vtkConeSource *cone = vtkConeSource::New();
59 cone->SetResolution(10);
61 vtkPolyDataMapper *map = vtkPolyDataMapper::New();
62 map->SetInput(cone->GetOutput());
64 vtkActor *act = vtkActor::New();
71 vtkPoints *_pts = vtkPoints::New();
72 _pts->SetNumberOfPoints(4);
74 _pts->SetPoint(0, -1 , -1 , 0 );
75 _pts->SetPoint(1, 1 , -1 , 0 );
76 _pts->SetPoint(2, 1 , 1 , 0 );
77 _pts->SetPoint(3, -1 , 1 , 0 );
79 vtkCellArray *lines = vtkCellArray::New();
80 lines->InsertNextCell(5);
81 lines->InsertCellPoint(0);
82 lines->InsertCellPoint(1);
83 lines->InsertCellPoint(2);
84 lines->InsertCellPoint(3);
85 lines->InsertCellPoint(0);
87 vtkPolyData *_pd = vtkPolyData::New();
88 _pd->SetPoints( _pts );
89 _pd->SetLines( lines );
91 vtkActor *_pointVtkActor = vtkActor::New();
92 vtkPolyDataMapper* _bboxMapper = vtkPolyDataMapper::New();
94 _bboxMapper->SetInput(_pd);
95 _pointVtkActor->SetMapper(_bboxMapper);
97 getRenderer()->AddActor(_pointVtkActor);
101 /////////////////////
103 //getRenderer()->AddActor(act);
105 //getRenderer()->Render();
111 //=========================================================================
112 void wxVtkSceneManager::disconnectDrop()
114 _baseView->GetWxVTKRenderWindowInteractor()->SetDropTarget(NULL);
116 //=========================================================================
117 wxVtkSceneManager::~wxVtkSceneManager()
120 //=========================================================================
122 void wxVtkSceneManager::configureBaseView()
124 vtkInteractorStyleImage *style = vtkInteractorStyleImage::New();
125 _baseView->GetWxVTKRenderWindowInteractor()->SetInteractorStyle(style);
126 //_baseView->GetRenderer()->SetActiveCamera(_baseView->GetCamera());
127 //_baseView->GetRenderer()->ResetCamera ();
128 //_baseView->GetCamera()->SetParallelProjection(true);
130 _baseView->GetRenderer()->SetBackground(0.9,0.9,0.9);
131 _baseView->GetRenderer()->GradientBackgroundOff();
132 _baseView->Refresh();
135 //=========================================================================
137 void wxVtkSceneManager::createGBlackBox(int x, int y, std::string packageName, std::string boxName)
139 int type = GBLACKBOX;
141 //Create the MVC Objects
142 GObjectModel *model = GObjectsMVCFactory::getInstance()->createGObjectModel(type);
143 vtkGObjectView *view = GObjectsMVCFactory::getInstance()->createGObjectView(type);
144 GObjectController* controller = GObjectsMVCFactory::getInstance()->createGObjectController(type);
146 BlackBoxDescriptor::Pointer descriptor = GObjectsMVCFactory::getInstance()->getBlackBoxDescriptor(packageName, boxName);
148 //Prepares the initial model
150 double yy = _baseView->GetRenWin()->GetSize()[1]-y;
152 _baseView->TransCoordScreenToWorld(xx,yy,zz);
153 model->setInicPoint(xx,yy,zz);
154 model->updateBlackBox(descriptor);
157 //Associates the view with the correspondent renderer and the model.
158 //(NOTE: Refresh is only made by the view)
159 view->setModel(model);
160 view->setBaseView(_baseView);
161 view->initVtkObjects();
163 //Associates the controller with the correspondent model and view
164 controller->setModelAndView(model,view);
166 //Refresh renderwindow with new objects
167 refreshRenderWindow();
169 registerController((InteractorStyleMaracas*) controller);
173 //=========================================================================
175 void wxVtkSceneManager::registerController(InteractorStyleMaracas *param)
177 vtkInteractorStyleBaseView* baseViewControlManager = (vtkInteractorStyleBaseView*)_baseView->GetInteractorStyleBaseView();
178 baseViewControlManager->AddInteractorStyleMaracas( param );
181 //=========================================================================
183 vtkRenderer* wxVtkSceneManager::getRenderer()
185 return _baseView->GetRenderer();
188 //=========================================================================
190 vtkRenderWindow* wxVtkSceneManager::getRenderWindow()
192 return _baseView->GetRenWin();
194 //=========================================================================
196 void wxVtkSceneManager::refreshRenderWindow()
198 _baseView->GetRenWin()->Render();
200 //=========================================================================
202 bool wxVtkSceneManager::OnMouseMove()
204 //cout<<"RaC wxVtkSceneManager::OnMouseMove "<<endl;
207 //=========================================================================
208 } // EO namespace bbtk