Commit ff4c6426 authored by Emmanuel Promayon's avatar Emmanuel Promayon

NEW simplified viewer API: type is either DOCKED or EMBEDDED

STACKED was just a specific case of EMBEDDED
parent 2d6c29e6
......@@ -136,7 +136,7 @@ void ReorientImage::initDialog() {
//-- add the internal viewer
initInternalViewer();
internalViewer->embedIn(ui.illustrationLayout);
internalViewer->setEmbedder(ui.illustrationLayout);
ui.xDirection->setTextFormat(Qt::RichText);
ui.yDirection->setTextFormat(Qt::RichText);
......@@ -191,7 +191,6 @@ void ReorientImage::initInternalViewer() {
// Set up the 3D viewer to visualize actual origin/orientation locations
internalViewer = dynamic_cast<InteractiveGeometryViewer*>(Application::getNewViewer("Image Orientation Viewer", "InteractiveGeometryViewer"));
internalViewer->setLayout(Viewer::EMBEDDED);
internalViewer->setHighlightMode(InteractiveViewer::OFF);
internalViewer->toggleCopyright(false);
internalViewer->getRendererWidget()->setCameraOrientation(RendererWidget::RIGHT_DOWN);
......
......@@ -34,8 +34,7 @@
#include "ActionStateViewer.h"
// ---------------- constructor ----------------
ActionStateViewer::ActionStateViewer(QString name) : Viewer(name) {
setLayout(Viewer::DOCKED);
ActionStateViewer::ActionStateViewer(QString name) : Viewer(name, Viewer::DOCKED) {
myWidget = nullptr;
// empty the list as this is a state viewer, it has nothing to do with Components
setComponents(QStringList());
......
......@@ -70,14 +70,13 @@ ImpMainWindow::ImpMainWindow() : MainWindow("imp") {
updateActionStates();
// now add the different viewers
setCentralViewer(Application::getViewer("BitmapViewer"));
setCentralViewer(Application::getViewer("MedicalImageViewer"));
addDockViewer(Qt::LeftDockWidgetArea, Application::getViewer("Explorer"));
addDockViewer(Qt::LeftDockWidgetArea, Application::getViewer("FrameExplorer"));
addDockViewer(Qt::LeftDockWidgetArea, Application::getViewer("PropertyExplorer"));
addDockViewer(Qt::RightDockWidgetArea, Application::getViewer("ActionViewer"));
//Merge Explorer and FrameExplorer viewers in one layout
// Merge Explorer and FrameExplorer viewers in one layout
QDockWidget* dockWidgetExplorer = dockWidgetMap.value(Application::getViewer("Explorer"), nullptr);
QDockWidget* dockWidgetFrameExplorer = dockWidgetMap.value(Application::getViewer("FrameExplorer"), nullptr);
......@@ -476,31 +475,11 @@ void ImpMainWindow::updateViewMenu() {
QMenu* toggleCentralWidgetMenu = viewMenu->addMenu(tr("Toggle Central Viewer"));
// add an action for each viewer of layout "stacked"
foreach (Viewer* viewer, viewers) {
// only add viewer that are not docked
if (viewer->getLayout() == Viewer::STACKED) {
// viewerAction is own by viewMenu, viewMenu->clear() will delete it
QAction* viewerAction = toggleCentralWidgetMenu->addAction(viewer->getName());
viewerAction->setCheckable(true);
viewerAction->setChecked(viewer == centralViewer);
viewerAction->setIcon(viewer->getIcon());
QString tipString = "Hide/show the " + viewer->getName() + " in the 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(viewer);
});
}
}
toggleCentralWidgetMenu-> addSeparator();
// add other viewers that are not initially part of imp, but that are
// added by supplementary viewer extensions
foreach (Viewer* viewer, Application::getViewers()) {
if (!viewers.contains(viewer) && viewer->getLayout() == Viewer::STACKED) {
// only control the embedded viewer that are not already embedded somewhere or is already in the centralViewer stack
if (viewer->getType() == Viewer::EMBEDDED && (viewer->getEmbedder() == centralWidget()->layout() || viewer->getEmbedder() == nullptr)) {
// viewerAction is own by viewMenu, viewMenu->clear() will delete it
QAction* viewerAction = toggleCentralWidgetMenu->addAction(viewer->getName());
viewerAction->setCheckable(true);
......
......@@ -45,11 +45,11 @@
#include <QUrl>
#include <QCloseEvent>
#include <QMimeData>
#include <QStackedWidget>
#include <QStackedLayout>
namespace camitk {
// ------------- constructor -----------------
MainWindow::MainWindow(QString title) {
MainWindow::MainWindow(QString title) : QMainWindow() {
// set window title
mainTitle = title;
setWindowTitle(title);
......@@ -62,7 +62,7 @@ MainWindow::MainWindow(QString title) {
// add permanent widget to the status bar (toggle console and progress bar)
QWidget* statusBarAdditionalWidget = new QWidget();
QGridLayout* layout = new QGridLayout(statusBarAdditionalWidget);
QGridLayout* statusBarLayout = new QGridLayout(statusBarAdditionalWidget);
// if actions are available, add a toggle console
Action* toggleAction = Application::getAction("Toggle Log Console");
......@@ -71,12 +71,12 @@ MainWindow::MainWindow(QString title) {
auto* toggleConsole = new QToolBar();
toggleConsole->addAction(toggleAction->getQAction());
layout->addWidget(toggleConsole, 0, 0, 1, 1, Qt::AlignVCenter | Qt::AlignLeft);
statusBarLayout->addWidget(toggleConsole, 0, 0, 1, 1, Qt::AlignVCenter | Qt::AlignLeft);
}
myProgressBar = new QProgressBar();
myProgressBar->setMaximum(100);
layout->addWidget(myProgressBar, 0, 1, 1, 1, Qt::AlignVCenter | Qt::AlignRight);
statusBarLayout->addWidget(myProgressBar, 0, 1, 1, 1, Qt::AlignVCenter | Qt::AlignRight);
statusBar()->addPermanentWidget(statusBarAdditionalWidget); // myProgressBar, 0);
......@@ -161,10 +161,13 @@ MainWindow::MainWindow(QString title) {
consoleWindow->hide();
addDockWidget(Qt::BottomDockWidgetArea, consoleWindow);
// create the default (empty) central widget inside which the central viewers can be added
centralWidget = new QStackedWidget(this);
centralWidget->setObjectName("MainWindow Central Widget");
setCentralWidget(centralWidget);
// create the default (empty) central widget's layout inside which the central viewers can be embedded.
// (for viewer debugging purpose it is a good idea to name the layout)
centralLayout = new QStackedLayout();
centralLayout->setObjectName("MainWindow Central Layout");
QFrame *centralFrame = new QFrame();
centralFrame->setLayout(centralLayout);
setCentralWidget(centralFrame);
centralViewer = nullptr;
// accept drag and drop events
......@@ -257,15 +260,18 @@ void MainWindow::refreshViewers() {
void MainWindow::addDockViewer(Qt::DockWidgetArea dockingArea, Viewer* theViewer) {
if (addViewer(theViewer)) {
// create the dock widget and insert it only if the viewer has a widget
QDockWidget* viewerDock = theViewer->dockIn();
QDockWidget* viewerDock = new QDockWidget();
if (viewerDock) {
if (theViewer->setDockWidget(viewerDock)) {
// add the dock
addDockWidget(dockingArea, viewerDock);
// update the map
dockWidgetMap.insert(theViewer, viewerDock);
}
else {
delete viewerDock;
}
}
......@@ -288,13 +294,13 @@ void MainWindow::setCentralViewer(Viewer* theViewer) {
centralViewer = theViewer;
// stack the viewer inside the central viewer
centralViewer->stackIn(centralWidget);
centralViewer->setEmbedder(centralLayout);
// show its toolbar
showViewerToolbar(centralViewer, true);
// save current central viewer in the settings (only if the central widget is visible
if (centralWidget->isVisible()) {
if (centralWidget()->isVisible()) {
QSettings& settings = Application::getSettings();
settings.beginGroup(Application::getName() + ".MainWindow");
settings.setValue("centralViewer", centralViewer->getName());
......
......@@ -38,7 +38,7 @@
#include <QTextEdit>
#include <QProgressBar>
#include <QStatusBar>
#include <QStackedWidget>
#include <QStackedLayout>
namespace camitk {
......@@ -60,10 +60,8 @@ class Viewer;
*
* See tutorials applications for examples.
*
* The central widget is a QStackWidget: when new central viewers are added, the previous central
* viewer is hidden, not destroyed. See the "switchviewer" action tutorial for some example on
* how to embed an new central viewer to the imp main window (and switch back to medical image viewer
* whenever required).
* The central widget's layout is a QStackedLayout: when new central viewers are added, the previous central
* viewer is hidden, not destroyed.
*/
class CAMITK_API MainWindow : public QMainWindow {
Q_OBJECT
......@@ -268,8 +266,9 @@ private:
/// the main part of the title
QString mainTitle;
/// the central widget is a QStackedWidget
QStackedWidget* centralWidget;
/// the central widget is a frame, its layout is a QStackedLayout so that
/// it is possible to easily switch between viewers
QStackedLayout* centralLayout;
};
}
......
......@@ -420,7 +420,7 @@ QMenu* Component::getActionMenu() {
for (Viewer* viewer : allViewers) {
// show only embedded or stacked viewers
if (viewer->getLayout() != Viewer::DOCKED) {
if (viewer->getType() != Viewer::DOCKED) {
// viewerAction is own by visibilityMenu, visibilityMenu.clear() will delete it
QAction* visibilityAction = visibilityMenu->addAction(viewer->getName());
visibilityAction->setCheckable(true);
......
......@@ -31,20 +31,19 @@
#include "Log.h"
#include <QDockWidget>
#include <QStackedWidget>
#include <QStackedLayout>
#include <QLayout>
namespace camitk {
//---------------------- constructor ------------------------
Viewer::Viewer(QString name): QObject() {
Viewer::Viewer(QString name, ViewerType type): QObject() {
this->name = name;
setObjectName(name);
this->type = type;
layout = STACKED;
dockedWidget = nullptr;
stackedWidget = nullptr;
embeddedLayout = nullptr;
dockWidget = nullptr;
embedder = nullptr;
toolbarVisibility = true;
......@@ -53,7 +52,6 @@ Viewer::Viewer(QString name): QObject() {
//---------------------- destructor ------------------------
Viewer::~Viewer() {
delete dockedWidget;
}
// -------------------- setIcon --------------------
......@@ -108,68 +106,69 @@ bool Viewer::getToolBarVisibility() {
}
// -------------------- getLayout --------------------
Viewer::ViewerLayout Viewer::getLayout() {
return layout;
Viewer::ViewerType Viewer::getType() {
return type;
}
// -------------------- setLayout --------------------
void Viewer::setLayout(Viewer::ViewerLayout layout) {
this->layout = layout;
void Viewer::setType(Viewer::ViewerType type) {
this->type = type;
}
// -------------------- dockIn --------------------
QDockWidget* Viewer::dockIn() {
if (layout != DOCKED) {
CAMITK_ERROR(tr("Cannot dock \"%1\": it does not have a DOCKED layout").arg(name))
return nullptr;
// -------------------- setDockWidget --------------------
bool Viewer::setDockWidget(QDockWidget* dockWidget) {
if (type != DOCKED) {
CAMITK_ERROR(tr("Cannot dock \"%1\": it is not a DOCKED type viewer").arg(name))
return false;
}
// create the dock widget and insert it only if the viewer has a widget
if (getWidget() != nullptr && dockedWidget == nullptr) {
// create the dock
dockedWidget = new QDockWidget(name);
dockedWidget->setObjectName(name);
// add the widget
dockedWidget->setWidget(getWidget());
else {
// create the dock widget and insert it only if the viewer has a widget
if (getWidget() != nullptr && this->dockWidget == nullptr) {
// set the object name and the visible window title
dockWidget->setObjectName(name);
dockWidget->setWindowTitle(name);
// add the widget
dockWidget->setWidget(getWidget());
// store the pointer
this->dockWidget = dockWidget;
return true;
}
return false;
}
return dockedWidget;
}
// -------------------- stackIn --------------------
void Viewer::stackIn(QStackedWidget* stackedWidget) {
if (layout != STACKED) {
CAMITK_ERROR(tr("Cannot stack \"%1\": it does not have a STACKED layout").arg(name))
return;
}
// -------------------- getDockWidget --------------------
QDockWidget* Viewer::getDockWidget() {
return dockWidget;
}
// check all conditions are met
if (getWidget() != nullptr) {
// add the viewer's widget inside the stack
stackedWidget->addWidget(getWidget());
// keep the pointer
this->stackedWidget = stackedWidget;
// -------------------- setEmbedder --------------------
bool Viewer::setEmbedder(QLayout* embedder) {
if (type != EMBEDDED) {
CAMITK_ERROR(tr("Cannot embed \"%1\": it is not a EMBEDDED type viewer").arg(name))
return false;
}
// refresh the widget
if (this->stackedWidget != nullptr) {
this->stackedWidget->setCurrentWidget(getWidget());
else {
// check all conditions are met
if (getWidget() != nullptr) {
embedder->addWidget(getWidget());
// keep the pointer
this->embedder = embedder;
// If it is a QStackedLayout, we need to call setCurrentWidget in order
// to put back the viewer's widget on top of the stack
QStackedLayout* stackEmbedder = qobject_cast<QStackedLayout*>(embedder);
if (stackEmbedder != nullptr) {
stackEmbedder->setCurrentWidget(getWidget());
}
return true;
}
return false;
}
}
// -------------------- embedIn --------------------
void Viewer::embedIn(QLayout* embeddedLayout) {
if (layout != EMBEDDED) {
CAMITK_ERROR(tr("Cannot embed \"%1\": it does not have a EMBEDDED layout").arg(name))
return;
}
// check all conditions are met
if (getWidget() != nullptr) {
embeddedLayout->addWidget(getWidget());
// keep the pointer
this->embeddedLayout = embeddedLayout;
}
// -------------------- getEmbedder --------------------
QLayout* Viewer::getEmbedder() {
return embedder;
}
// -------------------- setVisible --------------------
......
......@@ -39,7 +39,6 @@ class QMenu;
class QPixMap;
class QWidget;
class QDockWidget;
class QStackedWidget;
class QLayout;
namespace camitk {
......@@ -51,37 +50,43 @@ class Property;
* @ingroup group_sdk_libraries_core_viewer
*
* @brief
* Viewer is an abstract viewer.
* Viewer is an abstract class that is the base class for all viewers.
*
* A viewer can contains other viewers, example of viewer are: Explorer, PropertyExplorer, MedicalImageViewer.
* There are two types of viewers:
* - the embedded viewer (their widgets are inside a given layout), this is the default type
* - the docked viewer (their widgets are inside a dock widget).
*
* A viewer can embed other viewers.
* Example of viewer are: Explorer, PropertyExplorer, MedicalImageViewer.
*
* A viewer can be added to MainWindow, MainWindow will include its menu in the "View" menu and its toolbar in
* the application toolbar.
*
* The default viewed component are set so that the viewer is updated every time the current component selection
* is modified.
* If your viewer does not view components (for instance, in the very rare/special case it views actions)
*
* If your viewer does not view components (for instance, in the very rare/special case it views actions),
* then you need to call the setComponents(...) method with an empty list.
* An empty list means that this viewer is going to be notified/refreshed for every changes in the
* current action selection as well (i.e., anytime an action is triggered)
* An empty list means that this viewer is going to be also notified/refreshed every time the
* current selected action is changed (i.e., anytime an action is triggered)
*/
class CAMITK_API Viewer : public QObject {
Q_OBJECT
public:
/// \enum ViewerType describes where this viewer should appear
enum ViewerType {
EMBEDDED, ///< this viewer is meant to be embedded inside a layout (of another viewer or widget), use embedIn(..) to set the layout it is embedded in (this is the default viewer type)
DOCKED, ///< this viewer is meant to be docked, use dockIn() to get the dock widget
};
/// default constructor
Viewer(QString name);
Viewer(QString name, ViewerType type = EMBEDDED);
/// default destructor
virtual ~Viewer() override;
/// \enum ViewerLayout describes where this viewer should appear
enum ViewerLayout {
DOCKED, ///< this viewer is meant to be docked, use dockIn() to get the dock widget
STACKED, ///< this viewer is meant to be inside a stacked widget (for instance the central viewer), use stackIn() to set the stacked widget it is in
EMBEDDED, ///< this viewer is meant to be embedded inside a layout (of another viewer or widget), use embedIn(..) to set the layout it is embedded in
};
/// get the name of the viewer
QString getName() const {
return name;
......@@ -93,20 +98,31 @@ public:
};
/// set the viewer layout
void setLayout(ViewerLayout);
void setType(ViewerType);
/// get the viewer layout
ViewerLayout getLayout();
/// Create the dock widget and dock the viewer widget in it (return nullptr if this viewer has not a DOCKED layout)
QDockWidget* dockIn();
ViewerType getType();
/// If the viewer type is DOCKED, dock the widget inside the given dock widget (do nothing if the type is EMBEDDED or
/// if the viewer has already been docked before)
/// Note that once set, the dock widget cannot be modified.
/// The dock widget object's name, window title and icons are modified using the viewer's name and icon
/// @return true if the docking operation was successful
bool setDockWidget(QDockWidget*);
/// Get the QDockWidget* where this viewer is currently docked (or nullptr if it is not docked anywhere
/// or if the viewer is of type EMBEDDED)
QDockWidget* getDockWidget();
/// show the viewer's widget in the stack
/// If it is the first call, add the viewer widget in the given stack
void stackIn(QStackedWidget*);
/// If the viewer type is EMBEDDED, embed the viewer widget in the given layout (do nothing if the type is DOCKED)
/// Note that you can call this method any time you want to move the viewer's widget to another layout (but
/// there is only one embedder at a time)
/// @return true if the embedding operation was successful
bool setEmbedder(QLayout*);
/// Add the viewer widget in the given layout
void embedIn(QLayout*);
/// Get the QLayout* where this viewer is currently embedded (or nullptr if it is not embedded anywhere
/// or if the viewer is of type DOCKED)
QLayout* getEmbedder();
/// refresh the view (can be interesting to know which other viewer is calling this)
virtual void refresh(Viewer* whoIsAsking = nullptr) = 0;
......@@ -128,7 +144,7 @@ public:
/// set the visibility of the viewer (show or hide its widget)
void setVisible(bool);
/** set the visibility of the toolbar in the main window (true by default).
* If the visibility is set to false, the next call to setCentralViewer(..) or addDockViwer(...) will remove it
*/
......@@ -156,7 +172,7 @@ signals:
protected:
/// get the viewer widget.
/// this method is protected and to be redefined in the inheriting class.
/// \note to show the viewer's widget in the GUI, use dockIn(), stackIn(..) or embedIn(...)
/// \note to show the viewer's widget in the GUI, use dockIn() or embedIn(...)
/// to set where the viewer is displayed
virtual QWidget* getWidget() = 0;
......@@ -196,17 +212,13 @@ private:
QStringList components;
/// this viewer's layout
ViewerLayout layout;
/// if layout is DOCKED, then this is the dock widget
QDockWidget* dockedWidget;
/// if layout is embedded, then this is the QLayout it is embedded in
QLayout* embeddedLayout;
ViewerType type;
/// the QAction that will allow it to be set as the central viewer
QStackedWidget* stackedWidget;
/// if layout is of type DOCKED, then this is the widget where the viewer's widget is docked
QDockWidget* dockWidget;
/// if layout is of type EMBEDDED, this is the layout where the viewer's widget is embedded in
QLayout* embedder;
};
}
......
......@@ -41,8 +41,7 @@
using namespace camitk;
// ---------------- constructor ----------------
ActionViewer::ActionViewer(QString name) : Viewer(name) {
setLayout(Viewer::DOCKED);
ActionViewer::ActionViewer(QString name) : Viewer(name, Viewer::DOCKED) {
myWidget = nullptr;
familyComboBox = nullptr;
nameComboBox = nullptr;
......
......@@ -43,8 +43,7 @@
using namespace camitk;
//----------------------- constructor ------------------------
Explorer::Explorer(QString name) : Viewer(name) {
setLayout(Viewer::DOCKED);
Explorer::Explorer(QString name) : Viewer(name, Viewer::DOCKED) {
setIcon(QPixmap(":/explorer"));
explorerTree = nullptr;
explorerMenu = nullptr;
......
......@@ -35,8 +35,7 @@
using namespace camitk;
//----------------------- constructor ------------------------
FrameExplorer::FrameExplorer(QString name) : Viewer( name) {
setLayout(Viewer::DOCKED);
FrameExplorer::FrameExplorer(QString name) : Viewer(name, Viewer::DOCKED) {
explorerTree = nullptr;
}
......
......@@ -29,8 +29,5 @@ using namespace camitk;
// -------------------- Constructor --------------------
InteractiveGeometryViewer::InteractiveGeometryViewer(QString name) : InteractiveViewer(name, InteractiveViewer::GEOMETRY_VIEWER) {
if (name == "3DViewer") {
// the default 3D Viewer is embedded
setLayout(Viewer::EMBEDDED);
}
// nothing special to do, everything is defined by the InteractiveViewer type
}
......@@ -35,7 +35,6 @@ InteractiveSliceViewer::InteractiveSliceViewer(QString name) : InteractiveViewer
if (name == "axialViewer") {
// Axial Viewer
setLayout(Viewer::EMBEDDED);
getRendererWidget()->setCameraOrientation(RendererWidget::RIGHT_DOWN);
QString letters[4] = { QString("R"), QString("L"), QString("A"), QString("P") };
getRendererWidget()->setOrientationDecorationsLetters(letters);
......@@ -45,7 +44,6 @@ InteractiveSliceViewer::InteractiveSliceViewer(QString name) : InteractiveViewer
else {
if (name == "coronalViewer") {
// Coronal Viewer
setLayout(Viewer::EMBEDDED);
getRendererWidget()->setCameraOrientation(RendererWidget::LEFT_BACK);
QString letters[4] = { QString("R"), QString("L"), QString("S"), QString("I") };
getRendererWidget()->setOrientationDecorationsLetters(letters);
......@@ -55,7 +53,6 @@ InteractiveSliceViewer::InteractiveSliceViewer(QString name) : InteractiveViewer
else {
if (name == "sagittalViewer") {
// Sagittal Viewer
setLayout(Viewer::EMBEDDED);
getRendererWidget()->setCameraOrientation(RendererWidget::BACK_DOWN);
QString letters[4] = { QString("A"), QString("P"), QString("S"), QString("I") };
getRendererWidget()->setOrientationDecorationsLetters(letters);
......@@ -65,7 +62,6 @@ InteractiveSliceViewer::InteractiveSliceViewer(QString name) : InteractiveViewer
else {
if (name == "arbitraryViewer") {
// Arbitrary Viewer
setLayout(Viewer::EMBEDDED);
toggleOrientationDecorations(false);
}
}
......
......@@ -61,6 +61,7 @@ MedicalImageViewer::~MedicalImageViewer() {
viewerMenu->clear();
delete viewerMenu;
}
delete frame;
}
......@@ -75,10 +76,12 @@ void MedicalImageViewer::refresh(Viewer* whoIsAsking) {
if (displayedTopLevelComponents != (unsigned) Application::getTopLevelComponents().size()) {
// Check if there is ImageComponent, if yes show all viewers
int i = 0;
while (i<Application::getTopLevelComponents().size() && !Application::getTopLevelComponents().at(i)->isInstanceOf("ImageComponent")) {
while (i < Application::getTopLevelComponents().size() && !Application::getTopLevelComponents().at(i)->isInstanceOf("ImageComponent")) {
i++;
}
if (i<Application::getTopLevelComponents().size()) {
if (i < Application::getTopLevelComponents().size()) {
visibleLayout = VIEWER_ALL;
}
else {
......@@ -136,16 +139,17 @@ QWidget* MedicalImageViewer::getWidget() {
}
}
//-- show the correct viewer
updateLayout();
}
// always re-embed the viewers (in case another viewer embeded them somewhere else in the meanwhile)
Application::getViewer("axialViewer")->embedIn(northWestLayout);
Application::getViewer("coronalViewer")->embedIn(southWestLayout);
Application::getViewer("sagittalViewer")->embedIn(southEastLayout);
Application::getViewer("3DViewer")->embedIn(northEastLayout);
Application::getViewer("arbitraryViewer")->embedIn(northEastLayout);
Application::getViewer("axialViewer")->setEmbedder(northWestLayout);
Application::getViewer("coronalViewer")->setEmbedder(southWestLayout);
Application::getViewer("sagittalViewer")->setEmbedder(southEastLayout);
Application::getViewer("3DViewer")->setEmbedder(northEastLayout);
Application::getViewer("arbitraryViewer")->setEmbedder(northEastLayout);
//-- show the correct viewer
updateLayout();
return frame;
}
......
......@@ -39,8 +39,7 @@
using namespace camitk;
// ---------------- constructor ----------------
PropertyExplorer::PropertyExplorer(QString name) : Viewer(name) {
setLayout(Viewer::DOCKED);
PropertyExplorer::PropertyExplorer(QString name) : Viewer(name, Viewer::DOCKED) {
theController = nullptr;
tabWidget = nullptr;
revertButton = nullptr;
......
......@@ -35,10 +35,7 @@ int main(int argc, char* argv[]) {
// create a camitk application
Application a("basic", argc, argv);
// add an axial viewer to the default main window
// in order to add it to the main window, we need to extract it first from the medical viewer
// (that's what setLayout is doing)
Application::getViewer("axialViewer")->setLayout(Viewer::STACKED);
// add the default axial viewer to the default main window
a.getMainWindow()->setCentralViewer(Application::getViewer("axialViewer"));
// open an image volume
......
......@@ -55,8 +55,7 @@ FancyMainWindow::FancyMainWindow() : MainWindow("Fancy") {
// add the medical image viewer
visibility = MedicalImageViewer::VIEWER_AXIAL;
// for this application, force the medical image viewer to be embedded
Application::getViewer("MedicalImageViewer")->setLayout(Viewer::EMBEDDED);
Application::getViewer("MedicalImageViewer")->embedIn(ui.viewer);
Application::getViewer("MedicalImageViewer")->setEmbedder(ui.viewer);
// hide slide bar and modify the color and background
dynamic_cast<InteractiveViewer*>(Application::getViewer("axialViewer"))->setSideFrameVisible(false);
......@@ -76,8 +75,7 @@ FancyMainWindow::FancyMainWindow() : MainWindow("Fancy") {
// to true during refresh, as by default, the component does not know about it
// and its visibility is false)
viewer3D = dynamic_cast<InteractiveGeometryViewer*>(Application::getNewViewer("small3DViewer", "InteractiveGeometryViewer"));
viewer3D->setLayout(Viewer::EMBEDDED);
viewer3D->embedIn(ui.viewer3DLayout);
viewer3D->setEmbedder(ui.viewer3DLayout);
viewer3D->setSideFrameVisible(false);
viewer3D->setGradientBackground(false);
viewer3D->setBackgroundColor(ui.dial->palette().background().color());
......
......@@ -72,7 +72,6 @@ MyAppMainWindow::MyAppMainWindow() : MainWindow("MyApp - " + tr(Core::version))
// now add the different viewers
addDockViewer(Qt::LeftDockWidgetArea, Application::getViewer("Explorer"));
// get the default 3D viewer out of the MedicalImageViewer and put it directly in the central viewer
Application::getViewer("3DViewer")->setLayout(Viewer::STACKED);
setCentralViewer(Application::getViewer("3DViewer"));
addDockViewer(Qt::RightDockWidgetArea, Application::getViewer("ActionViewer"));
showDockViewer(Application::getViewer("ActionViewer"), false);
......
......@@ -47,28 +47,31 @@ MixedViewer::~MixedViewer() {
// -------------------- refresh --------------------
void MixedViewer::refresh(Viewer*) {
// nothing to do as everything is already done by the MedicalImageViewer!
// nothing to do as everything is already done by the MedicalImageViewer!
// just make sure the viewers are both visible (after all this is a mixed viewer)
Application::getViewer("axialViewer")->setVisible(true);
Application::getViewer("3DViewer")->setVisible(true);
}
// -------------------- getWidget --------------------
QWidget* MixedViewer::getWidget() {
if (!myWidget) {