Skip to content

Commit

Permalink
Fix: contour crashing on new VTK version. Installer files.
Browse files Browse the repository at this point in the history
  • Loading branch information
FelixdelasPozas committed Aug 19, 2019
1 parent 45a2a1d commit 3d740c2
Show file tree
Hide file tree
Showing 18 changed files with 196 additions and 47 deletions.
6 changes: 6 additions & 0 deletions AxesRender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ AxesRender::~AxesRender()
m_renderer->RemoveActor(m_planesActors[i]);
m_renderer->RemoveActor(m_crossActors[i]);
}

m_crossActors.clear();
m_planesActors.clear();
m_POILines.clear();
m_planes.clear();
m_renderer = nullptr;
}
}

Expand Down
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ PROJECT(EspinaVolumeEditor)
# Version Number
set (ESPINAEDITOR_VERSION_MAJOR 2)
set (ESPINAEDITOR_VERSION_MINOR 0)
set (ESPINAEDITOR_VERSION_PATCH 0)
set (ESPINAEDITOR_VERSION_PATCH 1)

# Find includes in corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)
Expand All @@ -32,6 +32,7 @@ endif (CMAKE_BUILD_TYPE MATCHES Debug)

if(DEFINED MINGW)
configure_file("${PROJECT_SOURCE_DIR}/EspinaEditor.rc.in" "${PROJECT_BINARY_DIR}/EspinaEditor.rc")
configure_file("${PROJECT_SOURCE_DIR}/installer/script.iss.in" "${PROJECT_BINARY_DIR}/script.iss")
set(RC_FILE ${CMAKE_CURRENT_BINARY_DIR}/ESPINAEDITOR.rc)
set(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> -O coff -o <OBJECT> -i <SOURCE>")
enable_language(RC)
Expand Down
9 changes: 6 additions & 3 deletions ContourRepresentationGlyph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,10 @@ ContourRepresentationGlyph::ContourRepresentationGlyph()
this->Mapper->SetInputData(this->Glypher->GetOutput());
this->Mapper->SetResolveCoincidentTopologyToPolygonOffset();
this->Mapper->ScalarVisibilityOff();
this->Mapper->ImmediateModeRenderingOn();

this->ActiveMapper->SetInputData(this->ActiveGlypher->GetOutput());
this->ActiveMapper->SetResolveCoincidentTopologyToPolygonOffset();
this->ActiveMapper->ScalarVisibilityOff();
this->ActiveMapper->ImmediateModeRenderingOn();

// Set up the initial properties
this->SetDefaultProperties();
Expand Down Expand Up @@ -231,6 +229,12 @@ void ContourRepresentationGlyph::SetRenderer(vtkRenderer *ren)
///////////////////////////////////////////////////////////////////////////////////////////////////
int ContourRepresentationGlyph::ComputeInteractionState(int X, int Y, int vtkNotUsed(modified))
{
if(this->FocalPoint->GetNumberOfPoints() == 0)
{
this->InteractionState = ContourRepresentation::Outside;
return this->InteractionState;
}

double pos[4];
this->FocalPoint->GetPoint(0, pos);
pos[3] = 1.0;
Expand Down Expand Up @@ -921,7 +925,6 @@ void ContourRepresentationGlyph::CreateSelectedNodesRepresentation()
this->SelectedNodesMapper->SetInputData(this->SelectedNodesGlypher->GetOutput());
this->SelectedNodesMapper->SetResolveCoincidentTopologyToPolygonOffset();
this->SelectedNodesMapper->ScalarVisibilityOff();
this->SelectedNodesMapper->ImmediateModeRenderingOn();

auto selectionProperty = vtkSmartPointer<vtkProperty>::New();
selectionProperty->SetColor(0.0, 1.0, 0.0);
Expand Down
8 changes: 5 additions & 3 deletions ContourWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ void ContourWidget::SelectAction(vtkAbstractWidget *widget)
auto Y = self->Interactor->GetEventPosition()[1];

self->WidgetRep->ComputeInteractionState(X, Y);
auto state = self->WidgetRep->GetInteractionState();
auto state = rep->GetInteractionState();
self->SetCursor(state);

double pos[2]{static_cast<double>(X), static_cast<double>(Y)};
Expand Down Expand Up @@ -218,12 +218,12 @@ void ContourWidget::SelectAction(vtkAbstractWidget *widget)
if (pressedKeys & Qt::ShiftModifier)
{
self->DeleteAction(widget);
state = self->WidgetRep->GetInteractionState();
state = rep->GetInteractionState();
self->SetCursor(state);
break;
}

if (self->WidgetRep->GetInteractionState() == ContourRepresentation::Inside)
if (rep->GetInteractionState() == ContourRepresentation::Inside)
{
self->TranslateContourAction(widget);
break;
Expand Down Expand Up @@ -252,6 +252,8 @@ void ContourWidget::SelectAction(vtkAbstractWidget *widget)
}
break;
}
default:
break;
}

if (rep->GetNeedToRender())
Expand Down
5 changes: 5 additions & 0 deletions DataManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@ DataManager::~DataManager()
it.second = nullptr;
}
ActionInformationVector.clear();

m_labelMap = nullptr;
m_structuredPoints = nullptr;
m_lookupTable = nullptr;

}

//////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down
10 changes: 4 additions & 6 deletions Editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@

int main(int argc, char * argv[])
{
auto app = new QApplication(argc, argv);
auto editor = new EspinaVolumeEditor(app);
QApplication app(argc, argv);
EspinaVolumeEditor editor(&app);
editor.showMaximized();

editor->showMaximized();
app->exec();

delete editor;
return app.exec();
}
18 changes: 14 additions & 4 deletions EditorOperations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
#include <vtkImageToImageStencil.h>
#include <vtkDiscreteMarchingCubes.h>
#include <vtkDecimatePro.h>
#include <vtkVolumeTextureMapper3D.h>
#include <vtkColorTransferFunction.h>
#include <vtkPiecewiseFunction.h>
#include <vtkVolumeProperty.h>
Expand Down Expand Up @@ -903,19 +902,21 @@ void EditorOperations::SetSliceViews(std::shared_ptr<SliceVisualization> axial,
std::shared_ptr<SliceVisualization> coronal,
std::shared_ptr<SliceVisualization> sagittal)
{
m_selection->setSliceViews(axial, coronal, sagittal);
if(m_selection) m_selection->setSliceViews(axial, coronal, sagittal);
}

///////////////////////////////////////////////////////////////////////////////////////////////////
void EditorOperations::ClearSelection(void)
{
m_selection->clear();
if(m_selection) m_selection->clear();
}

///////////////////////////////////////////////////////////////////////////////////////////////////
Selection::Type EditorOperations::GetSelectionType(void) const
{
return m_selection->type();
if(m_selection) return m_selection->type();

return Selection::Type::EMPTY;
}

///////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -981,3 +982,12 @@ void EditorOperations::Erase(const std::set<unsigned short> labels)
m_dataManager->SignalDataAsModified();
}
}

///////////////////////////////////////////////////////////////////////////////////////////////////
EditorOperations::~EditorOperations()
{
m_orientation = nullptr;
m_dataManager = nullptr;
m_selection = nullptr;
m_progress = nullptr;
}
5 changes: 5 additions & 0 deletions EditorOperations.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ class EditorOperations
*/
explicit EditorOperations(std::shared_ptr<DataManager> dataManager);

/** \brief EditorOperations class destructor.
*
*/
~EditorOperations();

/** \brief Initializes the class.
* \param[in] renderer view's renderer.
* \param[in] coordinates image orientation data.
Expand Down
27 changes: 27 additions & 0 deletions EspinaVolumeEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,31 @@ EspinaVolumeEditor::EspinaVolumeEditor(QApplication *app, QWidget *parent)
EspinaVolumeEditor::~EspinaVolumeEditor()
{
removeSessionFiles();

m_dataManager = nullptr;
m_editorOperations = nullptr;
m_progress = nullptr;

for(auto view: {m_axialRenderer, m_coronalRenderer, m_sagittalRenderer, m_volumeRenderer})
{
vtkProp *actor = nullptr;
while(actor = view->GetViewProps()->GetNextProp())
{
view->RemoveViewProp(actor);
}
}

m_axesWidget = nullptr;
m_axialRenderer = nullptr;
m_coronalRenderer = nullptr;
m_sagittalRenderer = nullptr;
m_volumeRenderer = nullptr;
m_axesRender = nullptr;
m_axialView = nullptr;
m_coronalView = nullptr;
m_sagittalView = nullptr;
m_volumeView = nullptr;
m_connections = nullptr;
}

///////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -934,6 +959,8 @@ void EspinaVolumeEditor::save()
///////////////////////////////////////////////////////////////////////////////////////////////////
void EspinaVolumeEditor::exit()
{
if(m_editorOperations) m_editorOperations->ClearSelection();

QApplication::exit();
}

Expand Down
9 changes: 8 additions & 1 deletion ProgressAccumulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void ProgressAccumulator::SetProgressBar(QProgressBar *bar)
m_ITKCommand = ITKCommandType::New();
m_ITKCommand->SetCallbackFunction(this, &ProgressAccumulator::ITKProcessEvent);

m_VTKCommand = VTKCommandType::New();
m_VTKCommand = vtkSmartPointer<VTKCommandType>::New();
m_VTKCommand->SetCallback(&ProgressAccumulator::VTKProcessEvent);
m_VTKCommand->SetClientData(this);

Expand Down Expand Up @@ -281,3 +281,10 @@ void ProgressAccumulator::ManualReset(bool calledFromThread)
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
}
}

///////////////////////////////////////////////////////////////////////////////////////////////////
ProgressAccumulator::~ProgressAccumulator()
{
m_ITKCommand = nullptr;
m_VTKCommand = nullptr;
}
5 changes: 5 additions & 0 deletions ProgressAccumulator.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ class ProgressAccumulator
*/
ProgressAccumulator();

/** \brief ProgressAccumulator class destructor.
*
*/
~ProgressAccumulator();

/** \brief Sets the progress bar that this class will use.
* \param[in] bar progress bar used by accumulator.
* \param[in] label label of the bar.
Expand Down
2 changes: 1 addition & 1 deletion QtAbout.ui
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
</font>
</property>
<property name="text">
<string>Espina Volume Editor 2.0.0</string>
<string>Espina Volume Editor 2.0.1</string>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>
Expand Down

0 comments on commit 3d740c2

Please sign in to comment.