...
 
Commits (3)
......@@ -52,11 +52,6 @@ public:
/// get the viewer widget.
virtual QWidget* getWidget();
/// returns the number of Component that are displayed by this viewer
virtual unsigned int numberOfViewedComponent() {
return 0;
};
/// refresh the view (can be interesting to know which other viewer is calling this)
virtual void refresh(Viewer* whoIsAsking = nullptr) {};
......
......@@ -22,13 +22,13 @@ set -e
# values to check
initTestData() {
# fill test data
extensionCount=( [4.2]=52 [4.1]=41 [4.0]=31 )
extensionCount=( [4.2]=53 [4.1]=41 [4.0]=31 )
componentExtensionCount=( [4.2]=14 [4.1]=14 [4.0]=14 )
actionExtensionCount=( [4.2]=29 [4.1]=27 [4.0]=27 )
viewerExtensionCount=( [4.2]=9 )
viewerExtensionCount=( [4.2]=10 )
fileExtensionCount=( [4.2]=37 [4.1]=37 [4.0]=37 )
actionCount=( [4.2]=108 [4.1]=105 [4.0]=105 )
viewerCount=( [4.2]=12 )
viewerCount=( [4.2]=13 )
# fill release date
releaseDate=( [4.2]="not yet released, current development version" \
......
......@@ -391,11 +391,6 @@ QString InteractiveViewer::getName() const {
return objectName();
}
// ---------------- numberOfViewedComponent ----------------
unsigned int InteractiveViewer::numberOfViewedComponent() {
return actorMap.size();
}
// ---------------------- refresh ----------------------------
void InteractiveViewer::refresh(Viewer* v) {
......
......@@ -186,9 +186,6 @@ public:
/** @name Inherited from Viewer
*/
///@{
/// returns the number of Component that are displayed by this viewer
unsigned int numberOfViewedComponent() override;
/// Refresh the display.
void refresh(Viewer* whoIsAsking = nullptr) override;
......
......@@ -144,7 +144,7 @@ void Viewer::stackIn(QStackedWidget* stackedWidget) {
}
// check all conditions are met
if (getWidget() != nullptr && this->stackedWidget == nullptr) {
if (getWidget() != nullptr) {
// add the viewer's widget inside the stack
stackedWidget->addWidget(getWidget());
// keep the pointer
......@@ -165,9 +165,8 @@ void Viewer::embedIn(QLayout* embeddedLayout) {
}
// check all conditions are met
if (getWidget() != nullptr && this->embeddedLayout == nullptr) {
if (getWidget() != nullptr) {
embeddedLayout->addWidget(getWidget());
//getWidget()->setParent(embeddedLayout->parentWidget());
// keep the pointer
this->embeddedLayout = embeddedLayout;
}
......
......@@ -102,15 +102,12 @@ public:
QDockWidget* dockIn();
/// show the viewer's widget in the stack
/// If it is the first call, add the viewer widget in the given stack (once done, it cannot change stack)
/// If it is the first call, add the viewer widget in the given stack
void stackIn(QStackedWidget*);
/// Add the viewer widget in the given layout (once done, the layout cannot be changed)
/// Add the viewer widget in the given layout
void embedIn(QLayout*);
/// returns the number of Component that are displayed by this viewer
virtual unsigned int numberOfViewedComponent() = 0;
/// refresh the view (can be interesting to know which other viewer is calling this)
virtual void refresh(Viewer* whoIsAsking = nullptr) = 0;
......
......@@ -70,16 +70,11 @@ public:
/// @name Inherited from Viewer
//@{
/// returns the number of Component that are displayed by this viewer
unsigned int numberOfViewedComponent() {
return 0;
};
/// refresh the view (can be interesting to know which other viewer is calling this)
virtual void refresh(Viewer* whoIsAsking = nullptr);
virtual void refresh(Viewer* whoIsAsking = nullptr) override;
/// get the viewer widget
virtual QWidget* getWidget();
virtual QWidget* getWidget() override;
//@}
/// show/hide the search panel (hidden by default)
......
......@@ -115,11 +115,6 @@ QWidget* Explorer::getPreferenceWidget(QWidget* parent) {
return nullptr;
}
// ---------------- numberOfViewedComponent ----------------
unsigned int Explorer::numberOfViewedComponent() {
return itemComponentMap.size();
}
//----------------------- refresh ------------------------
void Explorer::refresh(Viewer* whoIsAsking) {
// if it is this instance who is asking the refresh, then only the Component names need to be checked...
......
......@@ -37,10 +37,10 @@
#include <QTreeWidgetItem>
namespace camitk {
// -- Core stuff classes
class InterfaceNode;
class Component;
class ExplorerItem;
// -- Core stuff classes
class InterfaceNode;
class Component;
class ExplorerItem;
}
/**
......@@ -73,9 +73,6 @@ public:
/** @name Inherited from Viewer
*/
///@{
/// returns the number of Component that are displayed by this viewer
unsigned int numberOfViewedComponent() override;
/// refresh the explorer (can be interesting to know which other viewer is calling this)
void refresh(camitk::Viewer* whoIsAsking = nullptr) override;
......
......@@ -71,11 +71,6 @@ QWidget* FrameExplorer::getPreferenceWidget(QWidget* parent) {
return nullptr;
}
// ---------------- numberOfViewedComponent ----------------
unsigned int FrameExplorer::numberOfViewedComponent() {
return 0;
}
//----------------------- refresh ------------------------
void FrameExplorer::refresh(Viewer* whoIsAsking) {
// if it is this instance who is asking the refresh, then only the Component names need to be checked...
......
......@@ -65,9 +65,6 @@ public:
/** @name Inherited from Viewer
*/
///@{
/// returns the number of Component that are displayed by this viewer
unsigned int numberOfViewedComponent() override;
/// refresh the frame explorer (can be interesting to know which other viewer is calling this)
void refresh(Viewer* whoIsAsking = nullptr) override;
......
......@@ -57,18 +57,9 @@ MedicalImageViewer::MedicalImageViewer(QString name) : Viewer(name) {
// -------------------- Destructor --------------------
MedicalImageViewer::~MedicalImageViewer() {
}
// -------------------- numberOfViewedComponentgetWidget --------------------
unsigned int MedicalImageViewer::numberOfViewedComponent() {
unsigned int count = 0;
for (unsigned int i = 0; viewerVisibility[i] != VIEWER_ALL; i++) {
count += viewers.value(viewerVisibility[i])->numberOfViewedComponent();
}
return count;
viewerMenu->clear();
delete viewerMenu;
delete frame;
}
// -------------------- refresh --------------------
......@@ -80,11 +71,12 @@ void MedicalImageViewer::refresh(Viewer* whoIsAsking) {
// view everything?
if (displayedTopLevelComponents != (unsigned) Application::getTopLevelComponents().size()) {
// if there the nr of Component changed since last refresh,
// and if there is something displayed in the slices viewer, show all view
if (Application::getViewer("axialViewer")->numberOfViewedComponent() > 0
&& Application::getViewer("coronalViewer")->numberOfViewedComponent() > 0
&& Application::getViewer("sagittalViewer")->numberOfViewedComponent() > 0) {
// Check if there is ImageComponent, if yes show all viewers
int i = 0;
while (i<Application::getTopLevelComponents().size() && !Application::getTopLevelComponents().at(i)->isInstanceOf("ImageComponent")) {
i++;
}
if (i<Application::getTopLevelComponents().size()) {
visibleLayout = VIEWER_ALL;
}
else {
......@@ -126,21 +118,15 @@ QWidget* MedicalImageViewer::getWidget() {
frameLayout->setMargin(0);
/// the layout for the arbitrary/axial at the top left position of frameLayout
QVBoxLayout* innerLayout = new QVBoxLayout();
frameLayout->addLayout(innerLayout, 0, 0); // north-west
Application::getViewer("axialViewer")->embedIn(innerLayout);
innerLayout = new QVBoxLayout();
frameLayout->addLayout(innerLayout, 1, 0); // south-west
Application::getViewer("coronalViewer")->embedIn(innerLayout);
innerLayout = new QVBoxLayout();
frameLayout->addLayout(innerLayout, 1, 1); // south-east
Application::getViewer("sagittalViewer")->embedIn(innerLayout);
innerLayout = new QVBoxLayout();
frameLayout->addLayout(innerLayout, 0, 1); // north-east
Application::getViewer("3DViewer")->embedIn(innerLayout);
Application::getViewer("arbitraryViewer")->embedIn(innerLayout);
northWestLayout = new QVBoxLayout();
frameLayout->addLayout(northWestLayout, 0, 0); // north-west
southWestLayout = new QVBoxLayout();
frameLayout->addLayout(southWestLayout, 1, 0); // south-west
southEastLayout = new QVBoxLayout();
frameLayout->addLayout(southEastLayout, 1, 1); // south-east
northEastLayout = new QVBoxLayout();
frameLayout->addLayout(northEastLayout, 0, 1); // north-east
//-- connect
foreach (LayoutVisibility v, viewerVisibility) {
if (viewers.value(v)) { // prevent ALL
......@@ -152,6 +138,13 @@ QWidget* MedicalImageViewer::getWidget() {
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);
return frame;
}
......
......@@ -76,9 +76,6 @@ public:
/** @name Viewer inherited
*/
/// @{
/// returns the number of Component that are displayed by this viewer
unsigned int numberOfViewedComponent() override;
/// refresh the view (can be interesting to know which other viewer is calling this)
void refresh(Viewer* whoIsAsking = nullptr) override;
......@@ -121,6 +118,12 @@ private:
/// The main layout
QGridLayout* frameLayout;
/// The four corners of the main layout
QVBoxLayout* northWestLayout;
QVBoxLayout* southWestLayout;
QVBoxLayout* northEastLayout;
QVBoxLayout* southEastLayout;
/// the main widget
QFrame* frame;
......
......@@ -59,16 +59,6 @@ PropertyExplorer::~PropertyExplorer() {
}
}
// ---------------- numberOfViewedComponent ----------------
unsigned int PropertyExplorer::numberOfViewedComponent() {
if (currentComponent) {
return 1;
}
else {
return 0;
}
}
// ---------------- refresh ----------------
void PropertyExplorer::refresh(Viewer* whoIsAsking) {
// refresh the explorer if there is one selected Component
......
......@@ -97,9 +97,6 @@ public:
/** @name Inherited from Viewer
*/
///@{
/// returns the number of Component that are displayed by this viewer
unsigned int numberOfViewedComponent() override;
/// refresh the property editor
void refresh(camitk::Viewer* whoIsAsking = nullptr) override;
......
......@@ -49,5 +49,6 @@ MixedComponent::MixedComponent(const QString& file) : Component(file, QFileInfo(
// Create vtk component and connect it as a sub-component
VtkMeshComponent* meshCpt = new VtkMeshComponent(vtkFile);
addChild(meshCpt);
// show only wireframe
meshCpt->setRenderingModes(InterfaceGeometry::Wireframe);
}
# Call CamiTK CMake Macro to define the action
camitk_extension(VIEWER_EXTENSION
DEFAULT
DEFINES COMPILE_MIXED_VIEWER_API
NEEDS_COMPONENT_EXTENSION mixed
DESCRIPTION "An extension to demonstrate a dual viewer (only for ImageComponent and MixedComponent)"
INSTALL_ALL_HEADERS
)
/*****************************************************************************
* $CAMITK_LICENCE_BEGIN$
*
* CamiTK - Computer Assisted Medical Intervention ToolKit
* (c) 2001-2018 Univ. Grenoble Alpes, CNRS, TIMC-IMAG UMR 5525 (GMCAO)
*
* Visit http://camitk.imag.fr for more information
*
* This file is part of CamiTK.
*
* CamiTK is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* CamiTK is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with CamiTK. If not, see <http://www.gnu.org/licenses/>.
*
* $CAMITK_LICENCE_END$
****************************************************************************/
#include "MixedViewer.h"
// -- Core stuff
#include <Application.h>
#include <MixedComponent.h>
//-- Qt stuff
#include <QGridLayout>
using namespace camitk;
// -------------------- Constructor --------------------
MixedViewer::MixedViewer(QString name) : Viewer(name) {
myWidget = nullptr;
setComponents(QStringList() << "ImageComponent" << "MixedComponent");
}
// -------------------- Destructor --------------------
MixedViewer::~MixedViewer() {
delete myWidget;
}
// -------------------- refresh --------------------
void MixedViewer::refresh(Viewer*) {
// nothing to do as everything is already done by the MedicalImageViewer!
}
// -------------------- getWidget --------------------
QWidget* MixedViewer::getWidget() {
if (!myWidget) {
myWidget = new QWidget();
//-- init layout
auto* myWidgetLayout = new QGridLayout();
myWidgetLayout->setSpacing(0);
myWidgetLayout->setMargin(0);
leftLayout = new QVBoxLayout();
myWidgetLayout->addLayout(leftLayout, 0, 0);
rightLayout = new QVBoxLayout();
myWidgetLayout->addLayout(rightLayout, 0, 1);
myWidget->setLayout(myWidgetLayout);
}
// always re-embed the viewers (in case another viewer embeded them somewhere else in the meanwhile)
Application::getViewer("axialViewer")->embedIn(leftLayout);
Application::getViewer("3DViewer")->embedIn(rightLayout);
return myWidget;
}
/*****************************************************************************
* $CAMITK_LICENCE_BEGIN$
*
* CamiTK - Computer Assisted Medical Intervention ToolKit
* (c) 2001-2018 Univ. Grenoble Alpes, CNRS, TIMC-IMAG UMR 5525 (GMCAO)
*
* Visit http://camitk.imag.fr for more information
*
* This file is part of CamiTK.
*
* CamiTK is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* CamiTK is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with CamiTK. If not, see <http://www.gnu.org/licenses/>.
*
* $CAMITK_LICENCE_END$
****************************************************************************/
#ifndef MIXED_VIEWER_H
#define MIXED_VIEWER_H
#include "MixedViewerAPI.h"
// -- Core stuff
#include <ViewerExtension.h>
#include <Viewer.h>
// -- QT stuff
#include <QVBoxLayout>
/**
* A dual panel viewer...
* It just send reused the axial and 3D viewer to display two views of the same thing.
*
* All the heavy work is already done by the MedicalImageViewer:
* - view synchronization
* - update and refresh of the viewer
* - management of viewed components
*
* This viewer is therefore very simple. In the end it is just building a specific widget
* that presents the axial and 3D viewer side by side using a grid layout.
*/
class MIXED_VIEWER_API MixedViewer : public camitk::Viewer {
Q_OBJECT
public:
/** @name Constructors/Destructors
*/
/// @{
/** construtor. */
Q_INVOKABLE MixedViewer(QString name);
/** destructor */
virtual ~MixedViewer();
/// @}
/** @name Viewer inherited
*/
/// @{
/// refresh the view (can be interesting to know which other viewer is calling this)
virtual void refresh(Viewer* whoIsAsking = nullptr) override;
/// get the viewer widget.
virtual QWidget* getWidget() override;
/// @}
private:
/// The viewer's widget
QWidget* myWidget;
/// The two panels inside the main layout
QVBoxLayout* leftLayout;
QVBoxLayout* rightLayout;
};
#endif // MIXED_VIEWER_H
/*****************************************************************************
* $CAMITK_LICENCE_BEGIN$
*
* CamiTK - Computer Assisted Medical Intervention ToolKit
* (c) 2001-2014 UJF-Grenoble 1, CNRS, TIMC-IMAG UMR 5525 (GMCAO)
*
* Visit http://camitk.imag.fr for more information
*
*
* CamiTK is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* CamiTK is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with CamiTK. If not, see <http://www.gnu.org/licenses/>.
*
* $CAMITK_LICENCE_END$
****************************************************************************/
#ifndef MIXED_VIEWER_API_H
#define MIXED_VIEWER_API_H
// -----------------------------------------------------------------------
//
// MIXED_VIEWER_API
//
// -----------------------------------------------------------------------
// The following ifdef block is the standard way of creating macros which make exporting
// from a DLL simpler. All files within this DLL are compiled with the COMPILE_MIXED_VIEWER_API
// flag defined on the command line. this symbol should not be defined on any project
// that uses this DLL. This way any other project whose source files include this file see
// MIXED_VIEWER_API functions as being imported from a DLL, whereas this DLL sees symbols
// defined with this macro as being exported.
#if defined(_WIN32) // MSVC and mingw
#ifdef COMPILE_MIXED_VIEWER_API
#define MIXED_VIEWER_API __declspec(dllexport)
#else
#define MIXED_VIEWER_API __declspec(dllimport)
#endif
#else
// for all other platforms MIXED_VIEWER_API is defined to be "nothing"
#ifndef MIXED_VIEWER_API
#define MIXED_VIEWER_API
#endif
#endif // MSVC and mingw
// -----------------------------------------------------------------------
// It seems that MSVC does not understand exception specification
// If I understand it well, when _declspec() is used, there is a default
// nothrow attribute.
// I did not find the throw attribute. It seems that msvc is therefore ignoring the
// specification of the type of the exception.
// The compiler therefore issues a warning.
// The following line is to avoid this particular warning.
// The best would be to ask msvc not only to take the exception into account, but also
// its type. Anyway, I did not find how to do that anywhere, and I am not sure this is
// possible...
#if defined(_WIN32) && !defined(__MINGW32__) // MSVC only
#pragma warning( disable : 4290 )
#endif // MSVC only
#endif // MIXED_VIEWER_API_H
/*****************************************************************************
* $CAMITK_LICENCE_BEGIN$
*
* CamiTK - Computer Assisted Medical Intervention ToolKit
* (c) 2001-2018 Univ. Grenoble Alpes, CNRS, TIMC-IMAG UMR 5525 (GMCAO)
*
* Visit http://camitk.imag.fr for more information
*
* This file is part of CamiTK.
*
* CamiTK is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* CamiTK is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with CamiTK. If not, see <http://www.gnu.org/licenses/>.
*
* $CAMITK_LICENCE_END$
****************************************************************************/
#include "MixedViewerExtension.h"
// include generated actions headers
#include "MixedViewer.h"
// --------------- getActions -------------------
void MixedViewerExtension::init() {
registerDefaultViewer(MixedViewer);
}
/*****************************************************************************
* $CAMITK_LICENCE_BEGIN$
*
* CamiTK - Computer Assisted Medical Intervention ToolKit
* (c) 2001-2018 Univ. Grenoble Alpes, CNRS, TIMC-IMAG UMR 5525 (GMCAO)
*
* Visit http://camitk.imag.fr for more information
*
* This file is part of CamiTK.
*
* CamiTK is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* CamiTK is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with CamiTK. If not, see <http://www.gnu.org/licenses/>.
*
* $CAMITK_LICENCE_END$
****************************************************************************/
#ifndef MIXED_VIEWER_EXTENSION_H
#define MIXED_VIEWER_EXTENSION_H
#include <ViewerExtension.h>
class MixedViewerExtension : public camitk::ViewerExtension {
Q_OBJECT
Q_INTERFACES(camitk::ViewerExtension);
Q_PLUGIN_METADATA(IID "fr.imag.camitk.tutorials.viewer.mixedviewerextension")
public:
/// Constructor
MixedViewerExtension() : ViewerExtension() {};
/// Destructor
virtual ~MixedViewerExtension() = default;
/// Method returning the action extension name
virtual QString getName() {
return "MixedViewer Extension";
};
/// Method returning the action extension descrption
virtual QString getDescription() {
return "An extension that brings a pure text viewer called... MixedViewer";
};
/// initialize all the actions
virtual void init();
};
#endif // MIXED_VIEWER_EXTENSION_H
......@@ -42,18 +42,12 @@ TextViewer::TextViewer(QString name) : Viewer(name) {
inverse = nullptr;
myMenu = nullptr;
myWidget = nullptr;
isVisible = false;
displayedTopLevelComponents = 0;
}
// -------------------- Destructor --------------------
TextViewer::~TextViewer() {
}
// -------------------- numberOfViewedComponentgetWidget --------------------
unsigned int TextViewer::numberOfViewedComponent() {
return displayedTopLevelComponents;
delete myWidget;
}
// -------------------- refresh --------------------
......
......@@ -68,9 +68,6 @@ public:
/** @name Viewer inherited
*/
/// @{
/// returns the number of Component that are displayed by this viewer
virtual unsigned int numberOfViewedComponent();
/// refresh the view (can be interesting to know which other viewer is calling this)
virtual void refresh(Viewer* whoIsAsking = nullptr);
......@@ -120,17 +117,10 @@ private:
/// colors
QColor textColor;
QColor bgColor;
/// color management
void updateColors();
/// current visibility state
bool isVisible;
/// the viewer instance singleton
static TextViewer* singleton;
/// the unique instance name
static QString viewerName;
};
#endif // TEXT_VIEWER_H
......