GOFIGURE2  0.9.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
QGoContourEditingWidgetManager.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 "GoImageProcessor.h"
39 
40 #include "vtkSmartPointer.h"
41 #include "vtkImageExport.h"
42 #include "vtkImageData.h"
43 #include <iostream>
44 
45 
47  std::vector<QString> iVectChannels,
48  int iTimeMin,
49  int iTimeMax,
50  std::vector< vtkPoints* >* iSeeds,
51  GoImageProcessor* iImages,
52  int* iCurrentTimePoint,
53  QWidget* iParent): QGoTraceEditingWidgetManager("Contour",
54  iVectChannels, iTimeMin, iTimeMax, iSeeds, iImages,
55  iCurrentTimePoint, iParent)
56 {
57  this->SetSemiAutomaticAlgorithms(iParent);
58  this->SetManualMode(this->m_ListTimePoint, iParent);
59 }
60 //-------------------------------------------------------------------------
61 
62 //-------------------------------------------------------------------------
64 {
65 }
66 //-------------------------------------------------------------------------
67 
68 //-------------------------------------------------------------------------
70  QStringList iListTimePoint, QWidget* iParent)
71 {
73 
75  iListTimePoint, false);
76 
78 
81  QColor, QColor) ),
82  this, SIGNAL(changeContourRepresentationProperty(float, QColor,
83  QColor, QColor) ) );
84 
86  SIGNAL (validateContour() ),
87  this, SLOT(ContourToValidate() ) );
88 
90  SIGNAL (reinitializeContour() ),
91  this, SIGNAL(reinitializeContour() ) );
92 
94  SIGNAL(SetSeedInteractorBehaviour(bool) ),
95  this,
96  SLOT(StartManualSegmentation(bool) ) );
97 
98 }
99 //-------------------------------------------------------------------------
100 
101 //-------------------------------------------------------------------------
103 {
104  // if current is
105  if(this->m_TraceEditingWidget->GetCurrentModeName().compare("Manual") == 0)
106  {
107  emit ManualSegmentationActivated( true );
108  }
109  else
110  {
111  emit ManualSegmentationActivated( false );
112  }
113 }
114 //-------------------------------------------------------------------------
115 
116 //-------------------------------------------------------------------------
118 {
119  int CurrentTimePoint = this->GetSelectedTimePoint(); //for test purpose
120  emit ContourValidated( CurrentTimePoint );
121 }
122 //-------------------------------------------------------------------------
123 
124 //-------------------------------------------------------------------------
126 {
127  //level set:
128  m_LevelSetAlgo = new QGoContourLevelSetAlgo(this->m_Seeds, iParent);
129  QGoAlgorithmWidget* LevelSetWidget = m_LevelSetAlgo->GetAlgoWidget();
131 
132  QObject::connect(LevelSetWidget, SIGNAL(ApplyAlgo() ),
133  this, SLOT(ApplyLevelSetAlgo() ) );
134 
135  /*//shape:
136  this->m_ShapeAlgo = new QGoMeshShapeAlgo(this->m_Seeds, iParent);
137  QGoAlgorithmWidget* ShapeWidget = this->m_ShapeAlgo->GetAlgoWidget();
138  this->m_TraceEditingWidget->AddAlgoWidgetForSemiAutomaticMode(ShapeWidget);
139 
140  QObject::connect(ShapeWidget, SIGNAL(ApplyAlgo() ),
141  this, SLOT(ApplyShapeAlgo() ) );
142 
143  //watershed:
144  this->m_WaterShedAlgo = new QGoMeshWaterShedAlgo(this->m_Seeds,
145 this->m_MaxThreshold, iParent);
146  QGoAlgorithmWidget* WaterShedWidget = m_WaterShedAlgo->GetAlgoWidget();
147  this->m_TraceEditingWidget->AddAlgoWidgetForSemiAutomaticMode(WaterShedWidget);
148 
149  QObject::connect(WaterShedWidget, SIGNAL(ApplyAlgo() ),
150  this, SLOT(ApplyWaterShedAlgo() ) );*/
151 }
152 //-------------------------------------------------------------------------
153 
154 //-------------------------------------------------------------------------
156 {
157  this->GetPolydatasFromAlgo<QGoContourLevelSetAlgo>(this->m_LevelSetAlgo);
158 }
159 //-------------------------------------------------------------------------
160 
161 //-------------------------------------------------------------------------
162 /*void QGoContourEditingWidgetManager::ApplyShapeAlgo()
163 {
164  this->GetPolydatasFromAlgo<QGoContourShapeAlgo>(this->m_ShapeAlgo);
165 }
166 //-------------------------------------------------------------------------
167 
168 //-------------------------------------------------------------------------
169 void QGoContourEditingWidgetManager::ApplyWaterShedAlgo()
170 {
171  this->GetPolydatasFromAlgo<QGoMeshWaterShedAlgo>(this->m_WaterShedAlgo);
172 }*/
173 //-------------------------------------------------------------------------
174 
175 //-------------------------------------------------------------------------
177 {
178  this->m_ManualMode->SetReeditMode(iReeditMode);
179 }
180 //-------------------------------------------------------------------------
181 
182 //-------------------------------------------------------------------------
184 {
185  return this->m_ManualMode->GetReeditMode();
186 }
187 //-------------------------------------------------------------------------
188 
189 //-------------------------------------------------------------------------
191 {
193 }
194 //-------------------------------------------------------------------------
195 
196 //-------------------------------------------------------------------------
198 {
200 
201  if (this->m_TraceEditingWidget->GetCurrentModeName() == "Manual")
202  {
203  emit ManualSegmentationActivated(isVisible);
204  }
205 }
virtual void SetSemiAutomaticAlgorithms(QWidget *iParent=0)
add the algowidget of the different algo in the algomanagerwidget for the semi automatic mode and set...
void SetReeditMode(bool iReeditMode)
Set the reedit mode.
Base class for contour manual segmentation.
QGoTraceEditingWidget * m_TraceEditingWidget
bool GetReeditMode()
Get the reedit mode.
void ContourValidated(int iTCoord)
void SetManualMode(QStringList iListTimePoint, QWidget *iParent)
std::string GetCurrentModeName()
return the name of the current mode in the combobox
std::vector< vtkPoints * > * m_Seeds
class to be the interface between the levelset algo for contours and GoFigure
void GenerateContourRepresentationProperties(bool iModified=false)
Generate the widget contour properties if it has been modified.
void AddWidgetForManualMode(QWidget *iWidget, QStringList iListTimePoint, bool ModeNeedSeeds)
QWidget * getWidget()
Get the base widget for the contour manual segmentation.
void changeContourRepresentationProperty(float iLinewidth, QColor iLinecolor, QColor iNodecolor, QColor iActivenodecolor)
void AddAlgoWidgetForSemiAutomaticMode(QGoAlgorithmWidget *iAlgoWidget)
void SetSeedInteractorBehaviour(bool enable)
emit true to get the seeds widget enabled and false to disable it
void SetVisible(bool isVisible)
show or hide the dockwidget and check the current selected mode in order to emit a signal to get the ...
void SetReeditMode(bool iReeditMode)
Set the reedit mode.
QGoContourManualSegmentation * m_ManualMode
int GetSelectedTimePoint()
return the selected timepoint in the TSlice combobox
void ContourToValidate()
slot called when the user clicks on &quot;validate&quot; for the manual mode
void StartManualSegmentation(bool iValue)
display only the current timepoint in the TSlice comboboxes of the qgoalgomanagerwidgets, disable them and enable the channel comboboxes
QGoAlgorithmWidget * GetAlgoWidget()
return the algowidget
Interface between image reader and vtkImageData.
QGoContourEditingWidgetManager(std::vector< QString > iVectChannels, int iTimeMin, int iTimeMax, std::vector< vtkPoints * > *iSeeds, GoImageProcessor *iImages, int *iCurrentTimePoint, QWidget *iParent=0)
virtual void SetTSliceForClassicView()
display only the current timepoint in the TSlice comboboxes of the qgoalgomanagerwidgets, disable them and enable the channel comboboxes
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
abstract class handles the interactions between the user and the algorithms for one kind of trace ...