GOFIGURE2  0.9.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
QGoTraceEditingWidgetManager.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 "GoImageProcessor.h"
44 
45 
47  std::string iTraceName,
48  std::vector<QString> iVectChannels,
49  int iTimeMin,
50  int iTimeMax,
51  std::vector< vtkPoints* >* iSeeds,
52  GoImageProcessor* iImages,
53  int* iCurrentTimePoint,
54  QWidget* iParent)
55 {
56  this->m_TraceName = iTraceName;
57  this->m_Seeds = iSeeds;
58  this->m_Images = iImages;
59  this->m_CurrentTimePoint = iCurrentTimePoint;
60 
61  this->m_MaxThreshold = iImages->getMaxImage();
62 
63  this->SetTheTraceWidget(iVectChannels, iTimeMin, iTimeMax, iParent);
64  this->SetTheDockWidget(iParent);
65 
66 }
67 //-------------------------------------------------------------------------
68 
69 //-------------------------------------------------------------------------
71 {
72 }
73 //-------------------------------------------------------------------------
74 
75 //-------------------------------------------------------------------------
77  std::vector<QString> iVectChannels, int iTimeMin,
78  int iTimeMax, QWidget* iParent)
79 {
80 
81  QStringList ListTimePoints;
82  for (int i = iTimeMin; i < iTimeMax+1; ++i)
83  {
84  ListTimePoints.push_back(tr("%1").arg(i));
85  }
86  this->m_ListTimePoint = ListTimePoints;
87 
89  this->m_TraceName.c_str(), iVectChannels, ListTimePoints, iParent);
90 
92  SIGNAL(SetSeedInteractorBehaviour(bool) ),
93  this,
94  SIGNAL(SetSeedInteractorBehaviour(bool) ) );
95 
97  SIGNAL(ResetClicked() ),
98  this, SIGNAL(ClearAllSeeds() ) );
99 }
100 //-------------------------------------------------------------------------
101 
102 //-------------------------------------------------------------------------
104 {
105 
106  this->m_TraceEditingDockWidget = new QGoDockWidget(iParent);
107  std::string WindowTitle = this->m_TraceName;
108  WindowTitle += " Editing";
109  this->m_TraceEditingDockWidget->setWindowTitle(WindowTitle.c_str());
111 
112  QIcon TraceSegmentationIcon;
113  std::string PathIcon = ":/fig/";
114  PathIcon += this->m_TraceName;
115  PathIcon += "Editing.png";
116 
117  TraceSegmentationIcon.addPixmap(QPixmap( QString::fromUtf8(PathIcon.c_str() ) ),
118  QIcon::Normal, QIcon::Off);
119 
120  this->m_TraceEditingDockWidget->toggleViewAction()->setIcon(TraceSegmentationIcon);
121  this->m_TraceEditingDockWidget->toggleViewAction()->setToolTip( tr("%1 Editing").arg(this->m_TraceName.c_str() ) );
123  tr("Create %1s manually, semi-automatically or automatically").arg(this->m_TraceName.c_str() ) );
124 }
125 //-------------------------------------------------------------------------
126 
127 //-------------------------------------------------------------------------
129 {
131 }
132 //-------------------------------------------------------------------------
133 
134 //-------------------------------------------------------------------------
136 {
137  return this->m_TraceEditingDockWidget;
138 }
139 //-------------------------------------------------------------------------
140 
141 //-------------------------------------------------------------------------
143 {
144  this->m_TraceEditingDockWidget->setVisible(isVisible);
145  this->m_TraceEditingWidget->CheckTheCurrentMode(isVisible);
146 }
147 //-------------------------------------------------------------------------
148 
149 //-------------------------------------------------------------------------
151 {
153  *this->m_CurrentTimePoint);
154 }
155 //-------------------------------------------------------------------------
156 
157 //-------------------------------------------------------------------------
159  QHash<QString, QColor> iListTimePoints, int iChannelNumber)
160 {
162  iListTimePoints, iChannelNumber);
163 }
164 //-------------------------------------------------------------------------
165 
166 //-------------------------------------------------------------------------
168 {
170 }
171 //-------------------------------------------------------------------------
172 
173 //-------------------------------------------------------------------------
174 /*void QGoMeshEditingWidgetManager::SetSemiAutomaticAlgorithms(QWidget* iParent)
175 {
176  //level set:
177  m_LevelSetAlgo = new QGoMeshLevelSetAlgo(this->m_Seeds, iParent);
178  QGoAlgorithmWidget* LevelSetWidget = m_LevelSetAlgo->GetAlgoWidget();
179  this->m_MeshEditingWidget->AddAlgoWidgetForSemiAutomaticMode(LevelSetWidget);
180 
181  QObject::connect(LevelSetWidget, SIGNAL(ApplyAlgo() ),
182  this, SLOT(ApplyLevelSetAlgo() ) );
183 
184  //shape:
185  this->m_ShapeAlgo = new QGoMeshShapeAlgo(this->m_Seeds, iParent);
186  QGoAlgorithmWidget* ShapeWidget = this->m_ShapeAlgo->GetAlgoWidget();
187  this->m_MeshEditingWidget->AddAlgoWidgetForSemiAutomaticMode(ShapeWidget);
188 
189  QObject::connect(ShapeWidget, SIGNAL(ApplyAlgo() ),
190  this, SLOT(ApplyShapeAlgo() ) );
191 
192  //watershed:
193  this->m_WaterShedAlgo = new QGoMeshWaterShedAlgo(this->m_Seeds, iParent);
194  QGoAlgorithmWidget* WaterShedWidget = m_WaterShedAlgo->GetAlgoWidget();
195  this->m_MeshEditingWidget->AddAlgoWidgetForSemiAutomaticMode(WaterShedWidget);
196 
197  QObject::connect(WaterShedWidget, SIGNAL(ApplyAlgo() ),
198  this, SLOT(ApplyWaterShedAlgo() ) );
199 }
200 //-------------------------------------------------------------------------
201 
202 //-------------------------------------------------------------------------
203 void QGoMeshEditingWidgetManager::SetSetOfContoursAlgorithms(
204  std::vector<QString> iVectChannels, QStringList iListTime,
205  QWidget* iParent)
206 {
207  m_SetOfContoursWidget =
208  new QGoAlgorithmsManagerWidget("Set of Contours",
209  iParent, iVectChannels, iListTime);
210 
211  this->m_SetOfContoursWaterShedAlgo =
212  new QGoSetOfContoursWaterShedAlgo(this->m_Seeds, iParent);
213  QGoAlgorithmWidget* SetOfContoursWaterShedWidget =
214  this->m_SetOfContoursWaterShedAlgo->GetAlgoWidget();
215  this->m_SetOfContoursWidget->AddMethod(SetOfContoursWaterShedWidget);
216 
217  this->m_SetOfContoursLevelSetAlgo =
218  new QGoSetOfContoursLevelSetAlgo(this->m_Seeds, iParent);
219  QGoAlgorithmWidget* SetOfContoursLevelSetWidget =
220  this->m_SetOfContoursLevelSetAlgo->GetAlgoWidget();
221  this->m_SetOfContoursWidget->AddMethod(SetOfContoursLevelSetWidget);
222 
223  this->m_SetOfContoursShapeAlgo =
224  new QGoSetOfContoursShapeAlgo(this->m_Seeds, iParent);
225  QGoAlgorithmWidget* SetOfContoursShapeWidget =
226  this->m_SetOfContoursShapeAlgo->GetAlgoWidget();
227  this->m_SetOfContoursWidget->AddMethod(SetOfContoursShapeWidget);
228 
229  this->m_MeshEditingWidget->AddMode(m_SetOfContoursWidget, true);
230 
231  QObject::connect(SetOfContoursWaterShedWidget, SIGNAL(ApplyAlgo() ),
232  this, SLOT(ApplySetOfContoursWaterShedAlgo() ) );
233 
234  QObject::connect(SetOfContoursLevelSetWidget, SIGNAL(ApplyAlgo() ),
235  this, SLOT(ApplySetOfContoursLevelSetAlgo() ) );
236 
237  QObject::connect(SetOfContoursShapeWidget, SIGNAL(ApplyAlgo() ),
238  this, SLOT(ApplySetOfContoursShapeAlgo() ) );
239 
240 
241 }
242 //-------------------------------------------------------------------------
243 
244 //-------------------------------------------------------------------------
245 void QGoMeshEditingWidgetManager::SetSplitMergeMode(QWidget* iParent)
246 {
247  QGoAlgorithmsManagerWidget* SplitAlgoWidget =
248  new QGoAlgorithmsManagerWidget("Split", iParent);
249  this->m_MeshEditingWidget->AddMode(SplitAlgoWidget, true);
250 
251  m_DanielAlgo = new QGoMeshSplitDanielssonDistanceAlgo(iParent);
252  QGoAlgorithmWidget * DanielWidget = m_DanielAlgo->GetAlgoWidget();
253  SplitAlgoWidget->AddMethod(DanielWidget );
254 
255  QObject::connect( DanielWidget, SIGNAL(ApplyAlgo() ) ,
256  this, SLOT(ApplyDanielAlgo() ) );
257 
258  QGoAlgorithmsManagerWidget* MergeAlgoWidget =
259  new QGoAlgorithmsManagerWidget("Merge", iParent);
260  this->m_MeshEditingWidget->AddMode(MergeAlgoWidget, true);
261 
262 }
263 //-------------------------------------------------------------------------
264 
265 //-------------------------------------------------------------------------
266 void QGoMeshEditingWidgetManager::ApplyDanielAlgo()
267 {
268  this->GetPolydatasFromAlgo<QGoMeshSplitDanielssonDistanceAlgo>(this->m_DanielAlgo);
269 }
270 //-------------------------------------------------------------------------
271 
272 //-------------------------------------------------------------------------
273 void QGoMeshEditingWidgetManager::ApplyLevelSetAlgo()
274 {
275  this->GetPolydatasFromAlgo<QGoMeshLevelSetAlgo>(this->m_LevelSetAlgo);
276 }
277 //-------------------------------------------------------------------------
278 
279 //-------------------------------------------------------------------------
280 void QGoMeshEditingWidgetManager::ApplyShapeAlgo()
281 {
282  this->GetPolydatasFromAlgo<QGoMeshShapeAlgo>(this->m_ShapeAlgo);
283 }
284 //-------------------------------------------------------------------------
285 
286 //-------------------------------------------------------------------------
287 void QGoMeshEditingWidgetManager::ApplyWaterShedAlgo()
288 {
289  this->GetPolydatasFromAlgo<QGoMeshWaterShedAlgo>(this->m_WaterShedAlgo);
290 }
291 //-------------------------------------------------------------------------
292 
293 //-------------------------------------------------------------------------
294 void QGoMeshEditingWidgetManager::ApplySetOfContoursWaterShedAlgo()
295 {
296  this->GetSetOfPolydatasFromAlgo<QGoSetOfContoursWaterShedAlgo>(
297  this->m_SetOfContoursWaterShedAlgo);
298 }
299 //-------------------------------------------------------------------------
300 
301 //-------------------------------------------------------------------------
302 void QGoMeshEditingWidgetManager::ApplySetOfContoursLevelSetAlgo()
303 {
304  this->GetSetOfPolydatasFromAlgo<QGoSetOfContoursLevelSetAlgo>(
305  this->m_SetOfContoursLevelSetAlgo);
306 }
307 //-------------------------------------------------------------------------
308 
309 //-------------------------------------------------------------------------
310 void QGoMeshEditingWidgetManager::ApplySetOfContoursShapeAlgo()
311 {
312  this->GetSetOfPolydatasFromAlgo<QGoSetOfContoursShapeAlgo>(
313  this->m_SetOfContoursShapeAlgo);
314 }*/
QAction * toggleViewAction()
QGoTraceEditingWidget * m_TraceEditingWidget
void push_back(const T &value)
void setIcon(const QIcon &icon)
std::vector< vtkPoints * > * m_Seeds
virtual void setVisible(bool visible)
void SetTheTraceWidget(std::vector< QString > iVectChannels, int iTimeMin, int iTimeMax, QWidget *iParent)
void SetTSliceForClassicView(int iTimePoint)
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
QString tr(const char *sourceText, const char *disambiguation, int n)
void setToolTip(const QString &tip)
QString fromUtf8(const char *str, int size)
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 addPixmap(const QPixmap &pixmap, Mode mode, State state)
QGoTraceEditingWidgetManager(std::string iTraceName, std::vector< QString > iVectChannels, int iTimeMin, int iTimeMax, std::vector< vtkPoints * > *iSeeds, GoImageProcessor *iImages, int *iCurrentTimePoint, QWidget *iParent=0)
int GetSelectedTimePoint()
return the selected timepoint in the TSlice combobox
void setWidget(QWidget *widget)
void SetTSliceForDopplerView(QHash< QString, QColor > iListTimePoints, int iChannelNumber)
void setStatusTip(const QString &statusTip)
void setWindowTitle(const QString &)
void CheckTheCurrentMode(bool IsVisible)
check which mode is selected and if the seeds are needed or not and emit the corresponding signals ba...
inherits from Qt QDockWidget.toggle action reimplemented in order the state is saved when changing ta...
Definition: QGoDockWidget.h:47
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
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)