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( );
74 //EED 2017-01-01 Migration VTK7
75 #if VTK_MAJOR_VERSION <= 5
76 contour_mapped.back()->SetInput(contour);
78 contour_mapped.back()->SetInputData(contour);
82 contour_actor.push_back(vtkActor::New());
83 contour_actor.back()->SetMapper(contour_mapped.back());
84 contour_actor.back()->GetProperty()->BackfaceCullingOff();
88 case ContourView::BLUE : contour_actor.back()->GetProperty()->SetDiffuseColor(0, 0, 1);
90 case ContourView::MAGENTA : contour_actor.back()->GetProperty()->SetDiffuseColor(1, 0, 1);
92 case ContourView::GREEN : contour_actor.back()->GetProperty()->SetDiffuseColor(0, 1, 0);
94 case ContourView::YELLOW : contour_actor.back()->GetProperty()->SetDiffuseColor(0, 1, 1);
96 default: contour_actor.back()->GetProperty()->SetDiffuseColor(0, 0, 1);
99 contour_actor.back()->GetProperty()->SetLineWidth(2);
100 contour_actor.back()->ApplyProperties();
102 _wxvtkbaseview->GetRenderer()->AddActor(contour_actor.back());
103 _wxvtkbaseview->GetRenWin()->Render();
106 // ----------------------------------------------------------------------------
107 void ContourView::DeleteVtkObjects()
109 int i,size=contour_mapped.size();
110 for (i=0;i<size; i++){
111 if ( contour_mapped[i] != NULL ) {
112 contour_mapped[i] -> Delete();
114 if ( contour_actor[i] != NULL ) {
115 _wxvtkbaseview->GetRenderer()->RemoveActor(contour_actor[i]);
116 contour_actor[i] -> Delete();
118 contour_actor[i] = NULL;
119 contour_mapped[i] = NULL;