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 ca1f4ae2 authored by Emmanuel Promayon's avatar Emmanuel Promayon
Browse files

NEW MainWindow's central viewer is now a stack widget

This simplify the modification of the central viewer (for
instance to add a custom viewer easily to camitk-imp or
any other camitk::Application
parent d46cbc8e
......@@ -45,6 +45,7 @@
#include <QUrl>
#include <QCloseEvent>
#include <QMimeData>
#include <QStackedWidget>
namespace camitk {
// ------------- constructor -----------------
......@@ -203,20 +204,6 @@ bool MainWindow::addViewer(Viewer* theViewer) {
// ------------- removeViewer -----------------
bool MainWindow::removeViewer(Viewer* viewer) {
if (!viewers.contains(viewer)) {
return false;
// tell all component not to be visible anymore in this viewer
foreach (Component* comp, Application::getAllComponents()) {
comp->setVisibility(viewer, false);
// remove it properly
disconnect(viewer, SIGNAL(selectionChanged()), this, SLOT(refresh()));
delete viewer;
return true;
......@@ -260,14 +247,20 @@ void MainWindow::addDockViewer(Qt::DockWidgetArea dockingArea, Viewer* theViewer
// ------------- setCentralViewer -----------------
void MainWindow::setCentralViewer(Viewer* theViewer) {
if (theViewer->getWidget(this) && addViewer(theViewer)) {
// remove actual central viewer properly
if (centralViewer && (theViewer != centralViewer)) {
// get the viewer widget (must have something to show as it is a viewer after all!)
QWidget *viewerWidget = theViewer->getWidget(this);
if (viewerWidget != nullptr) {
// add the viewer to the list (if not already in the list)
// if needed, create the default (empty) central widget inside which the central viewers can be added
if (centralWidget()==0) {
setCentralWidget(new QStackedWidget(this));
// set the central widget
// add the widget to the central widget
centralViewer = theViewer;
......@@ -50,14 +50,20 @@ class Viewer;
* @ingroup group_sdk_libraries_core_application
* @brief
* This Class is the base class for your application. It sets up the main
* window and providing a menubar, toolbar and statusbar (all hidden).
* This class is the base class for your application. It sets up the main
* window and creates a menubar, toolbar and statusbar (all hidden by default).
* It is the default main window for a application.
* Create a class that inherits from MainWindow to
* get all the goodies of Core and add your own customization/UI.
* See applications for examples.
* get all the goodies of CamiTK and add your own customization/UI.
* 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).
class CAMITK_API MainWindow : public QMainWindow {
......@@ -184,13 +190,21 @@ protected:
/// just call open with the dragged uri
void dropEvent(QDropEvent* event) override;
* TODO CAMITK_DEPRECATED. This section list all the methods marked as deprecated. They are to be removed in CamiTK 5.0
* @deprecated
* Removing viewers can be harmful. Central viewer is now simply hidden, therefore there is no need to remove it.
* It will keep itself refreshed and when shown again will be up to date.
* DEPRECATED (CamiTK 5.0) -> to be removed
* @brief Remove the given viewer from the list of viewer.
* @note This tell all Component not to be visible anymore in this viewer instance, remove it from the list of viewers and delete it.
* @param viewer The viewer to remove.
* @return True if removing succeeded, false otherwise.
bool removeViewer(Viewer* viewer);
* @brief The actual central Viewer.
......@@ -227,6 +241,7 @@ private:
/// the main part of the title
QString mainTitle;
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