GOFIGURE2  0.9.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
QGoMeshEditingWidgetManager.cxx
Go to the documentation of this file.
1 /*=========================================================================
2  Authors: The GoFigure Dev. Team.
3  at Megason Lab, Systems biology, Harvard Medical school, 2009-11
4 
5  Copyright (c) 2009-11, President and Fellows of Harvard College.
6  All rights reserved.
7 
8  Redistribution and use in source and binary forms, with or without
9  modification, are permitted provided that the following conditions are met:
10 
11  Redistributions of source code must retain the above copyright notice,
12  this list of conditions and the following disclaimer.
13  Redistributions in binary form must reproduce the above copyright notice,
14  this list of conditions and the following disclaimer in the documentation
15  and/or other materials provided with the distribution.
16  Neither the name of the President and Fellows of Harvard College
17  nor the names of its contributors may be used to endorse or promote
18  products derived from this software without specific prior written
19  permission.
20 
21  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
23  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
25  BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
26  OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
27  OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
28  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
30  OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
31  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 
33 =========================================================================*/
35 #include "QGoAlgorithmWidget.h"
36 #include "QGoAlgoParameter.h"
38 #include "vtkSmartPointer.h"
39 #include "vtkImageExport.h"
40 #include "vtkImageData.h"
41 #include <iostream>
42 
43 #include <QDebug>
44 
45 #include "QGoMeshWaterShedAlgo.h"
46 #include "GoImageProcessor.h"
47 
48 
50  std::vector<QString> iVectChannels,
51  int iTimeMin,
52  int iTimeMax,
53  std::vector< vtkPoints* >* iSeeds,
54  GoImageProcessor* iImages,
55  int* iCurrentTimePoint,
56  QWidget* iParent): QGoTraceEditingWidgetManager("Mesh",
57  iVectChannels, iTimeMin, iTimeMax, iSeeds, iImages,
58  iCurrentTimePoint, iParent)
59 {
60  this->SetSemiAutomaticAlgorithms(iParent);
61  this->SetSplitMergeMode(iVectChannels, this->m_ListTimePoint,iParent);
62  this->SetSetOfContoursAlgorithms(iVectChannels, this->m_ListTimePoint,
63  iParent);
64 }
65 //-------------------------------------------------------------------------
66 
67 //-------------------------------------------------------------------------
69 {
70 }
71 //-------------------------------------------------------------------------
72 
73 //-------------------------------------------------------------------------
75 {
77  if (this->m_SetOfContoursWidget != NULL)
78  {
80  tr("%1").arg(*this->m_CurrentTimePoint) );
81  }
82 }
83 //-------------------------------------------------------------------------
84 
85 //-------------------------------------------------------------------------
87  QHash<QString, QColor> iListTimePoints, int iChannelNumber)
88 {
90  iListTimePoints, iChannelNumber);
92  iListTimePoints, iChannelNumber);
93 }
94 //-------------------------------------------------------------------------
95 
96 //-------------------------------------------------------------------------
98 {
99  //level set:
100  m_LevelSetAlgo = new QGoMeshLevelSetAlgo(this->m_Seeds, iParent);
101  QGoAlgorithmWidget* LevelSetWidget = m_LevelSetAlgo->GetAlgoWidget();
103 
104  QObject::connect(LevelSetWidget, SIGNAL(ApplyAlgo() ),
105  this, SLOT(ApplyLevelSetAlgo() ) );
106 
107  //watershed:
108  this->m_WaterShedAlgo = new QGoMeshWaterShedAlgo(this->m_Seeds,
109  this->m_MaxThreshold,
110  iParent);
111  QGoAlgorithmWidget* WaterShedWidget = m_WaterShedAlgo->GetAlgoWidget();
113 
114  QObject::connect(WaterShedWidget, SIGNAL(ApplyAlgo() ),
115  this, SLOT(ApplyWaterShedAlgo() ) );
116 
117  //shape:
118  this->m_ShapeAlgo = new QGoMeshShapeAlgo(this->m_Seeds, iParent);
119  QGoAlgorithmWidget* ShapeWidget = this->m_ShapeAlgo->GetAlgoWidget();
121 
122  QObject::connect(ShapeWidget, SIGNAL(ApplyAlgo() ),
123  this, SLOT(ApplyShapeAlgo() ) );
124 }
125 //-------------------------------------------------------------------------
126 
127 //-------------------------------------------------------------------------
129  std::vector<QString> iVectChannels, QStringList iListTime,
130  QWidget* iParent)
131 {
132  // initialize the widget
134  new QGoAlgorithmsManagerWidget("Set of Contours",
135  iParent, iVectChannels, iListTime);
136 
137  this->SetTSliceForClassicView();
138 
140 
141  //watershed
144  this->m_MaxThreshold,
145  iParent);
146  QGoAlgorithmWidget* SetOfContoursWaterShedWidget =
148  this->m_SetOfContoursWidget->AddMethod(SetOfContoursWaterShedWidget);
149 
150  QObject::connect(SetOfContoursWaterShedWidget, SIGNAL(ApplyAlgo() ),
151  this, SLOT(ApplySetOfContoursWaterShedAlgo() ) );
152 
153  //levelset
155  new QGoSetOfContoursLevelSetAlgo(this->m_Seeds, iParent);
156  QGoAlgorithmWidget* SetOfContoursLevelSetWidget =
158  this->m_SetOfContoursWidget->AddMethod(SetOfContoursLevelSetWidget);
159 
160  QObject::connect(SetOfContoursLevelSetWidget, SIGNAL(ApplyAlgo() ),
161  this, SLOT(ApplySetOfContoursLevelSetAlgo() ) );
162 
163  //shape
165  new QGoSetOfContoursShapeAlgo(this->m_Seeds, iParent);
166  QGoAlgorithmWidget* SetOfContoursShapeWidget =
168  this->m_SetOfContoursWidget->AddMethod(SetOfContoursShapeWidget);
169 
170  QObject::connect(SetOfContoursShapeWidget, SIGNAL(ApplyAlgo() ),
171  this, SLOT(ApplySetOfContoursShapeAlgo() ) );
172 }
173 //-------------------------------------------------------------------------
174 
175 //-------------------------------------------------------------------------
177  std::vector<QString> iVectChannels, QStringList iListTime,
178  QWidget* iParent)
179 {
180  QGoAlgorithmsManagerWidget* SplitAlgoWidget =
181  new QGoAlgorithmsManagerWidget("Split", iParent, iVectChannels);
182  this->m_TraceEditingWidget->AddMode(SplitAlgoWidget, true);
183 
185  iParent);
186  QGoAlgorithmWidget * DanielWidget = m_DanielAlgo->GetAlgoWidget();
187 
188  SplitAlgoWidget->AddMethod(DanielWidget );
189 
190  QObject::connect( DanielWidget, SIGNAL(ApplyAlgo() ) ,
191  this, SLOT(RequestPolydatasForDanielsson() ) );
192 
193  QGoAlgorithmsManagerWidget* MergeAlgoWidget =
194  new QGoAlgorithmsManagerWidget("Merge", iParent, iVectChannels);
195  this->m_TraceEditingWidget->AddMode(MergeAlgoWidget, false);
196 
198  iParent);
199  QGoAlgorithmWidget * ConvexHullWidget = m_ConvexHullAlgo->GetAlgoWidget();
200 
201  MergeAlgoWidget->AddMethod(ConvexHullWidget );
202 
203  QObject::connect( ConvexHullWidget, SIGNAL(ApplyAlgo() ) ,
204  this, SLOT(RequestPolydatasForConvexHull() ) );
205 
206 }
207 //-------------------------------------------------------------------------
208 // required to setup the go reference to the algorithm we gonna use
209 //-------------------------------------------------------------------------
212  emit RequestPolydatas();
213 }
214 //-------------------------------------------------------------------------
215 // required to setup the go reference to the algorithm we gonna use
216 //-------------------------------------------------------------------------
219  emit RequestPolydatas();
220 }
221 //-------------------------------------------------------------------------
222 
223 //-------------------------------------------------------------------------
224 void
226 RequestedPolydatas(std::list< vtkPolyData* > iRequest){
227  // get mode
228  QString mode =
230  // create iterator
231  std::list< vtkPolyData*>::iterator iterator =
232  iRequest.begin();
233 
234  // in split mode
235  if(mode.compare("Split") == 0)
236  {
237  emit UpdateSeeds();
238 
239  // loop through all polydatas
240  while(iterator != iRequest.end())
241  {
242  // need vector for API
243  std::vector<vtkPolyData*> polys;
244  polys.push_back(*iterator);
245  std::vector<vtkPolyData*> NewTraces = m_TempReference->ApplyAlgo(
246  this->m_Images,
248  polys,
250  // need to send trace ID and time point...!
251  emit TracesSplittedFromAlgo(NewTraces);
252  ++iterator;
253  }
254 
255  emit ClearAllSeeds();
256  }
257  // merge mode
258  // give all pds at once
259  else
260  {
261  std::vector<vtkPolyData*> polys;
262 
263  // fill vector with all polydatas
264  while(iterator != iRequest.end())
265  {
266  polys.push_back(*iterator);
267  ++iterator;
268  }
269 
270  // apply algo
271  std::vector<vtkPolyData*> NewTraces = m_TempReference->ApplyAlgo(
272  this->m_Images,
274  polys,
276  emit TracesMergedFromAlgo(NewTraces.front());
277  }
278 }
279 //-------------------------------------------------------------------------
280 
281 //-------------------------------------------------------------------------
283 {
284  this->GetPolydatasFromAlgo<QGoMeshLevelSetAlgo>(this->m_LevelSetAlgo);
285 }
286 //-------------------------------------------------------------------------
287 
288 //-------------------------------------------------------------------------
290 {
291  this->GetPolydatasFromAlgo<QGoMeshShapeAlgo>(this->m_ShapeAlgo);
292 }
293 //-------------------------------------------------------------------------
294 
295 //-------------------------------------------------------------------------
297 {
298  this->GetPolydatasFromAlgo<QGoMeshWaterShedAlgo>(this->m_WaterShedAlgo);
299 }
300 //-------------------------------------------------------------------------
301 
302 //-------------------------------------------------------------------------
304 {
305  this->GetSetOfPolydatasFromAlgo<QGoSetOfContoursWaterShedAlgo>(
307 }
308 //-------------------------------------------------------------------------
309 
310 //-------------------------------------------------------------------------
312 {
313  this->GetSetOfPolydatasFromAlgo<QGoSetOfContoursLevelSetAlgo>(
315 }
316 //-------------------------------------------------------------------------
317 
318 //-------------------------------------------------------------------------
320 {
321  this->GetSetOfPolydatasFromAlgo<QGoSetOfContoursShapeAlgo>(
323 }
QGoMeshEditingWidgetManager(std::vector< QString > iVectChannels, int iTimeMin, int iTimeMax, std::vector< vtkPoints * > *iSeeds, GoImageProcessor *iImages, int *iCurrentTimePoint, QWidget *iParent=0)
class to be the interface between the shape algo for meshes and GoFigure
QGoSplitSegmentationAlgo * m_TempReference
class to be the interface between the QGoMeshMergeConvexHullAlgo algo for meshes and GoFigure ...
QGoTraceEditingWidget * m_TraceEditingWidget
std::string GetCurrentModeName()
return the name of the current mode in the combobox
QGoSetOfContoursShapeAlgo * m_SetOfContoursShapeAlgo
std::vector< vtkPoints * > * m_Seeds
QGoMeshSplitDanielssonDistanceAlgo * m_DanielAlgo
virtual void SetTSliceForDopplerView(QHash< QString, QColor > iListTimePoints, int iChannelNumber)
display the 3 timepoints chosen by the user in the TSlice comboboxes of the qgoalgomanagerwidgets, enable them, display only the channel tracked by the user and disable the channel comboboxes
QGoSetOfContoursLevelSetAlgo * m_SetOfContoursLevelSetAlgo
manages all the algorithms widget for a same mode, has a combobox with the name of the methods which ...
void RequestedPolydatas(std::list< vtkPolyData * >)
QString tr(const char *sourceText, const char *disambiguation, int n)
QGoSetOfContoursWaterShedAlgo * m_SetOfContoursWaterShedAlgo
abstract class to be the interface between the semi automatic algorithms for meshes and contours and ...
class to be the interface between the watershed algo for meshes and GoFigure
QString fromStdString(const std::string &str)
QGoMeshMergeConvexHullAlgo * m_ConvexHullAlgo
void AddAlgoWidgetForSemiAutomaticMode(QGoAlgorithmWidget *iAlgoWidget)
class to be the interface between the levelset algo for set of contours and GoFigure ...
virtual void SetSemiAutomaticAlgorithms(QWidget *iParent=0)
add the algowidget of the different algo in the algomanagerwidget for the semi automatic mode and set...
class to be the interface between the QGoMeshSplitDanielssonDistanceAlgo algo for meshes and GoFigure...
class to be the interface between the watershed algo for set of contours and GoFigure ...
QGoAlgorithmWidget * GetAlgoWidget()
return the algowidget
void SetTSliceForDopplerView(QHash< QString, QColor > iListTimePoints, int iChannelNumber)
display the 3 timepoints chosen by the user in the TSlice comboboxes of the qgoalgomanagerwidgets, enable them, display only the channel tracked by the user and disable the channel comboboxes
void SetTSliceForDopplerView(QHash< QString, QColor > iListTimePoints, int iIndexChannel)
void SetTSliceForClassicView()
display only the current timepoint in the TSlice comboboxes of the qgoalgomanagerwidgets, disable them and enable the channel comboboxes
Interface between image reader and vtkImageData.
virtual void SetTSliceForClassicView()
display only the current timepoint in the TSlice comboboxes of the qgoalgomanagerwidgets, disable them and enable the channel comboboxes
class to be the interface between the levelset algo for meshes and GoFigure
iterator begin()
virtual std::vector< vtkPolyData * > ApplyAlgo(GoImageProcessor *iImages, std::string iChannel, std::vector< vtkPolyData * > iPolyData, bool iIsInvertedOn=false)=0
return the vtkpolydata created by the algorithm
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
void SetSetOfContoursAlgorithms(std::vector< QString > iVectChannels, QStringList iListTime, QWidget *iParent=0)
void TracesMergedFromAlgo(vtkPolyData *iPolydata)
void SetTSliceForClassicView(QString iTimePoint)
int compare(const QString &other) const
void AddMode(std::string iModeName, QWidget *iModeWidget, bool ModeNeedSeeds)
add iModeWidget as a widget to be displayed when iModeName is selected in the combobox of m_ModeEditi...
void TracesSplittedFromAlgo(std::vector< vtkPolyData * > iVectPolydata)
void SetSplitMergeMode(std::vector< QString > iVectChannels, QStringList iListTime, QWidget *iParent=0)
abstract class handles the interactions between the user and the algorithms for one kind of trace ...
void AddMethod(QGoAlgorithmWidget *iAlgoWidget)
add a widget in the stacked layout with the name of the method associated in the combobox to display ...
QGoAlgorithmsManagerWidget * m_SetOfContoursWidget
class to be the interface between the shape algo for set of contours and GoFigure ...