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

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() {
// --------------- apply -------------------
Action::ApplyStatus QuitAction::apply() {
Application::getMainWindow()->close();
return SUCCESS;
// 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;
}
else {
// or abort the operation
return ABORTED;
}
}
......@@ -25,14 +25,8 @@
#include "SaveAllAction.h"
#include <Application.h>
#include <ImageComponent.h>
#include <ImageComponentExtension.h>
#include <MeshComponent.h>
#include <MeshComponentExtension.h>
#include <Log.h>
#include <QFileDialog>
using namespace camitk;
......
......@@ -36,11 +36,11 @@ using namespace camitk;
// --------------- constructor -------------------
ImageLutAction::ImageLutAction(ActionExtension* extension) : Action(extension) {
setName("Lut");
setName("Image Look Up Table");
setDescription("Modify the LUT of an image components");
setComponent("ImageComponent");
setFamily("ImageLut");
addTag("Lut");
setFamily("Image LUT");
addTag("LUT");
}
// --------------- getWidget -------------------
......
......@@ -47,7 +47,7 @@ using namespace camitk;
// ---------------------- Constructor ----------------------------
ImageLutWidget::ImageLutWidget(QWidget* parent) : QWidget(parent) {
myComponent = NULL;
myComponent = nullptr;
lutMin = 0;
lutMax = 255;
......@@ -92,7 +92,7 @@ void ImageLutWidget::updateComponent(ImageComponent* comp) {
myComponent = comp;
// if there is no lookup table, just don't display this widget!
if (myComponent->getLut() == NULL) {
if (myComponent->getLut() == nullptr) {
setEnabled(false);
return;
}
......
......@@ -51,10 +51,8 @@ public:
/// Default Destructor
virtual ~VolumeRenderingAction() = default;
void createVolumeRendering(camitk::ImageComponent* comp);
public slots:
/** this method is automatically called when the action is triggered.
* Call getTargets() method to get the list of components to use.
......
......@@ -189,7 +189,7 @@ Action::ApplyStatus WarpOut::apply() {
for (vtkIdType i = 0; i < connectivityFilter->GetOutput()->GetNumberOfPoints(); i++) {
// 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);
#else
pointId->GetTupleValue(i, &id);
......
......@@ -473,7 +473,7 @@ void ImpMainWindow::updateViewMenu() {
// change the central viewer if there is more than one viewer in the central area
if (qobject_cast<QStackedWidget*>(centralWidget())->count() > 1) {
viewMenu->addSeparator()->setText(tr("Toggle Central Viewers"));
// add a toggle action for each widget stacked inside the central widget
for (int i = 0; i < qobject_cast<QStackedWidget*>(centralWidget())->count(); i++) {
QWidget* cWidget = qobject_cast<QStackedWidget*>(centralWidget())->widget(i);
......@@ -488,15 +488,15 @@ void ImpMainWindow::updateViewMenu() {
});
Viewer* cViewer = (*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->setChecked(cViewer == centralViewer);
QString tipString = "Hide/show the " + cViewer->objectName() + " central viewer";
viewerAction->setStatusTip(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
connect(viewerAction, &QAction::toggled, [=](bool) {
setCentralViewer(cViewer);
connect(viewerAction, &QAction::toggled, [ = ](bool) {
setCentralViewer(cViewer);
});
}
}
......@@ -600,63 +600,65 @@ void ImpMainWindow::saveHistoryAsSCXML() {
// ------------------------- openDataDirectoryMenuBuilder ---------------------------
void ImpMainWindow::openDataDirectoryMenuBuilder() {
QStringList dirExt = ExtensionManager::getDataDirectoryExtNames();
QString dirExtName;
if (dirExt.size() > 1) {
if (fileOpenDataDirectoryMenu == nullptr){
if (fileOpenDataDirectoryMenu == nullptr) {
fileOpenDataDirectoryMenu = new QMenu("Open Data Directory");
fileMenu->addMenu(fileOpenDataDirectoryMenu);
} else {
disconnect(fileOpenDataDirectoryMenu,0,0,0);
}
else {
disconnect(fileOpenDataDirectoryMenu, 0, 0, 0);
fileOpenDataDirectoryMenu->clear();
}
fileOpenDataDirectoryMenu->setIcon(QPixmap(":/fileOpen"));
foreach (dirExtName, dirExt) {
for (QString dirExtName : dirExt) {
QAction* openDirectory = new QAction(dirExtName, this);
openDirectory->setStatusTip(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);
}
} else if (dirExt.size() == 1) {
QAction* openDirectoryAct;
dirExtName = dirExt.at(0);
int indexAction = 0;
bool updateAction = false;
bool IDidntFindWhatImLookingFor = true;
QList<QAction *> actions = fileMenu->actions();
int size = actions.size();
while (IDidntFindWhatImLookingFor && indexAction < actions.size() ) {
if (actions.at(indexAction)->text().contains(" Directory")) {
actions.at(indexAction)->destroyed();
updateAction = true;
IDidntFindWhatImLookingFor = false;
}
else
if (dirExt.size() == 1) {
// if it exists, remove the default directory extension menu (that has only one submenu)
// from the file "open" action list
bool updateAction = false;
QList<QAction*> menuActions = fileMenu->actions();
int indexAction = 0;
while (indexAction < menuActions.size() && !updateAction) {
if (menuActions.at(indexAction)->text().contains(" Directory")) {
menuActions.at(indexAction)->destroyed();
updateAction = true;
}
indexAction++;
}
// create the single open directory action
QString dirExtName = dirExt.at(0);
QAction* openDirectoryAction = new QAction("Open " + dirExtName + " Directory", this);
if (!updateAction) {
// there was no specific menu, just add the single "open directory" action in the file menu
fileMenu->addAction(openDirectoryAction);
}
indexAction++;
};
if (!updateAction) {
openDirectoryAct = new QAction("Open " + dirExtName + " Directory", this);
fileMenu->addAction(openDirectoryAct);
} else {
openDirectoryAct = new QAction("Open " + dirExtName + " Directory", this);
}
openDirectoryAct->setStatusTip(tr(QString("Opens data directory for " + dirExtName).toStdString().c_str()));
openDirectoryAct->setWhatsThis(tr(QString("Opens data directory for " + dirExtName).toStdString().c_str()));
openDirectoryAction->setStatusTip(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"));
} else {
fileOpenDataDirectoryMenu = new QMenu("No plugins loaded to Open Data Directory");
fileOpenDataDirectoryMenu->setIcon(QPixmap(":/fileOpen"));
fileOpenDataDirectoryMenu->setEnabled(false);
fileMenu->addMenu(fileOpenDataDirectoryMenu);
}
openDirectoryAction->setIcon(QPixmap(":/fileOpen"));
}
else {
fileOpenDataDirectoryMenu = new QMenu("No plugins loaded to Open Data Directory");
fileOpenDataDirectoryMenu->setIcon(QPixmap(":/fileOpen"));
fileOpenDataDirectoryMenu->setEnabled(false);
fileMenu->addMenu(fileOpenDataDirectoryMenu);
}
}
......@@ -572,7 +572,7 @@ private:
}
// -------------------- 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
......
......@@ -58,6 +58,7 @@ void ActionExtension::initResources() {
// -------------------- destructor --------------------
ActionExtension::~ActionExtension() {
// delete all actions one by one
while (!actions.empty()) {
Action* toDelete = actions.takeFirst();
// do not delete the "Quit" action: it is the action that triggers this delete!
......@@ -66,7 +67,7 @@ ActionExtension::~ActionExtension() {
}
}
//delete internationalization instance
// delete internationalization instance
if (translator) {
delete translator;
}
......
......@@ -108,7 +108,7 @@ private:
}
// -------------------- 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
......@@ -204,7 +204,7 @@ QString Application::getName() {
// ----------------- 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
// delete all actions (they are instantiated when the extension is loaded)
......
......@@ -186,6 +186,27 @@ public:
*/
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
vtkSmartPointer<vtkProp> getProp(const QString&) override;
......@@ -204,18 +225,8 @@ public:
* @return true if effictively done
*/
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
/// @{
......@@ -307,10 +318,7 @@ private:
/// the VTK 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
vtkSmartPointer<vtkTextMapper> labelActorMapper;
......@@ -386,8 +394,15 @@ private:
double oldAlphaPoints;
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:
/** Return the vtkActor used to pick pixels in the slices. */
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,
* the given coordinates is position where the plane was picked.
*/
virtual void pixelPicked(double, double, double) = 0;
/// update the position of the plane surrounding the currently selected slice
virtual void updatePickPlane() = 0;
/** Return the number of slices in the image data set. */
......@@ -122,10 +119,18 @@ public:
/** Returns the encapsultaed data structure: the image as a vtkImageData. */
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
virtual vtkSmartPointer<vtkProp> getProp(const QString&) = 0;
......@@ -144,7 +149,7 @@ public:
* @return true if effictively done
*/
virtual bool removeProp(const QString&) = 0;
// END TODO
/// @}
};
......
......@@ -152,29 +152,7 @@ public:
* @see Geometry
*/
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.
virtual void setTexture(vtkSmartPointer<vtkTexture>) = 0;
......@@ -204,6 +182,40 @@ public:
* @see InteractiveViewer
*/
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
......
This diff is collapsed.
This diff is collapsed.
......@@ -77,7 +77,7 @@
#include <vtkRendererCollection.h>
#include <vtkExtractSelectedFrustum.h>
#include <vtkPointData.h>
#include <vtkImageProperty.h>
namespace camitk {
// ---------------------- singleton ----------------------------
......@@ -435,6 +435,7 @@ QWidget* InteractiveViewer::getWidget(QWidget* parent) {
addWhatsThisItem("Alt+L", "Toggle light follows camera");
addWhatsThisItem("Alt+P", "Toggle point rendering");
addWhatsThisItem("P", "Pick (flip selection flag for point/cell)");
addWhatsThisItem("R", "Reset Image Interactor Look Up Table");
addWhatsThisItem("S", "Take a screenshot");
addWhatsThisItem("Alt+S", "Toggle surfacerendering");
addWhatsThisItem("T", "Trackball interaction mode");
......@@ -1009,26 +1010,33 @@ void InteractiveViewer::initActions() {
// ----------------------initWhatsThis ----------------------------
void InteractiveViewer::initWhatsThis() {
whatsThis = "<font size=\"8pt\"><center><b><u><i>3D view interaction Shortcuts</i></u></b></center><br/></font>";
QColor bgColor = frame->palette().color(QPalette::Button);
QColor textColor = frame->palette().color(QPalette::ButtonText);
whatsThis = "<div style=\"background:" + bgColor.name() + "\"><font size=\"8pt\" color=\"" + textColor.name() + "\" ><center><b><u><i>3D view interaction Shortcuts</i></u></b></center><br/></font></div>";
}
// ----------------------startWhatsThisSection ----------------------------
void InteractiveViewer::startWhatsThisSection(const QString& title) {
whatsThis += "<font size=\"9pt\"><center><b><i>" + title + "</i></b></center></font>\
<table cellpadding = \"0\" cellspacing=\"0\" width=\"100%\">";
QColor bgColor = frame->palette().color(QPalette::Button);
QColor textColor = frame->palette().color(QPalette::ButtonText);
whatsThis += "<div style=\"background:" + bgColor.name() + "\"><font size=\"9pt\" color=\"" + textColor.name() + "\"><center><b><i>" + title + "</i></b></center>\
<table bgcolor=\"" + bgColor.name() + "\" cellpadding = \"0\" cellspacing=\"0\" width=\"100%\">";
oddWhatsThis = true;
}
// ----------------------endWhatsThisSection ----------------------------
void InteractiveViewer::endWhatsThisSection() {
whatsThis += "</table>\
whatsThis += "</table></font></div>\
<br>";
}
// ----------------------addWhatsThisItem ----------------------------
void InteractiveViewer::addWhatsThisItem(const QString& key, const QString& description) {
if (oddWhatsThis) {
whatsThis += "<tr bgcolor=\"#ECD4C8\">";
QColor bgColor = frame->palette().color(QPalette::Midlight);
whatsThis += "<tr bgcolor=\"" + bgColor.name() + "\">";
}
else {
whatsThis += "<tr>";
......@@ -1153,6 +1161,12 @@ void InteractiveViewer::keyPressEvent(QKeyEvent* e) {
break;
case Qt::Key_R:
if (myType == SLICE_VIEWER) {
resetLUT();
}
break;
case Qt::Key_S:
// addWhatsThisItem("Alt+S", "Toggle surface rendering");
......@@ -1411,9 +1425,6 @@ void InteractiveViewer::keyPressEvent(QKeyEvent* e) {
if (c->getPickPlaneActor() == p) {
found = true;
debugStream << "\t- Picked Plane Actor" << endl;
/* } else if (c->get2DAxesActor() == p) {
found = true;
debugStream << "\t- 2D Axes Actor" << endl; */
}
break;
......@@ -1670,6 +1681,23 @@ void InteractiveViewer::toggleInterpolation() {
}
}
//------------------------- resetLUT ----------------------------
void InteractiveViewer::resetLUT() {
foreach (Component* comp, actorMap.keys()) {
if (comp->getRepresentation() == Component::SLICE) {
// reset property LUT
vtkSmartPointer<vtkImageProperty> initProp = vtkImageProperty::New();
initProp->SetInterpolationTypeToLinear();
initProp->SetAmbient(1.0);
initProp->SetDiffuse(0.0);
comp->get2DImageActor()->SetProperty(initProp);
// the Component was modified inside the viewer, refresh all its other viewer
comp->refresh();
}
}
}
//---------------------updateSelectionDisplay------------------------
void InteractiveViewer::updateSelectionDisplay(Component* comp) {
InterfaceGeometry::EnhancedModes m = InterfaceGeometry::Normal;
......
......@@ -390,6 +390,9 @@ protected:
/// for InterfaceBitMap, toggle the interpolation mode (intern method, not a property because it can only be modified by the keyboard interaction)
void toggleInterpolation();
/// for InterfaceBitMap, reset the lut that was changed by the image interactor (window and level)
void resetLUT();
/// Update the display of the given Component, according to its selection state and the current HighlightMode.
void updateSelectionDisplay(Component*);
......
Markdown is supported
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