]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/CutModule/kernel/CutModelManager.h
#3128 creaMaracasVisu Feature New Normal - branch changeWx28to30 compilation with...
[creaMaracasVisu.git] / lib / maracasVisuLib / src / CutModule / kernel / CutModelManager.h
1 /*# ---------------------------------------------------------------------
2 #
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
4 #                        pour la Sant�)
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
8 #
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.
15 #
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
20 #  liability.
21 #
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 # ------------------------------------------------------------------------ */
25
26 /*=========================================================================
27
28 Program:   wxMaracas
29 Module:    $RCSfile: CutModelManager.h,v $
30 Language:  C++
31 Date:      $Date: 2012/11/15 14:15:49 $
32 Version:   $Revision: 1.6 $
33
34 Copyright: (c) 2002, 2003
35 License:
36
37 This software is distributed WITHOUT ANY WARRANTY; without even 
38 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
39 PURPOSE.  See the above copyright notice for more information.
40
41 =========================================================================*/
42
43
44
45
46 #ifndef __CutModelManagerH__
47 #define __CutModelManagerH__
48
49 #include <iostream>
50 #include <stdio.h>
51 #include <vector>
52
53 #include "vtkImageData.h"
54 #include "vtkRenderWindowInteractor.h"
55 #include "vtkRenderer.h"
56 #include "wxVtkBaseView.h"
57 #include "wxVtk3DBaseView.h"
58 #include <vtkPolyDataWriter.h>
59
60 #include "CutModelException.h"
61 #include "CutModelData.h"
62 #include "CutModelSaveBinInfo.h"
63
64 #include "vtkPoints.h"
65 #include "CutModelPolygon.h"
66 #include "vtkInteractorStyleTrackballCamera.h"
67 #include "vtkInteractorStyleCutter.h"
68 #include "creawxVTKRenderWindowInteractor.h"
69 #include "vtkImplicitSelectionLoop.h"
70 #include "vtkPolyDataMapper.h"
71 #include "vtkSampleFunction.h"
72 #include "vtkContourFilter.h"
73 #include "vtkPolyData.h"
74 #include "vtkActor.h"
75
76
77
78 class CutModelManager  {
79
80 public:
81         CutModelManager(std::string path);
82         ~CutModelManager();
83
84         void setImageData(vtkImageData* img);
85
86         vtkImageData* getImageData();
87
88         void setInteractor(vtkRenderWindowInteractor* interactor);
89
90         void setRenderer(vtkRenderer* renderer);
91
92         void setBaseView(wxVtkBaseView* baseView);
93
94         void onAddCutModel(int id, vtkCommand* observer) throw( CutModelException);
95
96         double* getImageRange()throw( CutModelException);
97
98         void changeOpacity(int id,int opacity)throw( CutModelException);
99
100         void ShowViewBox(int id,bool check)throw( CutModelException);
101
102         void ChangeShape(int id,int selection)throw( CutModelException);
103
104         void changeColor(int id,double r,double g,double b)throw( CutModelException);
105
106         void updateActorDirection(int id)throw( CutModelException);
107
108         void RemoveActor(int id)throw( CutModelException);
109
110         void ExecuteCut(int id, double* range, bool isinside)throw( CutModelException);
111
112         vtkImageData* GetResultImage();
113
114         void RefreshActor(int id);
115
116         void SaveCutModelData(std::string filename)throw( CutModelException);
117
118         void LoadCutModelData(std::string filename)throw( CutModelException);
119
120         CutModelSaveBinInfo* AddActionUndo(int id, UNDOTYPE type)throw( CutModelException);
121
122         int Undo()throw( CutModelException);
123
124         int Redo()throw( CutModelException);
125
126         void ParallelProjectionOn();
127
128         void ParallelProjectionOff();
129
130         void UpdatePolygon(bool mode);
131
132         void ExecuteCutPolygon(bool inOutCut);
133
134         void InitializePolygonInteractorStyle();
135
136 private:
137
138         int _currentaction;
139
140         void checkInvariant() throw( CutModelException);
141         std::string _path;
142         vtkImageData* _img;
143         vtkImageData* _img2;
144         vtkRenderer* _render;
145         vtkRenderWindowInteractor* _interactor;
146
147         std::vector<CutModelData*> _vectordata;
148         std::vector<CutModelSaveBinInfo*> _undoredo;
149         CutModelData* getCutModelData(int id)throw( CutModelException);
150
151         CutModelPolygon* _polygonCutter;
152         vtkPoints *contourPoints ;
153         double *contourDirection;       
154         vtkInteractorStyleTrackballCamera *interactorstyle;
155         vtkInteractorStyleCutter *cutterstyle;
156         vtkContourFilter *contour;
157         vtkSampleFunction *sample;
158         vtkPolyData *actor;
159         vtkActor *actor3D;
160         vtkImplicitSelectionLoop *loop;
161         vtkPolyDataMapper *mapper;
162
163 };
164
165 #endif