Commit cd883be9 authored by Emmanuel Promayon's avatar Emmanuel Promayon

NEW Settings dialog has now a viewer extension tab

+ add a specific description for the viewers and little code cleanings
parent 945b436c
......@@ -9,7 +9,7 @@
<x>0</x>
<y>0</y>
<width>800</width>
<height>461</height>
<height>462</height>
</rect>
</property>
<property name="minimumSize">
......@@ -40,7 +40,7 @@
<bool>true</bool>
</property>
<property name="currentIndex">
<number>2</number>
<number>3</number>
</property>
<widget class="QWidget" name="generalTab">
<attribute name="title">
......@@ -193,7 +193,7 @@
<item>
<widget class="QLabel" name="componentPluginDescription">
<property name="text">
<string>Here is a plugin &lt;b&gt;description&lt;/b&gt;, that can be in &lt;i&gt;rich text&lt;/i&gt; !!!</string>
<string>Click on a registered component extension above to display its description.</string>
</property>
<property name="textFormat">
<enum>Qt::AutoText</enum>
......@@ -216,15 +216,15 @@
</widget>
<widget class="QWidget" name="actionExtensionTab">
<attribute name="title">
<string>Actions Extensions</string>
<string>Action Extensions</string>
</attribute>
<layout class="QVBoxLayout">
<item>
<widget class="QTableWidget" name="actionExtensionList">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
<width>768</width>
<height>229</height>
</size>
</property>
<property name="toolTip">
......@@ -269,6 +269,9 @@
<property name="rowCount">
<number>0</number>
</property>
<attribute name="horizontalHeaderMinimumSectionSize">
<number>60</number>
</attribute>
<column>
<property name="text">
<string>Name</string>
......@@ -334,7 +337,151 @@
<item>
<widget class="QLabel" name="actionExtensionDescription">
<property name="text">
<string>Here is an extension &lt;b&gt;description&lt;/b&gt;, that can be in &lt;i&gt;rich text&lt;/i&gt; !!!</string>
<string>Click on an registered action above to display its description.</string>
</property>
<property name="textFormat">
<enum>Qt::AutoText</enum>
</property>
<property name="scaledContents">
<bool>false</bool>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="viewerExtensionTab">
<attribute name="title">
<string>Viewer Extensions</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QTableWidget" name="viewerExtensionList">
<property name="minimumSize">
<size>
<width>768</width>
<height>229</height>
</size>
</property>
<property name="toolTip">
<string>List the actions extensions (you can add or remove an extension by clicking on the Add/Remove buttons)</string>
</property>
<property name="whatsThis">
<string>List the actions extensions (you can add or remove an extension by clicking on the Add/Remove buttons)</string>
</property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="showDropIndicator" stdset="0">
<bool>false</bool>
</property>
<property name="dragDropOverwriteMode">
<bool>false</bool>
</property>
<property name="alternatingRowColors">
<bool>true</bool>
</property>
<property name="selectionMode">
<enum>QAbstractItemView::ExtendedSelection</enum>
</property>
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectRows</enum>
</property>
<property name="showGrid">
<bool>false</bool>
</property>
<property name="gridStyle">
<enum>Qt::SolidLine</enum>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
<property name="cornerButtonEnabled">
<bool>false</bool>
</property>
<property name="rowCount">
<number>0</number>
</property>
<attribute name="horizontalHeaderMinimumSectionSize">
<number>60</number>
</attribute>
<column>
<property name="text">
<string>Name</string>
</property>
</column>
<column>
<property name="text">
<string>Viewer</string>
</property>
</column>
<column>
<property name="text">
<string>Location</string>
</property>
</column>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="_2">
<item>
<widget class="QPushButton" name="addViewerExtensionButton">
<property name="toolTip">
<string>Add a action extension</string>
</property>
<property name="whatsThis">
<string>Add a action extension</string>
</property>
<property name="text">
<string>&amp;Add</string>
</property>
<property name="shortcut">
<string>Alt+A</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="removeViewerExtensionButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>remove a action extension from the list</string>
</property>
<property name="whatsThis">
<string>remove a action extension from the list</string>
</property>
<property name="text">
<string>&amp;Remove</string>
</property>
<property name="shortcut">
<string>Alt+R</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBox_6">
<property name="title">
<string>Description</string>
</property>
<layout class="QHBoxLayout" name="_3">
<item>
<widget class="QLabel" name="viewerExtensionDescription">
<property name="text">
<string>Click on an registered viewer above to display its description.</string>
</property>
<property name="textFormat">
<enum>Qt::AutoText</enum>
......@@ -362,7 +509,16 @@
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
......
......@@ -32,6 +32,8 @@
#include "ComponentExtension.h"
#include "ActionExtension.h"
#include "Action.h"
#include "ViewerExtension.h"
#include "Viewer.h"
#include "ObjectController.h"
#include "ui_Settings.h"
......@@ -57,7 +59,8 @@ SettingsDialog::SettingsDialog() : QDialog(qApp->activeWindow()) {
readUserExtensions();
updateComponentExtensionList();
updateActionExtensionList();
updateViewerExtensionList();
// -- setup the general tab
myUI->generalTab->setVisible(false);
objectController = new ObjectController(myUI->propEditorFrame, ObjectController::BUTTON);
......@@ -98,6 +101,7 @@ void SettingsDialog::readUserExtensions() {
settings.beginGroup("UserExtensions");
userComponents = settings.value("components", QVariant(QStringList())).toStringList();
userActions = settings.value("actions", QVariant(QStringList())).toStringList();
userViewers = settings.value("viewers", QVariant(QStringList())).toStringList();
settings.endGroup();
}
......@@ -107,6 +111,7 @@ void SettingsDialog::writeUserExtensions() {
settings.beginGroup("UserExtensions");
settings.setValue("components", userComponents);
settings.setValue("actions", userActions);
settings.setValue("viewers", userViewers);
settings.endGroup();
}
......@@ -168,9 +173,8 @@ void SettingsDialog::updateComponentExtensionList() {
}
// ------------------------------ updateComponentExtensionList -------------------------------
// ------------------------------ updateActionExtensionList -------------------------------
void SettingsDialog::updateActionExtensionList() {
//const QMap<QString, ActionExtension*>& aeMap = ExtensionManager::getActionExtensions();
const QList<ActionExtension*> aeList = ExtensionManager::getActionExtensionsList();
// remove all the items
......@@ -185,7 +189,8 @@ void SettingsDialog::updateActionExtensionList() {
// create table row
for (int i = 0; i < ae->getActions().size(); i++) {
Action* action = ae->getActions().at(i);
myUI->actionExtensionList->setItem(actionId, 0, new QTableWidgetItem((userActions.contains(ae->getLocation()) ? QPixmap(":/user") : QPixmap(":/camiTKIcon")), action->getName()));
QPixmap actionIcon = action->getIcon();
myUI->actionExtensionList->setItem(actionId, 0, new QTableWidgetItem((userActions.contains(ae->getLocation()) ? QPixmap(":/user") : ((actionIcon.isNull()) ? QPixmap(":/camiTKIcon") : actionIcon)), action->getName()));
myUI->actionExtensionList->setItem(actionId, 1, new QTableWidgetItem(action->getComponent()));
myUI->actionExtensionList->setItem(actionId, 2, new QTableWidgetItem(ae->getLocation()));
actionId++;
......@@ -197,6 +202,36 @@ void SettingsDialog::updateActionExtensionList() {
myUI->actionExtensionList->sortByColumn(0, Qt::AscendingOrder);
}
// ------------------------------ updateViewerExtensionList -------------------------------
void SettingsDialog::updateViewerExtensionList() {
const QList<ViewerExtension*> aeList = ExtensionManager::getViewerExtensionsList();
// remove all the items
myUI->viewerExtensionList->clearContents();
myUI->viewerExtensionList->setRowCount(Application::getViewers().size());
myUI->viewerExtensionList->verticalHeader()->setVisible(false);
myUI->viewerExtensionList->setSortingEnabled(false); // temporarily for insertion!
// loop over all ActionExtensions
unsigned int viewerId = 0;
foreach (ViewerExtension* ve, aeList) {
// create table row
for (int i = 0; i < ve->getViewers().size(); i++) {
Viewer* viewer = ve->getViewers().at(i);
QPixmap viewerIcon = viewer->getIcon();
myUI->viewerExtensionList->setItem(viewerId, 0, new QTableWidgetItem((userViewers.contains(ve->getLocation()) ? QPixmap(":/user") : ((viewerIcon.isNull()) ? QPixmap(":/camiTKIcon") : viewerIcon)), viewer->getName()));
myUI->viewerExtensionList->setItem(viewerId, 1, new QTableWidgetItem(ve->getName()));
myUI->viewerExtensionList->setItem(viewerId, 2, new QTableWidgetItem(ve->getLocation()));
viewerId++;
}
}
myUI->viewerExtensionList->resizeColumnsToContents();
myUI->viewerExtensionList->setSortingEnabled(true);
myUI->viewerExtensionList->sortByColumn(0, Qt::AscendingOrder);
}
// ------------------------------ accept -------------------------------
void SettingsDialog::accept() {
if (objectController->isModified()) {
......@@ -330,7 +365,6 @@ void SettingsDialog::on_addActionExtensionButton_released() {
updateActionExtensionList();
}
// ----------------- on_removeActionExtensionButton_released ----------------------------
void SettingsDialog::on_removeActionExtensionButton_released() {
// remove the plugin
......@@ -370,5 +404,23 @@ void SettingsDialog::on_actionExtensionList_cellClicked(int row, int column) {
(myUI->actionExtensionList->item(myUI->actionExtensionList->currentRow(), 0)->text())->getDescription());
}
// ------------------------------ on_addViewerExtensionButton_released -------------------------------
void SettingsDialog::on_addViewerExtensionButton_released() {
// TODO
}
// ----------------- on_removeViewerExtensionButton_released ----------------------------
void SettingsDialog::on_removeViewerExtensionButton_released() {
// TODO
}
// ------------------------------ on_viewerExtensionList_cellClicked -------------------------------
void SettingsDialog::on_viewerExtensionList_cellClicked(int row, int column) {
myUI->removeViewerExtensionButton->setEnabled(userViewers.contains(myUI->viewerExtensionList->item(myUI->viewerExtensionList->currentRow(), 2)->text()));
myUI->viewerExtensionDescription->setText(Application::getViewer
(myUI->viewerExtensionList->item(myUI->viewerExtensionList->currentRow(), 0)->text())->getDescription());
}
}
......@@ -98,6 +98,12 @@ private slots:
virtual void on_actionExtensionList_cellClicked(int, int);
virtual void on_addViewerExtensionButton_released();
virtual void on_removeViewerExtensionButton_released();
virtual void on_viewerExtensionList_cellClicked(int, int);
private:
/// if the user says it is ok and validate the settings dialog, this update the settings
void accept() override;
......@@ -108,6 +114,9 @@ private:
/// update the action plugin list
void updateActionExtensionList();
/// update the action plugin list
void updateViewerExtensionList();
/// the property editor
ObjectController* objectController;
......@@ -123,6 +132,9 @@ private:
/// the list of user action extension locations
QStringList userActions;
/// the list of user action extension locations
QStringList userViewers;
/// get the current value of the settings
void readUserExtensions();
......
......@@ -77,6 +77,11 @@ QStringList Viewer::getComponents() {
return components;
}
// -------------------- setDescription --------------------
void Viewer::setDescription(QString description) {
this->description = description;
}
//---------------------- selectionChanged ------------------------
void Viewer::selectionChanged(camitk::ComponentList& compSet) {
foreach (Component* comp, compSet) {
......@@ -108,12 +113,12 @@ bool Viewer::getToolBarVisibility() {
return toolbarVisibility;
}
// -------------------- getLayout --------------------
// -------------------- getType --------------------
Viewer::ViewerType Viewer::getType() {
return type;
}
// -------------------- setLayout --------------------
// -------------------- setType --------------------
void Viewer::setType(Viewer::ViewerType type) {
this->type = type;
}
......
......@@ -98,7 +98,7 @@ public:
return description;
};
/// set the viewer layout
/// set the viewer layout (the type can be changed dynamically to fit the developer's purpose)
void setType(ViewerType);
/// get the viewer layout
......@@ -128,17 +128,17 @@ public:
/// refresh the view (can be interesting to know which other viewer is calling this)
virtual void refresh(Viewer* whoIsAsking = nullptr) = 0;
/// get the viewer property object (returns NULL by default, i.e. there are no property to edit)
/// get the viewer property object (returns nullptr by default, i.e. there are no property to edit)
virtual QObject* getPropertyObject() {
return nullptr;
};
/// get the viewer menu (returns NULL by default, i.e. there are no default edit menu)
/// get the viewer menu (returns nullptr by default, i.e. there are no default edit menu)
virtual QMenu* getMenu() {
return nullptr;
};
/// get the viewer toolbar (returns NULL by default, i.e. there are no default toolbar)
/// get the viewer toolbar (returns nullptr by default, i.e. there are no default toolbar)
virtual QToolBar* getToolBar() {
return nullptr;
};
......@@ -196,6 +196,9 @@ protected:
/// \note Default is set to "Component" (all type of components)
void setComponents(QStringList);
/// set the viewer's description
void setDescription(QString);
private:
/// current viewer's name
QString name;
......
......@@ -52,6 +52,8 @@ ActionViewer::ActionViewer(QString name) : Viewer(name, Viewer::DOCKED) {
setComponents(QStringList());
setIcon(QPixmap(":/play"));
setDescription("\"Action Viewer\" displays the currently selected action's GUI as well as an action selector");
}
// ---------------- destructor ----------------
......
......@@ -35,7 +35,7 @@
class ACTIONVIEWER_API ActionViewerExtension : public camitk::ViewerExtension {
Q_OBJECT
Q_INTERFACES(camitk::ViewerExtension);
Q_PLUGIN_METADATA(IID "fr.imag.camitk.actionviewerextension.viewer.actionviewerextension")
Q_PLUGIN_METADATA(IID "fr.imag.camitk.sdk.viewer.actionviewerextension")
public:
/// Constructor
......
......@@ -50,6 +50,8 @@ BitmapViewer::BitmapViewer(QString name) : InteractiveViewer(name, InteractiveVi
// can only display 2D bitmap = SingleImageComponent
setComponents(QStringList() << "SingleImageComponent");
setDescription("BitmapViewer is a simple 2D image viewer");
myWidget = nullptr;
myToolbar = nullptr;
}
......
......@@ -33,7 +33,7 @@
class BitmapViewerExtension : public camitk::ViewerExtension {
Q_OBJECT
Q_INTERFACES(camitk::ViewerExtension);
Q_PLUGIN_METADATA(IID "fr.imag.camitk.tutorials.viewer.bitmapviewerextension")
Q_PLUGIN_METADATA(IID "fr.imag.camitk.sdk.viewer.bitmapviewerextension")
public:
/// Constructor
......
......@@ -45,8 +45,10 @@ using namespace camitk;
//----------------------- constructor ------------------------
Explorer::Explorer(QString name) : Viewer(name, Viewer::DOCKED) {
setIcon(QPixmap(":/explorer"));
setDescription("The Explorer viewer shows all the instanciated components");
explorerTree = nullptr;
explorerMenu = nullptr;
explorerMenu = nullptr;
}
//----------------------- destructor ------------------------
......
......@@ -35,7 +35,7 @@
class EXPLORER_API ExplorerExtension : public camitk::ViewerExtension {
Q_OBJECT
Q_INTERFACES(camitk::ViewerExtension);
Q_PLUGIN_METADATA(IID "fr.imag.camitk.explorerextension.viewer.explorerextension")
Q_PLUGIN_METADATA(IID "fr.imag.camitk.sdk.viewer.explorerextension")
public:
/// Constructor
......
......@@ -38,6 +38,7 @@ using namespace camitk;
FrameExplorer::FrameExplorer(QString name) : Viewer(name, Viewer::DOCKED) {
explorerTree = nullptr;
setIcon(QPixmap(":/axes"));
setDescription("The frame explorer shows all the hierarchy of frames (which is independent from the hierarchy of components)");
}
//----------------------- getWidget ------------------------
......
......@@ -35,7 +35,7 @@
class FRAMEEXPLORER_API FrameExplorerExtension : public camitk::ViewerExtension {
Q_OBJECT
Q_INTERFACES(camitk::ViewerExtension);
Q_PLUGIN_METADATA(IID "fr.imag.camitk.frameexplorerextension.viewer.frameexplorerextension")
Q_PLUGIN_METADATA(IID "fr.imag.camitk.sdk.viewer.frameexplorerextension")
public:
/// Constructor
......
......@@ -30,4 +30,8 @@ using namespace camitk;
// -------------------- Constructor --------------------
InteractiveGeometryViewer::InteractiveGeometryViewer(QString name) : InteractiveViewer(name, InteractiveViewer::GEOMETRY_VIEWER) {
// nothing special to do, everything is defined by the InteractiveViewer type
// set the description for the specific "3D Viewer"
if (name == "3D Viewer") {
setDescription("Default 3D viewers that shows the component that have a geometry or bitmap representation");
}
}
......@@ -35,7 +35,7 @@
class INTERACTIVEGEOMETRYVIEWER_API InteractiveGeometryViewerExtension : public camitk::ViewerExtension {
Q_OBJECT
Q_INTERFACES(camitk::ViewerExtension);
Q_PLUGIN_METADATA(IID "fr.imag.camitk.interactivegeometryviewerextension.viewer.interactivegeometryviewerextension")
Q_PLUGIN_METADATA(IID "fr.imag.camitk.sdk.viewer.interactivegeometryviewerextension")
public:
/// Constructor
......
......@@ -35,6 +35,7 @@ InteractiveSliceViewer::InteractiveSliceViewer(QString name) : InteractiveViewer
if (name == "Axial Viewer") {
// Axial Viewer
setDescription("Default slice viewer that displays the axial slices");
getRendererWidget()->setCameraOrientation(RendererWidget::RIGHT_DOWN);
QString letters[4] = { QString("R"), QString("L"), QString("A"), QString("P") };
getRendererWidget()->setOrientationDecorationsLetters(letters);
......@@ -44,6 +45,7 @@ InteractiveSliceViewer::InteractiveSliceViewer(QString name) : InteractiveViewer
else {
if (name == "Coronal Viewer") {
// Coronal Viewer
setDescription("Default slice viewer that displays the coronal slices");
getRendererWidget()->setCameraOrientation(RendererWidget::LEFT_BACK);
QString letters[4] = { QString("R"), QString("L"), QString("S"), QString("I") };
getRendererWidget()->setOrientationDecorationsLetters(letters);
......@@ -53,6 +55,7 @@ InteractiveSliceViewer::InteractiveSliceViewer(QString name) : InteractiveViewer
else {
if (name == "Sagittal Viewer") {
// Sagittal Viewer
setDescription("Default slice viewer that displays the sagittal slices");
getRendererWidget()->setCameraOrientation(RendererWidget::BACK_DOWN);
QString letters[4] = { QString("A"), QString("P"), QString("S"), QString("I") };
getRendererWidget()->setOrientationDecorationsLetters(letters);
......@@ -62,6 +65,7 @@ InteractiveSliceViewer::InteractiveSliceViewer(QString name) : InteractiveViewer
else {
if (name == "Arbitrary Viewer") {
// Arbitrary Viewer
setDescription("Default slice viewer that displays the arbitrary orientation slices");
toggleOrientationDecorations(false);
}
}
......
......@@ -35,7 +35,7 @@
class INTERACTIVESLICEVIEWER_API InteractiveSliceViewerExtension : public camitk::ViewerExtension {
Q_OBJECT
Q_INTERFACES(camitk::ViewerExtension);
Q_PLUGIN_METADATA(IID "fr.imag.camitk.interactivesliceviewerextension.viewer.interactivesliceviewerextension")
Q_PLUGIN_METADATA(IID "fr.imag.camitk.sdk.viewer.interactivesliceviewerextension")
public:
/// Constructor
......
......@@ -40,6 +40,7 @@ using namespace camitk;
// -------------------- Constructor --------------------
MedicalImageViewer::MedicalImageViewer(QString name) : Viewer(name) {
setDescription("The Medical Image Viewer embeds all classical medical image views (axial, sagittal, coronal, 3D and arbitrary orientation)");
// init view members
frame = nullptr;
frameLayout = nullptr;
......
......@@ -35,7 +35,7 @@
class MEDICALIMAGEVIEWER_API MedicalImageViewerExtension : public camitk::ViewerExtension {
Q_OBJECT
Q_INTERFACES(camitk::ViewerExtension);
Q_PLUGIN_METADATA(IID "fr.imag.camitk.medicalimageviewerextension.viewer.medicalimageviewerextension")
Q_PLUGIN_METADATA(IID "fr.imag.camitk.sdk.viewer.medicalimageviewerextension")
public:
/// Constructor
......
......@@ -47,6 +47,7 @@ PropertyExplorer::PropertyExplorer(QString name) : Viewer(name, Viewer::DOCKED)
currentComponent = nullptr;
setIcon(QPixmap(":/properties"));
setDescription("The property explorer shows the properties of the currently selected component");
createProperties();
}
......
......@@ -35,7 +35,7 @@
class PROPERTYEXPLORER_API PropertyExplorerExtension : public camitk::ViewerExtension {
Q_OBJECT
Q_INTERFACES(camitk::ViewerExtension);
Q_PLUGIN_METADATA(IID "fr.imag.camitk.propertyexplorerextension.viewer.propertyexplorerextension")
Q_PLUGIN_METADATA(IID "fr.imag.camitk.sdk.viewer.propertyexplorerextension")
public:
/// Constructor
......@@ -51,7 +51,7 @@ public:
/// Method returning the viewer extension descrption
virtual QString getDescription() {
return "The property explorer shows the propreties of the currently selected component";
return "The property explorer shows the properties of the currently selected component";
};
/// initialize all the viewers
......
......@@ -38,6 +38,7 @@ using namespace camitk;
MixedViewer::MixedViewer(QString name) : Viewer(name) {
myWidget = nullptr;
setComponents(QStringList() << "ImageComponent" << "MixedComponent");
setDescription("A two panels viewer (left is axial, right is 3D), specialized in mixed component");
}
// -------------------- Destructor --------------------
......
......@@ -48,7 +48,7 @@ public:
/// Method returning the action extension descrption
virtual QString getDescription() {
return "An extension that brings a pure text viewer called... MixedViewer";
return "An extension that provides a two panels viewer (left is axial, right is 3D), specialized in mixed component";
};
/// initialize all the actions
......
......@@ -42,6 +42,7 @@ TextViewer::TextViewer(QString name) : Viewer(name, Viewer::DOCKED) {
myWidget = nullptr;
displayedTopLevelComponents = 0;
setIcon(QPixmap(":/textviewer"));
setDescription("This text only viewer displays the number of opened components (docked by default)");
}
// -------------------- Destructor --------------------
......
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