Vous avez reçu un message "Your GitLab account has been locked ..." ? Pas d'inquiétude : lisez cet article https://docs.gricad-pages.univ-grenoble-alpes.fr/help/unlock/

Commit 8c0413db authored by Emmanuel Promayon's avatar Emmanuel Promayon
Browse files

Merge branch 'fix/various-small-bugs' into 'develop'

Fix/various small bugs + Slice simplification

See merge request !137
parents b5f9f671 42343ce0
...@@ -57,7 +57,16 @@ QWidget* QuitAction::getWidget() { ...@@ -57,7 +57,16 @@ QWidget* QuitAction::getWidget() {
// --------------- apply ------------------- // --------------- apply -------------------
Action::ApplyStatus QuitAction::apply() { Action::ApplyStatus QuitAction::apply() {
Application::getMainWindow()->close(); // close all components (and therefore ask the user to savet the modified ones)
ApplyStatus closeAllStatus = Application::getAction("Close All")->apply();
if (closeAllStatus == SUCCESS) {
// Quit the app (will call Application::quitting() and therefore unload all action extensions and delete all actions)
Application::quit();
return SUCCESS; return SUCCESS;
}
else {
// or abort the operation
return ABORTED;
}
} }
...@@ -25,14 +25,8 @@ ...@@ -25,14 +25,8 @@
#include "SaveAllAction.h" #include "SaveAllAction.h"
#include <Application.h> #include <Application.h>
#include <ImageComponent.h>
#include <ImageComponentExtension.h>
#include <MeshComponent.h>
#include <MeshComponentExtension.h>
#include <Log.h> #include <Log.h>
#include <QFileDialog>
using namespace camitk; using namespace camitk;
......
...@@ -36,11 +36,11 @@ using namespace camitk; ...@@ -36,11 +36,11 @@ using namespace camitk;
// --------------- constructor ------------------- // --------------- constructor -------------------
ImageLutAction::ImageLutAction(ActionExtension* extension) : Action(extension) { ImageLutAction::ImageLutAction(ActionExtension* extension) : Action(extension) {
setName("Lut"); setName("Image Look Up Table");
setDescription("Modify the LUT of an image components"); setDescription("Modify the LUT of an image components");
setComponent("ImageComponent"); setComponent("ImageComponent");
setFamily("ImageLut"); setFamily("Image LUT");
addTag("Lut"); addTag("LUT");
} }
// --------------- getWidget ------------------- // --------------- getWidget -------------------
......
...@@ -47,7 +47,7 @@ using namespace camitk; ...@@ -47,7 +47,7 @@ using namespace camitk;
// ---------------------- Constructor ---------------------------- // ---------------------- Constructor ----------------------------
ImageLutWidget::ImageLutWidget(QWidget* parent) : QWidget(parent) { ImageLutWidget::ImageLutWidget(QWidget* parent) : QWidget(parent) {
myComponent = NULL; myComponent = nullptr;
lutMin = 0; lutMin = 0;
lutMax = 255; lutMax = 255;
...@@ -92,7 +92,7 @@ void ImageLutWidget::updateComponent(ImageComponent* comp) { ...@@ -92,7 +92,7 @@ void ImageLutWidget::updateComponent(ImageComponent* comp) {
myComponent = comp; myComponent = comp;
// if there is no lookup table, just don't display this widget! // if there is no lookup table, just don't display this widget!
if (myComponent->getLut() == NULL) { if (myComponent->getLut() == nullptr) {
setEnabled(false); setEnabled(false);
return; return;
} }
......
...@@ -51,10 +51,8 @@ public: ...@@ -51,10 +51,8 @@ public:
/// Default Destructor /// Default Destructor
virtual ~VolumeRenderingAction() = default; virtual ~VolumeRenderingAction() = default;
void createVolumeRendering(camitk::ImageComponent* comp); void createVolumeRendering(camitk::ImageComponent* comp);
public slots: public slots:
/** this method is automatically called when the action is triggered. /** this method is automatically called when the action is triggered.
* Call getTargets() method to get the list of components to use. * Call getTargets() method to get the list of components to use.
......
...@@ -189,7 +189,7 @@ Action::ApplyStatus WarpOut::apply() { ...@@ -189,7 +189,7 @@ Action::ApplyStatus WarpOut::apply() {
for (vtkIdType i = 0; i < connectivityFilter->GetOutput()->GetNumberOfPoints(); i++) { for (vtkIdType i = 0; i < connectivityFilter->GetOutput()->GetNumberOfPoints(); i++) {
// get the id of the point in the original point set // get the id of the point in the original point set
#if VTK_MAJOR_VERSION == 8 #if VTK_MAJOR_VERSION >= 7
pointId->GetTypedTuple(i, &id); pointId->GetTypedTuple(i, &id);
#else #else
pointId->GetTupleValue(i, &id); pointId->GetTupleValue(i, &id);
......
...@@ -488,14 +488,14 @@ void ImpMainWindow::updateViewMenu() { ...@@ -488,14 +488,14 @@ void ImpMainWindow::updateViewMenu() {
}); });
Viewer* cViewer = (*it); Viewer* cViewer = (*it);
// viewerAction is own by viewMenu, viewMenu->clear() will delete it // viewerAction is own by viewMenu, viewMenu->clear() will delete it
QAction *viewerAction = viewMenu->addAction(cViewer->objectName()); QAction* viewerAction = viewMenu->addAction(cViewer->objectName());
viewerAction->setCheckable(true); viewerAction->setCheckable(true);
viewerAction->setChecked(cViewer == centralViewer); viewerAction->setChecked(cViewer == centralViewer);
QString tipString = "Hide/show the " + cViewer->objectName() + " central viewer"; QString tipString = "Hide/show the " + cViewer->objectName() + " central viewer";
viewerAction->setStatusTip(tr(tipString.toStdString().c_str())); viewerAction->setStatusTip(tr(tipString.toStdString().c_str()));
viewerAction->setWhatsThis(tr(tipString.toStdString().c_str())); viewerAction->setWhatsThis(tr(tipString.toStdString().c_str()));
// add the toggle action slot using C++11 lambda so that everything is contained inside viewMenu // add the toggle action slot using C++11 lambda so that everything is contained inside viewMenu
connect(viewerAction, &QAction::toggled, [=](bool) { connect(viewerAction, &QAction::toggled, [ = ](bool) {
setCentralViewer(cViewer); setCentralViewer(cViewer);
}); });
} }
...@@ -600,60 +600,62 @@ void ImpMainWindow::saveHistoryAsSCXML() { ...@@ -600,60 +600,62 @@ void ImpMainWindow::saveHistoryAsSCXML() {
// ------------------------- openDataDirectoryMenuBuilder --------------------------- // ------------------------- openDataDirectoryMenuBuilder ---------------------------
void ImpMainWindow::openDataDirectoryMenuBuilder() { void ImpMainWindow::openDataDirectoryMenuBuilder() {
QStringList dirExt = ExtensionManager::getDataDirectoryExtNames(); QStringList dirExt = ExtensionManager::getDataDirectoryExtNames();
QString dirExtName;
if (dirExt.size() > 1) { if (dirExt.size() > 1) {
if (fileOpenDataDirectoryMenu == nullptr){ if (fileOpenDataDirectoryMenu == nullptr) {
fileOpenDataDirectoryMenu = new QMenu("Open Data Directory"); fileOpenDataDirectoryMenu = new QMenu("Open Data Directory");
fileMenu->addMenu(fileOpenDataDirectoryMenu); fileMenu->addMenu(fileOpenDataDirectoryMenu);
} else { }
disconnect(fileOpenDataDirectoryMenu,0,0,0); else {
disconnect(fileOpenDataDirectoryMenu, 0, 0, 0);
fileOpenDataDirectoryMenu->clear(); fileOpenDataDirectoryMenu->clear();
} }
fileOpenDataDirectoryMenu->setIcon(QPixmap(":/fileOpen")); fileOpenDataDirectoryMenu->setIcon(QPixmap(":/fileOpen"));
foreach (dirExtName, dirExt) { for (QString dirExtName : dirExt) {
QAction* openDirectory = new QAction(dirExtName, this); QAction* openDirectory = new QAction(dirExtName, this);
openDirectory->setStatusTip(tr(QString("Opens data directory for " + dirExtName).toStdString().c_str())); openDirectory->setStatusTip(tr(QString("Opens data directory for " + dirExtName).toStdString().c_str()));
openDirectory->setWhatsThis(tr(QString("Opens data directory for " + dirExtName).toStdString().c_str())); openDirectory->setWhatsThis(tr(QString("Opens data directory for " + dirExtName).toStdString().c_str()));
connect(openDirectory, &QAction::triggered, this, [=]() {this->openDataDirectory(dirExtName);}); connect(openDirectory, &QAction::triggered, this, [ = ]() {
this->openDataDirectory(dirExtName);
});
fileOpenDataDirectoryMenu->addAction(openDirectory); fileOpenDataDirectoryMenu->addAction(openDirectory);
} }
} else if (dirExt.size() == 1) { }
QAction* openDirectoryAct; else
if (dirExt.size() == 1) {
dirExtName = dirExt.at(0); // if it exists, remove the default directory extension menu (that has only one submenu)
int indexAction = 0; // from the file "open" action list
bool updateAction = false; bool updateAction = false;
bool IDidntFindWhatImLookingFor = true; QList<QAction*> menuActions = fileMenu->actions();
int indexAction = 0;
QList<QAction *> actions = fileMenu->actions(); while (indexAction < menuActions.size() && !updateAction) {
int size = actions.size(); if (menuActions.at(indexAction)->text().contains(" Directory")) {
menuActions.at(indexAction)->destroyed();
while (IDidntFindWhatImLookingFor && indexAction < actions.size() ) {
if (actions.at(indexAction)->text().contains(" Directory")) {
actions.at(indexAction)->destroyed();
updateAction = true; updateAction = true;
IDidntFindWhatImLookingFor = false;
} }
indexAction++; indexAction++;
}; }
// create the single open directory action
QString dirExtName = dirExt.at(0);
QAction* openDirectoryAction = new QAction("Open " + dirExtName + " Directory", this);
if (!updateAction) { if (!updateAction) {
openDirectoryAct = new QAction("Open " + dirExtName + " Directory", this); // there was no specific menu, just add the single "open directory" action in the file menu
fileMenu->addAction(openDirectoryAct); fileMenu->addAction(openDirectoryAction);
} else {
openDirectoryAct = new QAction("Open " + dirExtName + " Directory", this);
} }
openDirectoryAct->setStatusTip(tr(QString("Opens data directory for " + dirExtName).toStdString().c_str())); openDirectoryAction->setStatusTip(tr(QString("Opens data directory for " + dirExtName).toStdString().c_str()));
openDirectoryAct->setWhatsThis(tr(QString("Opens data directory for " + dirExtName).toStdString().c_str())); openDirectoryAction->setWhatsThis(tr(QString("Opens data directory for " + dirExtName).toStdString().c_str()));
connect(openDirectoryAct, &QAction::triggered, this, [=]() {this->openDataDirectory(dirExtName);}); connect(openDirectoryAction, &QAction::triggered, this, [ = ]() {
this->openDataDirectory(dirExtName);
});
openDirectoryAct->setIcon(QPixmap(":/fileOpen")); openDirectoryAction->setIcon(QPixmap(":/fileOpen"));
} else { }
else {
fileOpenDataDirectoryMenu = new QMenu("No plugins loaded to Open Data Directory"); fileOpenDataDirectoryMenu = new QMenu("No plugins loaded to Open Data Directory");
fileOpenDataDirectoryMenu->setIcon(QPixmap(":/fileOpen")); fileOpenDataDirectoryMenu->setIcon(QPixmap(":/fileOpen"));
fileOpenDataDirectoryMenu->setEnabled(false); fileOpenDataDirectoryMenu->setEnabled(false);
......
...@@ -572,7 +572,7 @@ private: ...@@ -572,7 +572,7 @@ private:
} }
// -------------------- declare the interface for QPluginLoader -------------------- // -------------------- declare the interface for QPluginLoader --------------------
Q_DECLARE_INTERFACE(camitk::Action, "TIMC-IMAG.Action/2.1") //TODO use svn version? Q_DECLARE_INTERFACE(camitk::Action, "TIMC-IMAG.Action/2.1")
#endif // ACTION_H #endif // ACTION_H
......
...@@ -58,6 +58,7 @@ void ActionExtension::initResources() { ...@@ -58,6 +58,7 @@ void ActionExtension::initResources() {
// -------------------- destructor -------------------- // -------------------- destructor --------------------
ActionExtension::~ActionExtension() { ActionExtension::~ActionExtension() {
// delete all actions one by one
while (!actions.empty()) { while (!actions.empty()) {
Action* toDelete = actions.takeFirst(); Action* toDelete = actions.takeFirst();
// do not delete the "Quit" action: it is the action that triggers this delete! // do not delete the "Quit" action: it is the action that triggers this delete!
...@@ -66,7 +67,7 @@ ActionExtension::~ActionExtension() { ...@@ -66,7 +67,7 @@ ActionExtension::~ActionExtension() {
} }
} }
//delete internationalization instance // delete internationalization instance
if (translator) { if (translator) {
delete translator; delete translator;
} }
......
...@@ -108,7 +108,7 @@ private: ...@@ -108,7 +108,7 @@ private:
} }
// -------------------- declare the interface for QPluginLoader -------------------- // -------------------- declare the interface for QPluginLoader --------------------
Q_DECLARE_INTERFACE(camitk::ActionExtension, "TIMC-IMAG. Action Extension/2.1") //TODO use variable from CMake? Q_DECLARE_INTERFACE(camitk::ActionExtension, "TIMC-IMAG. Action Extension/2.1")
#endif //ACTION_EXTENSION_H #endif //ACTION_EXTENSION_H
...@@ -204,7 +204,7 @@ QString Application::getName() { ...@@ -204,7 +204,7 @@ QString Application::getName() {
// ----------------- quitting -------------------- // ----------------- quitting --------------------
void Application::quitting() { void Application::quitting() {
// this is connect to the aboutToQuit signal from QApplication // this is connected to the aboutToQuit signal from QApplication
// it should contain all the code that frees the resources // it should contain all the code that frees the resources
// delete all actions (they are instantiated when the extension is loaded) // delete all actions (they are instantiated when the extension is loaded)
......
...@@ -186,6 +186,27 @@ public: ...@@ -186,6 +186,27 @@ public:
*/ */
vtkSmartPointer<vtkActor> getActor(const RenderingModes) override; vtkSmartPointer<vtkActor> getActor(const RenderingModes) override;
/** Set a texture to this object. */
void setTexture(vtkSmartPointer<vtkTexture> texture) override;
/// a vtkPoint of the structured was picked (to be reimplemented in a Component inherited class if needed)
void pointPicked(vtkIdType, bool) {};
/// a vtkCell of the structured was picked (to be reimplemented in a Component inherited class if needed)
void cellPicked(vtkIdType, bool) {};
///@}
/// @name manage extra prop associated with a Geometry
/// @{
/// TODO
/// - put all this management into a dedicated interface
/// - remove it from InterfaceBitMap and InterfaceGeometry
/// - remove it from Slice and Geometry helper classes
/// - create a new associated helper class
/// - update Component class and all other code using it (if needed)
/// Note : beware that Geometry requires this to manage to at least "label" and "glyph" extra actors
/// Return the vtkProp (actors, volumes and annotations) corresponding to the given name /// Return the vtkProp (actors, volumes and annotations) corresponding to the given name
vtkSmartPointer<vtkProp> getProp(const QString&) override; vtkSmartPointer<vtkProp> getProp(const QString&) override;
...@@ -204,17 +225,7 @@ public: ...@@ -204,17 +225,7 @@ public:
* @return true if effictively done * @return true if effictively done
*/ */
bool removeProp(const QString&) override; bool removeProp(const QString&) override;
/// @}
/** Set a texture to this object. */
void setTexture(vtkSmartPointer<vtkTexture> texture) override;
/// a vtkPoint of the structured was picked (to be reimplemented in a Component inherited class if needed)
void pointPicked(vtkIdType, bool) {};
/// a vtkCell of the structured was picked (to be reimplemented in a Component inherited class if needed)
void cellPicked(vtkIdType, bool) {};
///@}
/// @name InterfaceGeometry Helpers inherited methods /// @name InterfaceGeometry Helpers inherited methods
/// @{ /// @{
...@@ -308,9 +319,6 @@ private: ...@@ -308,9 +319,6 @@ private:
/// the VTK mapper /// the VTK mapper
vtkSmartPointer<vtkDataSetMapper> mapper; vtkSmartPointer<vtkDataSetMapper> mapper;
/// The additional map for prop (include at least "label" and "glyph"
QMap<QString, vtkSmartPointer<vtkProp> > extraProp;
/// the mapper to create the text /// the mapper to create the text
vtkSmartPointer<vtkTextMapper> labelActorMapper; vtkSmartPointer<vtkTextMapper> labelActorMapper;
...@@ -386,8 +394,15 @@ private: ...@@ -386,8 +394,15 @@ private:
double oldAlphaPoints; double oldAlphaPoints;
double oldPointsColor[4]; double oldPointsColor[4];
///@} ///@}
protected:
vtkSmartPointer< vtkPointSet > New(); /// @name manage extra prop associated with a Geometry
/// @{
/// TODO see extra prop management method section
/// The additional map for prop (include at least "label" and "glyph")
QMap<QString, vtkSmartPointer<vtkProp> > extraProp;
///@}
}; };
......
...@@ -85,15 +85,12 @@ public: ...@@ -85,15 +85,12 @@ public:
/** Return the vtkActor used to pick pixels in the slices. */ /** Return the vtkActor used to pick pixels in the slices. */
virtual vtkSmartPointer<vtkActor> getPixelActor() = 0; virtual vtkSmartPointer<vtkActor> getPixelActor() = 0;
/** Return 2D Axes at the proper slice origin */
// virtual vtkSmartPointer<vtkAxesActor> get2DAxesActor() = 0;
/** This method is called when the associated plane has been picked in the InteractiveViewer, /** This method is called when the associated plane has been picked in the InteractiveViewer,
* the given coordinates is position where the plane was picked. * the given coordinates is position where the plane was picked.
*/ */
virtual void pixelPicked(double, double, double) = 0; virtual void pixelPicked(double, double, double) = 0;
/// update the position of the plane surrounding the currently selected slice
virtual void updatePickPlane() = 0; virtual void updatePickPlane() = 0;
/** Return the number of slices in the image data set. */ /** Return the number of slices in the image data set. */
...@@ -122,9 +119,17 @@ public: ...@@ -122,9 +119,17 @@ public:
/** Returns the encapsultaed data structure: the image as a vtkImageData. */ /** Returns the encapsultaed data structure: the image as a vtkImageData. */
virtual vtkSmartPointer<vtkImageData> getImageData() const = 0; virtual vtkSmartPointer<vtkImageData> getImageData() const = 0;
// TODO : put all of this into a dedicated interface
/// The additional map for prop (include at least "label" and "glyph"
QMap<QString, vtkSmartPointer<vtkProp> > extraProp; /// @name manage extra prop associated with an InterfaceBitMap
/// @{
/// TODO
/// - put all this management into a dedicated interface
/// - remove it from InterfaceBitMap and InterfaceGeometry
/// - remove it from Slice and Geometry helper classes
/// - create a new associated helper class
/// - update Component class and all other code using it (if needed)
/// Note : beware that Geometry requires this to manage to at least "label" and "glyph" extra actors
/// Return the vtkProp (actors, volumes and annotations) corresponding to the given name /// Return the vtkProp (actors, volumes and annotations) corresponding to the given name
virtual vtkSmartPointer<vtkProp> getProp(const QString&) = 0; virtual vtkSmartPointer<vtkProp> getProp(const QString&) = 0;
...@@ -144,7 +149,7 @@ public: ...@@ -144,7 +149,7 @@ public:
* @return true if effictively done * @return true if effictively done
*/ */
virtual bool removeProp(const QString&) = 0; virtual bool removeProp(const QString&) = 0;
// END TODO /// @}
}; };
......
...@@ -153,28 +153,6 @@ public: ...@@ -153,28 +153,6 @@ public:
*/ */
virtual void setDataConnection(vtkSmartPointer<vtkAlgorithmOutput>) = 0; virtual void setDataConnection(vtkSmartPointer<vtkAlgorithmOutput>) = 0;
/// Return the actor for the representation mode, NULL if the actor doesn't exist.
virtual vtkSmartPointer<vtkActor> getActor(const RenderingModes) = 0;
/// Return the vtkProp (actors, volumes and annotations) corresponding to the given name
virtual vtkSmartPointer<vtkProp> getProp(const QString&) = 0;
/// return the number of additional prop
virtual unsigned int getNumberOfProp() const = 0;
/// return an additional prop by its index
virtual vtkSmartPointer<vtkProp> getProp(unsigned int) = 0;
/** remove a given additional prop.
* @return true if effictively done
*/
virtual bool removeProp(const QString&) = 0;
/** insert an additional prop, defining it by its name (default visibility = false).
* @return true if the additional prop was added (i.e. another additional prop of the same name does not exist)
*/
virtual bool addProp(const QString&, vtkSmartPointer<vtkProp>) = 0;
/// Set a texture to this object. /// Set a texture to this object.
virtual void setTexture(vtkSmartPointer<vtkTexture>) = 0; virtual void setTexture(vtkSmartPointer<vtkTexture>) = 0;
...@@ -204,6 +182,40 @@ public: ...@@ -204,6 +182,40 @@ public:
* @see InteractiveViewer * @see InteractiveViewer
*/ */
virtual void cellPicked(vtkIdType cellId, bool pickingIsSelecting) = 0; virtual void cellPicked(vtkIdType cellId, bool pickingIsSelecting) = 0;
/// Return the actor for the representation mode, NULL if the actor doesn't exist.
virtual vtkSmartPointer<vtkActor> getActor(const RenderingModes) = 0;
///@}
/// @name manage extra prop associated with an InterfaceGeometry
/// @{
/// TODO
/// - put all this management into a dedicated interface
/// - remove it from InterfaceBitMap and InterfaceGeometry
/// - remove it from Slice and Geometry helper classes
/// - create a new associated helper class
/// - update Component class and all other code using it (if needed)
/// Note : beware that Geometry requires this to manage to at least "label" and "glyph" extra actors
/// Return the vtkProp (actors, volumes and annotations) corresponding to the given name
virtual vtkSmartPointer<vtkProp> getProp(const QString&) = 0;
/// return the number of additional prop
virtual unsigned int getNumberOfProp() const = 0;
/// return an additional prop by its index
virtual vtkSmartPointer<vtkProp> getProp(unsigned int) = 0;
/** remove a given additional prop.
* @return true if effictively done
*/
virtual bool removeProp(const QString&) = 0;
/** insert an additional prop, defining it by its name (default visibility = false).
* @return true if the additional prop was added (i.e. another additional prop of the same name does not exist)
*/
virtual bool addProp(const QString&, vtkSmartPointer<vtkProp>) = 0;
///@} ///@}
/// @name Helpers methods /// @name Helpers methods
......
This diff is collapsed.
...@@ -31,36 +31,48 @@ ...@@ -31,36 +31,48 @@
#include "InterfaceBitMap.h" #include "InterfaceBitMap.h"
// -- vtk stuff // -- vtk stuff
#include <vtkSmartPointer.h> #include <vtkImageData.h>
#include <vtkWindowLevelLookupTable.h> #include <vtkWindowLevelLookupTable.h>
#include <vtkImageMapToColors.h> #include <vtkTransform.h>
#include <vtkActor.h> #include <vtkActor.h>
#include <vtkImageActor.h> #include <vtkImageActor.h>
#include <vtkImageChangeInformation.h>