Commit 1e240d0c authored by promayon's avatar promayon
Browse files

FIXED crash in debian continuous integration: please always delay...

FIXED crash in debian continuous integration: please always delay initialization in action::getWidget 


git-svn-id: svn+ssh://scm.forge.imag.fr/var/lib/gforge/chroot/scmrepos/svn/camitk/trunk/camitk@1973 ec899d31-69d1-42ba-9299-647d76f65fb3
parent 69a96ccd
...@@ -91,27 +91,25 @@ ReorientImage::ReorientImage(ActionExtension* extension) : Action(extension) { ...@@ -91,27 +91,25 @@ ReorientImage::ReorientImage(ActionExtension* extension) : Action(extension) {
lettersMeaning.insert('I', IMeaning); lettersMeaning.insert('I', IMeaning);
lettersMeaning.insert('S', SMeaning); lettersMeaning.insert('S', SMeaning);
// see initDialog
dialog = NULL; dialog = NULL;
// see buildAxes
axes = NULL; axes = NULL;
buildAxes();
// see buildCube
annotatedCube = NULL; annotatedCube = NULL;
buildCube();
orientationTransform = NULL; orientationTransform = NULL;
axesTransform = NULL; axesTransform = NULL;
orientationCubeTransform = NULL; orientationCubeTransform = NULL;
cubeTransform = NULL; cubeTransform = NULL;
buildTransforms();
// see buildGeometries for the 3D representation
internalViewer = NULL;
modelBoundingBox = NULL; modelBoundingBox = NULL;
maleModel = NULL; maleModel = NULL;
femaleModel = NULL; femaleModel = NULL;
buildGeometries();
internalViewer = NULL;
// these properties are for pipeline users to set parameters // these properties are for pipeline users to set parameters
Property * useMaleModel = new Property("Use Male Model", QVariant(true), tr("Use male or female model for image orientation illustration"), ""); Property * useMaleModel = new Property("Use Male Model", QVariant(true), tr("Use male or female model for image orientation illustration"), "");
...@@ -124,60 +122,25 @@ ReorientImage::ReorientImage(ActionExtension* extension) : Action(extension) { ...@@ -124,60 +122,25 @@ ReorientImage::ReorientImage(ActionExtension* extension) : Action(extension) {
// --------------- destructor ------------------- // --------------- destructor -------------------
ReorientImage::~ReorientImage() { ReorientImage::~ReorientImage() {
// internalViewer->getRendererWidget()->removeProp(femaleModel->getActor(InterfaceGeometry::Surface));
// internalViewer->getRendererWidget()->removeProp(maleModel->getActor(InterfaceGeometry::Surface));
// internalViewer->getRendererWidget()->removeProp(modelBoundingBox->getActor(InterfaceGeometry::Wireframe));
// internalViewer->getRendererWidget()->removeProp(axes);
// internalViewer->getRendererWidget()->removeProp(annotatedCube);
axes = NULL; axes = NULL;
annotatedCube = NULL; annotatedCube = NULL;
delete modelBoundingBox;
modelBoundingBox = NULL; modelBoundingBox = NULL;
delete femaleModel;
femaleModel = NULL; femaleModel = NULL;
delete maleModel;
maleModel = NULL; maleModel = NULL;
delete dialog;
if (dialog != NULL) { dialog = NULL;
delete dialog;
}
}
// --------------- buildGeometries -------------------
void ReorientImage::buildGeometries() {
// check for the CamiTK test data dir (not the first valid one, but the right one, i.e., the one that contains
// the VTK files needed for this action)
// => TODO use Qt resource files
QStringList testDataDirectories = Core::getInstallDirectories("share/" + QString(Core::shortVersion) + "/testdata");
int i=0;
bool foundVtkFiles=false;
QDir globalTestDir;
while (i<testDataDirectories.size() && !foundVtkFiles) {
globalTestDir = QDir(testDataDirectories.at(i));
foundVtkFiles = globalTestDir.exists("imageBoundingBox.vtk") && globalTestDir.exists("male.vtk") && globalTestDir.exists("female.vtk");
i++;
}
QString boundingBoxFilename = globalTestDir.canonicalPath() + "/imageBoundingBox.vtk";
modelBoundingBox = VtkMeshUtil::vtkToGeometry(boundingBoxFilename.toStdString());
modelBoundingBox->setRenderingModes(InterfaceGeometry::Wireframe);
QString maleModelFilename = globalTestDir.canonicalPath() + "/male.vtk";
maleModel = VtkMeshUtil::vtkToGeometry(maleModelFilename.toStdString());
maleModel->setColor(1.0, 0.75, 0.64);
QString femaleModelFilename = globalTestDir.canonicalPath() + "/female.vtk";
femaleModel = VtkMeshUtil::vtkToGeometry(femaleModelFilename.toStdString());
femaleModel->setColor(1.0, 0.75, 0.64);
} }
// --------------- initDialog ------------------- // --------------- initDialog -------------------
void ReorientImage::initDialog() { void ReorientImage::initDialog() {
dialog = new QDialog(); dialog = new QDialog();
//-- init user interface //-- init user interface
ui.setupUi(dialog); ui.setupUi(dialog);
//-- add the internal viewer //-- add the internal viewer
initInternalViewer(); initInternalViewer();
ui.illustrationLayout->addWidget(internalViewer->getWidget(dialog)); ui.illustrationLayout->addWidget(internalViewer->getWidget(dialog));
...@@ -204,7 +167,6 @@ void ReorientImage::initDialog() { ...@@ -204,7 +167,6 @@ void ReorientImage::initDialog() {
// Duplicate image // Duplicate image
ui.noNewImageCheckBox->setChecked(property("No New Image").toBool()); ui.noNewImageCheckBox->setChecked(property("No New Image").toBool());
// Set the Dicom RCS Labels Menu // Set the Dicom RCS Labels Menu
ui.rcsComboBox->addItems(ImageOrientationHelper::getPossibleImageOrientations()); ui.rcsComboBox->addItems(ImageOrientationHelper::getPossibleImageOrientations());
...@@ -225,17 +187,26 @@ void ReorientImage::showApplyButton(bool show) { ...@@ -225,17 +187,26 @@ void ReorientImage::showApplyButton(bool show) {
// --------------- initInternalViewer ------------------- // --------------- initInternalViewer -------------------
void ReorientImage::initInternalViewer() { void ReorientImage::initInternalViewer() {
// build the axes representation
buildAxes();
// build the cube around the 3D person
buildCube();
// initial the transformations
buildTransforms();
// get the nice vtk 3D representation from file
buildGeometries();
// Set up the 3D viewer to visualize actual origin/orientation locations // Set up the 3D viewer to visualize actual origin/orientation locations
internalViewer = InteractiveViewer::getNewViewer("Image Orientation Viewer", InteractiveViewer::GEOMETRY_VIEWER); internalViewer = InteractiveViewer::getNewViewer("Image Orientation Viewer", InteractiveViewer::GEOMETRY_VIEWER);
internalViewer->setHighlightMode(InteractiveViewer::OFF); internalViewer->setHighlightMode(InteractiveViewer::OFF);
internalViewer->toggleCopyright(false); internalViewer->toggleCopyright(false);
internalViewer->getRendererWidget()->setCameraOrientation(RendererWidget::RIGHT_DOWN); internalViewer->getRendererWidget()->setCameraOrientation(RendererWidget::RIGHT_DOWN);
internalViewer->getRendererWidget()->addProp(modelBoundingBox->getActor(InterfaceGeometry::Wireframe)); if (modelBoundingBox)
internalViewer->getRendererWidget()->addProp(modelBoundingBox->getActor(InterfaceGeometry::Wireframe));
internalViewer->getRendererWidget()->addProp(axes); internalViewer->getRendererWidget()->addProp(axes);
internalViewer->getRendererWidget()->addProp(annotatedCube); internalViewer->getRendererWidget()->addProp(annotatedCube);
} }
// --------------- rcsChanged ------------------- // --------------- rcsChanged -------------------
...@@ -253,6 +224,9 @@ void ReorientImage::rcsChanged(const QString index) { ...@@ -253,6 +224,9 @@ void ReorientImage::rcsChanged(const QString index) {
// --------------- modelChanged ------------------- // --------------- modelChanged -------------------
void ReorientImage::modelChanged(bool displayMaleModel) { void ReorientImage::modelChanged(bool displayMaleModel) {
if (femaleModel==NULL || maleModel==NULL)
return;
if (displayMaleModel) { if (displayMaleModel) {
internalViewer->getRendererWidget()->removeProp(femaleModel->getActor(InterfaceGeometry::Surface)); internalViewer->getRendererWidget()->removeProp(femaleModel->getActor(InterfaceGeometry::Surface));
internalViewer->getRendererWidget()->addProp(maleModel->getActor(InterfaceGeometry::Surface)); internalViewer->getRendererWidget()->addProp(maleModel->getActor(InterfaceGeometry::Surface));
...@@ -269,7 +243,6 @@ QWidget * ReorientImage::getWidget() { ...@@ -269,7 +243,6 @@ QWidget * ReorientImage::getWidget() {
if (!dialog) if (!dialog)
initDialog(); initDialog();
// rcsChanged("RAI");
ui.rcsComboBox->setCurrentIndex(0); ui.rcsComboBox->setCurrentIndex(0);
return dialog; return dialog;
...@@ -380,6 +353,7 @@ Action::ApplyStatus ReorientImage::process( ImageComponent * image) { ...@@ -380,6 +353,7 @@ Action::ApplyStatus ReorientImage::process( ImageComponent * image) {
return SUCCESS; return SUCCESS;
} }
// --------------- buildAxes ------------------- // --------------- buildAxes -------------------
void ReorientImage::buildAxes() { void ReorientImage::buildAxes() {
//-- axes //-- axes
...@@ -462,6 +436,41 @@ void ReorientImage::buildCube() { ...@@ -462,6 +436,41 @@ void ReorientImage::buildCube() {
acProp->SetInterpolationToFlat(); acProp->SetInterpolationToFlat();
} }
// --------------- buildGeometries -------------------
void ReorientImage::buildGeometries() {
// check for the CamiTK test data dir (not the first valid one, but the right one, i.e., the one that contains
// the VTK files needed for this action)
// => TODO use Qt resource files
QStringList testDataDirectories = Core::getInstallDirectories("share/" + QString(Core::shortVersion) + "/testdata");
int i=0;
bool foundVtkFiles=false;
QDir globalTestDir;
while (i<testDataDirectories.size() && !foundVtkFiles) {
globalTestDir = QDir(testDataDirectories.at(i));
foundVtkFiles = globalTestDir.exists("imageBoundingBox.vtk") && globalTestDir.exists("male.vtk") && globalTestDir.exists("female.vtk");
i++;
}
if (foundVtkFiles) {
QString boundingBoxFilename = globalTestDir.canonicalPath() + "/imageBoundingBox.vtk";
modelBoundingBox = VtkMeshUtil::vtkToGeometry(boundingBoxFilename.toStdString());
modelBoundingBox->setRenderingModes(InterfaceGeometry::Wireframe);
QString maleModelFilename = globalTestDir.canonicalPath() + "/male.vtk";
maleModel = VtkMeshUtil::vtkToGeometry(maleModelFilename.toStdString());
maleModel->setColor(1.0, 0.75, 0.64);
QString femaleModelFilename = globalTestDir.canonicalPath() + "/female.vtk";
femaleModel = VtkMeshUtil::vtkToGeometry(femaleModelFilename.toStdString());
femaleModel->setColor(1.0, 0.75, 0.64);
}
else {
CAMITK_WARNING("ReorientImage", "buildGeometries", "3D Model VTK files not found");
}
}
// --------------- buildTransforms ------------------- // --------------- buildTransforms -------------------
void ReorientImage::buildTransforms() { void ReorientImage::buildTransforms() {
axesTransform = vtkSmartPointer<vtkTransform>::New(); axesTransform = vtkSmartPointer<vtkTransform>::New();
......
...@@ -104,17 +104,17 @@ ...@@ -104,17 +104,17 @@
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../../ReorientImage.cpp" line="117"/> <location filename="../../ReorientImage.cpp" line="115"/>
<source>Use male or female model for image orientation illustration</source> <source>Use male or female model for image orientation illustration</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../../ReorientImage.cpp" line="119"/> <location filename="../../ReorientImage.cpp" line="117"/>
<source>Reset the image frame so that the transform origin and the original origin are the same</source> <source>Reset the image frame so that the transform origin and the original origin are the same</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../../ReorientImage.cpp" line="121"/> <location filename="../../ReorientImage.cpp" line="119"/>
<source>Do not create a new re-oriented image, but apply the transformations on the input image.</source> <source>Do not create a new re-oriented image, but apply the transformations on the input image.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
......
...@@ -104,17 +104,17 @@ ...@@ -104,17 +104,17 @@
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../../ReorientImage.cpp" line="117"/> <location filename="../../ReorientImage.cpp" line="115"/>
<source>Use male or female model for image orientation illustration</source> <source>Use male or female model for image orientation illustration</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../../ReorientImage.cpp" line="119"/> <location filename="../../ReorientImage.cpp" line="117"/>
<source>Reset the image frame so that the transform origin and the original origin are the same</source> <source>Reset the image frame so that the transform origin and the original origin are the same</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../../ReorientImage.cpp" line="121"/> <location filename="../../ReorientImage.cpp" line="119"/>
<source>Do not create a new re-oriented image, but apply the transformations on the input image.</source> <source>Do not create a new re-oriented image, but apply the transformations on the input image.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
......
...@@ -122,7 +122,7 @@ ...@@ -122,7 +122,7 @@
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../../VtkImageComponentExtension.cpp" line="163"/> <location filename="../../VtkImageComponentExtension.cpp" line="165"/>
<source>Cannot save file: unrecognized extension &quot;.</source> <source>Cannot save file: unrecognized extension &quot;.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
......
...@@ -122,7 +122,7 @@ ...@@ -122,7 +122,7 @@
<translation>Gérer n&apos;importe quel type de fichier supporté par vtk dans &lt;b&gt;CamiTK&lt;/b&gt;</translation> <translation>Gérer n&apos;importe quel type de fichier supporté par vtk dans &lt;b&gt;CamiTK&lt;/b&gt;</translation>
</message> </message>
<message> <message>
<location filename="../../VtkImageComponentExtension.cpp" line="163"/> <location filename="../../VtkImageComponentExtension.cpp" line="165"/>
<source>Cannot save file: unrecognized extension &quot;.</source> <source>Cannot save file: unrecognized extension &quot;.</source>
<translation>Ne peut pas sauver le fichier : extension non reconnu &quot;.</translation> <translation>Ne peut pas sauver le fichier : extension non reconnu &quot;.</translation>
</message> </message>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment