...
 
Commits (2)
......@@ -22,12 +22,13 @@ set -e
# values to check
initTestData() {
# fill test data
extensionCount=( [4.2]=53 [4.1]=41 [4.0]=31 )
extensionCount=( [4.2]=52 [4.1]=41 [4.0]=31 )
componentExtensionCount=( [4.2]=14 [4.1]=14 [4.0]=14 )
actionExtensionCount=( [4.2]=30 [4.1]=27 [4.0]=27 )
actionExtensionCount=( [4.2]=29 [4.1]=27 [4.0]=27 )
viewerExtensionCount=( [4.2]=9 )
fileExtensionCount=( [4.2]=37 [4.1]=37 [4.0]=37 )
actionCount=( [4.2]=109 [4.1]=105 [4.0]=105 )
actionCount=( [4.2]=108 [4.1]=105 [4.0]=105 )
viewerCount=( [4.2]=12 )
# fill release date
releaseDate=( [4.2]="not yet released, current development version" \
......@@ -52,6 +53,7 @@ declareTestData() {
declare -Ag viewerExtensionCount
declare -Ag fileExtensionCount
declare -Ag actionCount
declare -Ag viewerCount
declare -Ag releaseDate
}
......@@ -186,6 +188,9 @@ getExpectedValue() {
"Number of Actions")
echo ${actionCount[$shortVersion]}
;;
"Number of Viewers")
echo ${viewerCount[$shortVersion]}
;;
esac
}
......@@ -292,5 +297,6 @@ checkValue "Number of Action Extensions"
checkValue "Number of Viewer Extensions"
checkValue "Number of File Extensions Supported"
checkValue "Number of Actions"
checkValue "Number of Viewers"
exit $exitStatus
......@@ -109,6 +109,12 @@ Component::~Component() {
propertyMap.clear();
if (actionsMenu != nullptr) {
actionsMenu->clear();
delete actionsMenu;
actionsMenu = nullptr;
}
CAMITK_TRACE(tr("Deleted"))
}
......@@ -125,6 +131,7 @@ void Component::init() {
mySlice = nullptr;
myFrame = nullptr;
actionsMenu = nullptr;
visibilityMenu = nullptr;
// create the Frame (does not depend on any representation, should be created for any Component)
myFrame = new Frame();
......@@ -397,6 +404,9 @@ QMenu* Component::getActionMenu() {
}
}
//-- create the visibility menu when first call
visibilityMenu = actionsMenu->addMenu("Visibility");
// no menu if no action
if (actionsMenu->actions().size() == 0) {
delete actionsMenu;
......@@ -404,6 +414,30 @@ QMenu* Component::getActionMenu() {
}
}
//-- update viewer visibility
visibilityMenu->clear();
ViewerList allViewers = Application::getViewers(this);
for (Viewer* viewer : allViewers) {
// show only embedded or stacked viewers
if (viewer->getLayout() != Viewer::DOCKED) {
// viewerAction is own by visibilityMenu, visibilityMenu.clear() will delete it
QAction* visibilityAction = visibilityMenu->addAction(viewer->getName());
visibilityAction->setCheckable(true);
visibilityAction->setChecked(getVisibility(viewer));
visibilityAction->setIcon(viewer->getIcon());
QString tipString = "Set the visibility of this component in the \"" + viewer->getName() + "\" viewer\n(note that it might not have effect depending on the viewer)";
visibilityAction->setStatusTip(tr(tipString.toStdString().c_str()));
visibilityAction->setWhatsThis(tr(tipString.toStdString().c_str()));
// add the toggle action slot using C++11 lambda so that everything is contained inside viewMenu
connect(visibilityAction, &QAction::toggled, [ = ](bool visible) {
setVisibility(viewer, visible);
Application::refresh();
});
}
}
return actionsMenu;
}
......
This diff is collapsed.
......@@ -143,12 +143,12 @@ public:
~Geometry() override;
/// get the label of this Geometry instance
const QString getLabel() const {
const QString getLabel() const override {
return label;
}
/// set the label of this Geometry instance
void setLabel(QString newName) {
void setLabel(QString newName) override {
label = newName;
updateLabel();
}
......@@ -159,7 +159,7 @@ public:
*/
///@{
/// Return the dataset associated to this object.
vtkSmartPointer<vtkPointSet> getPointSet() {
vtkSmartPointer<vtkPointSet> getPointSet() override {
return pointSet;
}
......@@ -170,7 +170,7 @@ public:
void setMeshWorldTransform(vtkSmartPointer<vtkTransform>) override;
/// get the custom algorithm pipeline input.
vtkSmartPointer<vtkAlgorithmOutput> getDataPort() const {
vtkSmartPointer<vtkAlgorithmOutput> getDataPort() const override {
return dataOutput;
}
......@@ -190,10 +190,10 @@ public:
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) {};
void pointPicked(vtkIdType, bool) override {};
/// a vtkCell of the structured was picked (to be reimplemented in a Component inherited class if needed)
void cellPicked(vtkIdType, bool) {};
void cellPicked(vtkIdType, bool) override {};
///@}
......@@ -246,12 +246,12 @@ public:
/// @{
/// Set the actor associated to a rendering mode visible or not.
void setRenderingModes(const RenderingModes rMode) {
void setRenderingModes(const RenderingModes rMode) override {
renderingModes = rMode;
}
/// Return if the actor associated to a rendering mode is currently visible or not.
const RenderingModes getRenderingModes() const {
const RenderingModes getRenderingModes() const override {
return renderingModes;
}
......@@ -259,7 +259,7 @@ public:
void setEnhancedModes(const EnhancedModes) override;
/// get the current enhanced mode
const EnhancedModes getEnhancedModes() const {
const EnhancedModes getEnhancedModes() const override {
return enhancedModes;
}
......
......@@ -53,7 +53,7 @@ public:
static SimplisticComponent* createInstance(QString name);
/// this component has no representation
void initRepresentation() {}
void initRepresentation() override {}
/// This simplistic component cannot have properties
/// If you need properties, it means that you need a
......
......@@ -35,6 +35,7 @@
#include "MeshComponent.h"
#include "Property.h"
#include "Frame.h"
#include "Viewer.h"
// -- vtk stuff
#include <vtkUniformGrid.h>
......@@ -85,6 +86,7 @@ ImageComponent::~ImageComponent() {
if (model != nullptr) {
delete model;
}
if (selectionView != nullptr) {
delete selectionView;
}
......@@ -156,6 +158,7 @@ void ImageComponent::initImageProperties() {
// from QObject documentation, section "Detailed Description":
// "To avoid never ending notification loops you can temporarily block signals with blockSignals()."
setProperty("Image Name", QVariant(getName()));
if (originalImageData != nullptr) {
int* imgDims = originalImageData->GetDimensions();
......@@ -200,19 +203,21 @@ void ImageComponent::updateProperty(QString name, QVariant value) {
if (name == "Display Image in 3D Viewer") {
update3DViewer();
}
else if (name == "Image Name") {
setName(value.toString());
refreshInterfaceNode();
}
// bypass read-only properties
// (other specific properties are read only and should not be sent up to Component::updateProperty)
else if (name != "Image Dimensions"
&& name != "Image Size"
&& name != "Voxel Size"
&& name != "Voxel Data Type"
&& name != "Initial Image Orientation") {
Component::updateProperty(name, value);
}
else
if (name == "Image Name") {
setName(value.toString());
refreshInterfaceNode();
}
// bypass read-only properties
// (other specific properties are read only and should not be sent up to Component::updateProperty)
else
if (name != "Image Dimensions"
&& name != "Image Size"
&& name != "Voxel Size"
&& name != "Voxel Data Type"
&& name != "Initial Image Orientation") {
Component::updateProperty(name, value);
}
}
// -------------------- setImageData --------------------
......@@ -275,10 +280,12 @@ void ImageComponent::setImageData(vtkSmartPointer<vtkImageData> anImageData,
initialFrameTransform = vtkSmartPointer<vtkTransform>::New();
vtkSmartPointer<vtkMatrix4x4> initialFrameMatrix = vtkSmartPointer<vtkMatrix4x4>::New();
rotationMatrix = initialRotationMatrix;
if (!rotationMatrix) {
rotationMatrix = vtkSmartPointer<vtkMatrix4x4>::New();
rotationMatrix->Identity();
}
vtkMatrix4x4::Multiply4x4(rotationMatrix, initialTranslation->GetMatrix(), initialFrameMatrix);
vtkMatrix4x4::Multiply4x4(initialFrameMatrix, orientationToRAIMatrix, initialFrameMatrix);
initialFrameTransform->SetMatrix(initialFrameMatrix);
......@@ -501,9 +508,24 @@ QString ImageComponent::getImageName() const {
return getName();
}
// -------------------- setVisibility --------------------
void ImageComponent::setVisibility(Viewer* v, bool b) {
if (v != nullptr) {
if (v->getName() == "3DViewer") {
// if setVisibility was called and the current state is different, update it
if (property("Display Image in 3D Viewer").toBool() != b) {
setProperty("Display Image in 3D Viewer", b);
}
}
}
Component::setVisibility(v, b);
}
// -------------------- update3DViewer --------------------
void ImageComponent::update3DViewer() {
bool viewIn3D = property("Display Image in 3D Viewer").toBool();
setVisibility(Application::getViewer("3DViewer"), viewIn3D);
if (axialSlices != nullptr) {
axialSlices->setViewSliceIn3D(viewIn3D);
......@@ -788,6 +810,7 @@ QWidget* ImageComponent::getPropertyWidgetAt(unsigned int i) {
case 0:
return selectionView;
break;
default:
return nullptr;
}
......
......@@ -100,12 +100,15 @@ public:
/// set selected will select all the Image components (axial, sagittal and coronal).
void setSelected(const bool b, const bool recursive = false) override;
/// set the visibility for a viewer (override required to manage the specific case of the 3D viewer)
virtual void setVisibility(Viewer*, bool) override;
/// getter/setter for the property
QString getImageName() const;
void setImageName(const QString&);
/// get the image volume managed by this Component
vtkSmartPointer<vtkImageData> getImageData() const {
vtkSmartPointer<vtkImageData> getImageData() const override {
return originalImageData;
}
......@@ -253,7 +256,7 @@ private:
virtual void initImageProperties();
/// the concrete building of the 3D objects (Slice/Geometry): none in this case!
void initRepresentation() {}
void initRepresentation() override {}
// builds default lookup table
void initLookupTable();
......
......@@ -144,36 +144,6 @@ Viewer* ViewerExtension::getNewInstance(QString name) {
else {
CAMITK_ERROR(tr("Cannot instanciate %1 from static meta object").arg(getViewerClassName()));
}
/*CLEANUP
int typeId = QMetaType::type(viewerClassName.toStdString().c_str());
if (typeId != QMetaType::UnknownType) {
// get the pointer to the viewer's class meta object
const QMetaObject* metaObject = QMetaType::metaObjectForType(typeId);
if (metaObject == nullptr) {
// If not working try the meta type create method
void* instance = QMetaType::create(typeId);
// this pointer is bad and uninitialized
viewer = static_cast<Viewer*>(instance);
if (viewer == nullptr) {
CAMITK_ERROR(tr("Cannot get %1 metaObject nor use the QMetaType create method").arg(viewerClassName));
}
}
else {
// instanciate a new viewer of the managed class
QObject* o = metaObject->newInstance(Q_ARG(QString, name));
viewer = qobject_cast<Viewer*>(o);
// register it in the list
registerViewer(viewer);
}
}
else {
CAMITK_ERROR(tr("Cannot create new instance of %1: type not registered by Qt").arg(viewerClassName));
}
*/
return viewerInstance;
}
......
......@@ -46,7 +46,8 @@ BitmapViewer::BitmapViewer(QString name) : InteractiveViewer(name, InteractiveVi
// parallel projection
getRendererWidget()->getActiveCamera()->ParallelProjectionOn();
setComponents(QStringList() << "ImageComponent");
// can only display 2D bitmap = SingleImageComponent
setComponents(QStringList() << "SingleImageComponent");
myToolbar = nullptr;
}
......@@ -85,10 +86,11 @@ QToolBar* BitmapViewer::getToolBar() {
hideViewerAction->setIcon(QPixmap(":/fileClose"));
hideViewerAction->setStatusTip(tr("Switch back to the medical image viewer"));
hideViewerAction->setWhatsThis(tr("Switch back the ventral viewer to normal (i.e., show the Medical Image Viewer)"));
connect(hideViewerAction, &QAction::triggered, [=](bool) {
connect(hideViewerAction, &QAction::triggered, [ = ](bool) {
Application::getMainWindow()->setCentralViewer(Application::getViewer("MedicalImageViewer"));
});
}
return myToolbar;
}
......
......@@ -23,7 +23,6 @@
* $CAMITK_LICENCE_END$
****************************************************************************/
// -- Core stuff
#include "InteractiveGeometryViewer.h"
using namespace camitk;
......@@ -31,12 +30,7 @@ using namespace camitk;
// -------------------- Constructor --------------------
InteractiveGeometryViewer::InteractiveGeometryViewer(QString name) : InteractiveViewer(name, InteractiveViewer::GEOMETRY_VIEWER) {
if (name == "3DViewer") {
// Axial Viewer
// the default 3D Viewer is embedded
setLayout(Viewer::EMBEDDED);
}
}
/* CLEANUP
// -------------------- Destructor --------------------
InteractiveGeometryViewer::~InteractiveGeometryViewer() {
}*/
......@@ -23,15 +23,16 @@
* $CAMITK_LICENCE_END$
****************************************************************************/
// -- Core stuff
#include "InteractiveSliceViewer.h"
#include <InteractiveViewer.h>
#include <vtkCamera.h>
using namespace camitk;
// -------------------- Constructor --------------------
InteractiveSliceViewer::InteractiveSliceViewer(QString name) : InteractiveViewer(name, InteractiveViewer::SLICE_VIEWER) {
setComponents(QStringList() << "SingleImageComponent" );
if (name == "axialViewer") {
// Axial Viewer
setLayout(Viewer::EMBEDDED);
......
......@@ -52,9 +52,6 @@ MedicalImageViewer::MedicalImageViewer(QString name) : Viewer(name) {
autoUpdateToolbarVisibility = true;
/*
setComponents(QStringList() << "ImageComponent" << "MeshComponent");
*/
}
......