/*========================================================================= Program: bbtk Module: $RCSfile$ Language: C++ Date: $Date$ Version: $Revision$ =========================================================================*/ /* --------------------------------------------------------------------- * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale) * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux * * This software is governed by the CeCILL-B license under French law and * abiding by the rules of distribution of free software. You can use, * modify and/ or redistribute the software under the terms of the CeCILL-B * license as circulated by CEA, CNRS and INRIA at the following URL * http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html * or in the file LICENSE.txt. * * As a counterpart to the access to the source code and rights to copy, * modify and redistribute granted by the license, users are provided only * with a limited warranty and the software's author, the holder of the * economic rights, and the successive licensors have only limited * liability. * * The fact that you are presently reading this means that you have had * knowledge of the CeCILL-B license and that you accept its terms. * ------------------------------------------------------------------------ */ /** * \file * \brief Class bbtk::wxVtkSceneManager . */ #include "wxVtkSceneManager.h" namespace bbtk { //========================================================================= wxVtkSceneManager::wxVtkSceneManager(wxDropTarget *parent, wxVtk3DBaseView *baseView,int id) { _id=id; _baseView=baseView; if( _baseView!=NULL ) { _baseView->GetWxVTKRenderWindowInteractor()->SetDropTarget(parent); registerController(this); configureBaseView(); vtkConeSource *cone = vtkConeSource::New(); cone->SetResolution(10); vtkPolyDataMapper *map = vtkPolyDataMapper::New(); map->SetInput(cone->GetOutput()); vtkActor *act = vtkActor::New(); act->SetMapper(map); ///////////////////// vtkPoints *_pts = vtkPoints::New(); _pts->SetNumberOfPoints(4); _pts->SetPoint(0, -1 , -1 , 0 ); _pts->SetPoint(1, 1 , -1 , 0 ); _pts->SetPoint(2, 1 , 1 , 0 ); _pts->SetPoint(3, -1 , 1 , 0 ); vtkCellArray *lines = vtkCellArray::New(); lines->InsertNextCell(5); lines->InsertCellPoint(0); lines->InsertCellPoint(1); lines->InsertCellPoint(2); lines->InsertCellPoint(3); lines->InsertCellPoint(0); vtkPolyData *_pd = vtkPolyData::New(); _pd->SetPoints( _pts ); _pd->SetLines( lines ); vtkActor *_pointVtkActor = vtkActor::New(); vtkPolyDataMapper* _bboxMapper = vtkPolyDataMapper::New(); _bboxMapper->SetInput(_pd); _pointVtkActor->SetMapper(_bboxMapper); getRenderer()->AddActor(_pointVtkActor); ///////////////////// //getRenderer()->AddActor(act); //getRenderer()->Render(); } } //========================================================================= void wxVtkSceneManager::disconnectDrop() { _baseView->GetWxVTKRenderWindowInteractor()->SetDropTarget(NULL); } //========================================================================= wxVtkSceneManager::~wxVtkSceneManager() { } //========================================================================= void wxVtkSceneManager::configureBaseView() { vtkInteractorStyleImage *temp = vtkInteractorStyleImage::New(); _baseView->GetWxVTKRenderWindowInteractor()->SetInteractorStyle(temp); _baseView->GetRenderer()->SetActiveCamera(_baseView->GetCamera()); _baseView->GetRenderer()->ResetCamera (); _baseView->GetCamera()->SetParallelProjection(true); _baseView->Refresh(); } //========================================================================= void wxVtkSceneManager::createGBlackBox(int x, int y, std::string packageName, std::string boxName) { int type = GBLACKBOX; //Create the MVC Objects GObjectModel *model = GObjectsMVCFactory::getInstance()->createGObjectModel(type); vtkGObjectView *view = GObjectsMVCFactory::getInstance()->createGObjectView(type); GObjectController* controller = GObjectsMVCFactory::getInstance()->createGObjectController(type); //Prepares the initial model double xx = x; double yy = y; double zz = 900; _baseView->TransCoordScreenToWorld(xx,yy,zz); //Associates the view with the correspondent renderer and the model. //(NOTE: Refresh is only made by the view) model->setInicPoint(xx,yy,zz); view->setModel(model); view->setRenderer(_baseView->GetRenderer()); view->initVtkObjects(); //Refresh renderwindow with new objects refreshRenderWindow(); //Associates the controller with the correspondent model and view controller->setModelAndView(model,view); registerController((InteractorStyleMaracas*) controller); } //========================================================================= void wxVtkSceneManager::registerController(InteractorStyleMaracas *param) { vtkInteractorStyleBaseView* baseViewControlManager = (vtkInteractorStyleBaseView*)_baseView->GetInteractorStyleBaseView(); baseViewControlManager->AddInteractorStyleMaracas( param ); } //========================================================================= vtkRenderer* wxVtkSceneManager::getRenderer() { return _baseView->GetRenderer(); } //========================================================================= vtkRenderWindow* wxVtkSceneManager::getRenderWindow() { return _baseView->GetRenWin(); } //========================================================================= void wxVtkSceneManager::refreshRenderWindow() { _baseView->GetRenWin()->Render(); } //========================================================================= //========================================================================= } // EO namespace bbtk // EOF