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 # ------------------------------------------------------------------------ */
33 // ----------------------------------------------------------------------------
34 // ----------------------------------------------------------------------------
35 // ----------------------------------------------------------------------------
38 _wxvtkbaseview = NULL;
41 // ----------------------------------------------------------------------------
47 // ----------------------------------------------------------------------------
48 void LineView::DeleteLines()
51 contour_mapped.clear();
52 contour_actor.clear();
55 // ----------------------------------------------------------------------------
56 void LineView::SetWxVtkBaseView(wxVtkBaseView *wxvtkbaseview)
58 _wxvtkbaseview = wxvtkbaseview;
61 // ----------------------------------------------------------------------------
62 void LineView::Refresh()
64 _wxvtkbaseview->GetRenWin()->Render();
67 // ----------------------------------------------------------------------------
68 void LineView::CreateNewLine(double x1, double y1, double z1, double x2, double y2, double z2)
71 vtkPoints* pointsLine = vtkPoints::New();
72 vtkPolyLine* aLine = vtkPolyLine::New();
73 vtkUnstructuredGrid* aLineGrid = vtkUnstructuredGrid::New();
74 contour_mapped.push_back(vtkDataSetMapper::New());
75 contour_actor.push_back(vtkActor::New());
77 pointsLine->SetNumberOfPoints(2);
78 pointsLine->InsertPoint(0,x1,y1,z1);
79 pointsLine->InsertPoint(1,x2,y2,z2);
81 (aLine->GetPointIds())->SetNumberOfIds(2);
82 (aLine->GetPointIds())->SetId(0,0);
83 (aLine->GetPointIds())->SetId(1,1);
85 aLineGrid->Allocate(1,1);
86 aLineGrid->InsertNextCell(aLine->GetCellType(),aLine->GetPointIds());
87 aLineGrid->SetPoints(pointsLine);
89 //EED 2017-01-01 Migration VTK7
90 #if VTK_MAJOR_VERSION <= 5
91 contour_mapped.back()->SetInput(aLineGrid);
93 contour_mapped.back()->SetInputData(aLineGrid);
96 contour_mapped.back()->ImmediateModeRenderingOn();
98 contour_actor.back()->SetMapper(contour_mapped.back());
99 contour_actor.back()->GetProperty()->BackfaceCullingOn();
100 contour_actor.back()->GetProperty()->SetDiffuseColor(0, 0, 1);
101 contour_actor.back()->ApplyProperties();
103 _wxvtkbaseview->GetRenderer()->AddActor(contour_actor.back());
104 _wxvtkbaseview->GetRenWin()->Render();
108 // ----------------------------------------------------------------------------
109 void LineView::DeleteVtkObjects()
111 int i,size=contour_mapped.size();
112 for (i=0;i<size; i++){
113 if ( contour_mapped[i] != NULL ) {
114 contour_mapped[i] -> Delete();
116 if ( contour_actor[i] != NULL ) {
117 _wxvtkbaseview->GetRenderer()->RemoveActor(contour_actor[i]);
118 contour_actor[i] -> Delete();
120 contour_actor[i] = NULL;
121 contour_mapped[i] = NULL;