1 /*# ---------------------------------------------------------------------
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
5 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
7 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
9 # This software is governed by the CeCILL-B license under French law and
10 # abiding by the rules of distribution of free software. You can use,
11 # modify and/ or redistribute the software under the terms of the CeCILL-B
12 # license as circulated by CEA, CNRS and INRIA at the following URL
13 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
14 # or in the file LICENSE.txt.
16 # As a counterpart to the access to the source code and rights to copy,
17 # modify and redistribute granted by the license, users are provided only
18 # with a limited warranty and the software's author, the holder of the
19 # economic rights, and the successive licensors have only limited
22 # The fact that you are presently reading this means that you have had
23 # knowledge of the CeCILL-B license and that you accept its terms.
24 # ------------------------------------------------------------------------ */
28 #include "ContourView.h"
31 // ----------------------------------------------------------------------------
32 // ----------------------------------------------------------------------------
33 // ----------------------------------------------------------------------------
35 ContourView::ContourView()
37 _wxvtkbaseview = NULL;
40 // ----------------------------------------------------------------------------
41 ContourView::~ContourView()
46 // ----------------------------------------------------------------------------
47 void ContourView::DeleteContours()
50 contour_mapped.clear();
51 contour_actor.clear();
54 // ----------------------------------------------------------------------------
55 void ContourView::SetWxVtkBaseView(wxVtkBaseView *wxvtkbaseview)
57 _wxvtkbaseview = wxvtkbaseview;
60 // ----------------------------------------------------------------------------
61 void ContourView::Refresh()
63 _wxvtkbaseview->GetRenWin()->Render();
66 // ----------------------------------------------------------------------------
67 void ContourView::CreateNewContour(vtkPolyData *contour, int type)
69 contour_mapped.push_back(vtkPolyDataMapper::New());
70 contour_mapped.back()->ImmediateModeRenderingOn();
71 contour_mapped.back()->ScalarVisibilityOff( );
72 contour_mapped.back()->SetInput(contour);
74 contour_actor.push_back(vtkActor::New());
75 contour_actor.back()->SetMapper(contour_mapped.back());
76 contour_actor.back()->GetProperty()->BackfaceCullingOff();
80 case ContourView::BLUE : contour_actor.back()->GetProperty()->SetDiffuseColor(0, 0, 1);
82 case ContourView::MAGENTA : contour_actor.back()->GetProperty()->SetDiffuseColor(1, 0, 1);
84 case ContourView::GREEN : contour_actor.back()->GetProperty()->SetDiffuseColor(0, 1, 0);
86 case ContourView::YELLOW : contour_actor.back()->GetProperty()->SetDiffuseColor(0, 1, 1);
88 default: contour_actor.back()->GetProperty()->SetDiffuseColor(0, 0, 1);
91 contour_actor.back()->GetProperty()->SetLineWidth(2);
92 contour_actor.back()->ApplyProperties();
94 _wxvtkbaseview->GetRenderer()->AddActor(contour_actor.back());
95 _wxvtkbaseview->GetRenWin()->Render();
98 // ----------------------------------------------------------------------------
99 void ContourView::DeleteVtkObjects()
101 int i,size=contour_mapped.size();
102 for (i=0;i<size; i++){
103 if ( contour_mapped[i] != NULL ) {
104 contour_mapped[i] -> Delete();
106 if ( contour_actor[i] != NULL ) {
107 _wxvtkbaseview->GetRenderer()->RemoveActor(contour_actor[i]);
108 contour_actor[i] -> Delete();
110 contour_actor[i] = NULL;
111 contour_mapped[i] = NULL;