Commit 9762c1f0 authored by Emmanuel Promayon's avatar Emmanuel Promayon

NEW docked viewer icons + TextViewer is now a docked viewer

+ FIXED issues from different analyzer
parent 02c5dfe2
......@@ -191,7 +191,8 @@ 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->setHighlightMode(InteractiveViewer::OFF);
internalViewer->setProperty("Highlight Mode",InteractiveViewer::OFF);
internalViewer->setHighlightMode();
internalViewer->toggleCopyright(false);
internalViewer->getRendererWidget()->setCameraOrientation(RendererWidget::RIGHT_DOWN);
......
......@@ -500,9 +500,30 @@ void ImpMainWindow::updateViewMenu() {
toggleDockedMenu->addAction(viewResetWindows);
for (QMap<Viewer*, QDockWidget*>::iterator it = dockWidgetMap.begin(); it != dockWidgetMap.end(); it++) {
it.value()->toggleViewAction()->setIcon(it.key()->getIcon());
toggleDockedMenu->addAction(it.value()->toggleViewAction());
foreach (Viewer* viewer, Application::getViewers()) {
// add the
if (viewer->getType() == Viewer::DOCKED) {
QDockWidget* dockWidget = dockWidgetMap.value(viewer);
if (dockWidget != nullptr) {
dockWidget->toggleViewAction()->setIcon(viewer->getIcon());
toggleDockedMenu->addAction(dockWidget->toggleViewAction());
}
else {
// add a specific action to add this viewer in the right dock area
// viewerAction is own by viewMenu, viewMenu->clear() will delete it
QAction* viewerDockAction = toggleDockedMenu->addAction(viewer->getName());
viewerDockAction->setCheckable(true);
viewerDockAction->setChecked(false);
viewerDockAction->setIcon(viewer->getIcon());
QString tipString = "Hide/show the " + viewer->getName() + " inside a dock";
viewerDockAction->setStatusTip(tr(tipString.toStdString().c_str()));
viewerDockAction->setWhatsThis(tr(tipString.toStdString().c_str()));
// add the toggle action slot using C++11 lambda so that everything is contained inside viewMenu
connect(viewerDockAction, &QAction::toggled, [ = ](bool) {
addDockViewer(Qt::RightDockWidgetArea, viewer);
});
}
}
}
// insert generic on/off actions
......
......@@ -218,13 +218,14 @@ bool ExtensionManager::loadExtension(ExtensionManager::ExtensionType type, QStri
// initialize all viewers
ext->init();
// check that ext is managing a new class
int i = 0;
while (i < getViewerExtensionMap().size() && getViewerExtensionsList().at(i)->getViewerClassName() != ext->getViewerClassName()) {
i++;
}
if (returnValue = (i >= getViewerExtensionMap().size())) {
returnValue = (i >= getViewerExtensionMap().size());
if (returnValue) {
//-- register the filename
getViewerExtensionMap().insert(fileName, ext);
//-- register all viewers
......
......@@ -217,7 +217,13 @@ bool MainWindow::addViewer(Viewer* theViewer) {
// ------------- removeViewer -----------------
bool MainWindow::removeViewer(Viewer* viewer) {
return true;
if (viewers.contains(viewer)) {
viewers.removeAll(viewer);
return true;
}
else {
return false;
}
}
// ------------- showDockViewer -----------------
......
......@@ -47,7 +47,9 @@
<file alias="play">oxygen_icons/actions/media-playback-start.png</file>
<file alias="pause">oxygen_icons/actions/media-playback-pause.png</file>
<file alias="stop">oxygen_icons/actions/media-playback-stop.png</file>
<file alias="backwrad">oxygen_icons/actions/media-skip-backward.png</file>
<file alias="backward">oxygen_icons/actions/media-skip-backward.png</file>
<file alias="forward">oxygen_icons/actions/media-skip-forward.png</file>
<file alias="properties">oxygen_icons/actions/view-list-details.png</file>
<file alias="explorer">oxygen_icons/places/folder-brown.png</file>
</qresource>
</RCC>
......@@ -614,7 +614,7 @@ QMenu* InteractiveViewer::getMenu() {
if (myType == GEOMETRY_VIEWER) {
options->addSeparator();
//options->addAction(toggleAxesAction);
options->addAction(toggleAxesAction);
options->addAction(toggleLabelAction);
options->addAction(toggleLinesAsTubesAction);
options->addAction(toggleBackfaceCullingAction);
......@@ -1897,7 +1897,7 @@ void InteractiveViewer::renderingActorsChanged() {
}
// --------------- setHighlightMode --------------------
void InteractiveViewer::setHighlightMode(InteractiveViewer::HighlightMode h) {
void InteractiveViewer::setHighlightMode() {
HighlightMode highlightMode = (HighlightMode) propertyObject->property(highlightModeProperty->getName().toStdString().c_str()).toInt();
refresh(this);
QSettings& settings = Application::getSettings();
......
......@@ -261,8 +261,8 @@ public:
/// Handle keyboard events in the scene, let to the parent widget if not processed here. This method is a friend of class InteractiveViewerFrame
void keyPressEvent(QKeyEvent* e);
/// Set the current highlighting mode.
virtual void setHighlightMode(InteractiveViewer::HighlightMode);
/// Set the current highlighting mode from the current value of the property
virtual void setHighlightMode();
/// return interactiveViewer RendererWidget
inline RendererWidget* getRendererWidget() {
......
......@@ -948,7 +948,7 @@ void RendererWidget::pick() {
}
// --------------------- pickActor -----------------------------------
void RendererWidget::pickActor(int x, int y) {
void RendererWidget::pickActor(int, int) {
//-- if there is no picker or a picker that we can't use with (x,y), then picking was not initialized, so do nothing!
vtkSmartPointer<vtkPicker> picker = vtkPicker::SafeDownCast(GetInteractor()->GetPicker());
if (!picker) {
......@@ -978,10 +978,11 @@ void RendererWidget::setBackfaceCulling(bool culling) {
backfaceCulling = culling;
// update all currently managed actors
vtkSmartPointer<vtkActorCollection> ac = renderer->GetActors();
ac->InitTraversal();
vtkSmartPointer<vtkActorCollection> actorCollection = renderer->GetActors();
actorCollection->InitTraversal();
vtkSmartPointer<vtkActor> actor;
while (actor = ac->GetNextActor()) {
for(vtkIdType i = 0; i < actorCollection->GetNumberOfItems(); i++) {
actor = actorCollection->GetNextActor();
actor->GetProperty()->SetBackfaceCulling(backfaceCulling);
}
......@@ -1021,10 +1022,11 @@ void RendererWidget::setPointSize(double size) {
pointSize = size;
// update all currently managed actors
vtkSmartPointer<vtkActorCollection> ac = renderer->GetActors();
ac->InitTraversal();
vtkSmartPointer<vtkActorCollection> actorCollection = renderer->GetActors();
actorCollection->InitTraversal();
vtkSmartPointer<vtkActor> actor;
while (actor = ac->GetNextActor()) {
for(vtkIdType i = 0; i < actorCollection->GetNumberOfItems(); i++) {
actor = actorCollection->GetNextActor();
actor->GetProperty()->SetPointSize(pointSize);
}
......@@ -1475,4 +1477,4 @@ void RendererWidget::setPicker(vtkSmartPointer<vtkAbstractPropPicker> woodyWood)
}
}
\ No newline at end of file
}
......@@ -46,10 +46,10 @@ void ViewerDockStyle::drawControl(ControlElement element, const QStyleOption* op
// margin of title from frame
int margin = baseStyle()->pixelMetric(QStyle::PM_DockWidgetTitleMargin);
// starting position of the icon
QPoint iconPosition(margin + option->rect.left(), margin + option->rect.center().y() - width / 2);
painter->drawPixmap(iconPosition, icon->pixmap(width, width));
QPoint iconPosition(margin*2 + option->rect.left(), margin*2 + option->rect.center().y() - width / 2);
painter->drawPixmap(iconPosition, icon->pixmap(width - margin*2, width - margin*2));
const_cast<QStyleOption*>(option)->rect = option->rect.adjusted(width, 0, 0, 0);
const_cast<QStyleOption*>(option)->rect = option->rect.adjusted(width - margin*2, 0, 0, 0);
}
baseStyle()->drawControl(element, option, painter, widget);
......
......@@ -50,6 +50,8 @@ ActionViewer::ActionViewer(QString name) : Viewer(name, Viewer::DOCKED) {
// empty the list as this is an action viewer, it has nothing to do with Components
setComponents(QStringList());
setIcon(QPixmap(":/play"));
}
// ---------------- destructor ----------------
......
......@@ -29,12 +29,6 @@
// include generated actions headers
#include "Explorer.h"
// --------------- constructor -------------------
ExplorerExtension::ExplorerExtension() : ViewerExtension() {
// initialize the icon resources
Q_INIT_RESOURCE(ExplorerExtensionIcons);
}
// --------------- getViewers -------------------
void ExplorerExtension::init() {
registerDefaultViewer(Explorer);
......
......@@ -39,7 +39,7 @@ class EXPLORER_API ExplorerExtension : public camitk::ViewerExtension {
public:
/// Constructor
ExplorerExtension();
ExplorerExtension() = default;
/// Destructor
virtual ~ExplorerExtension() = default;
......
......@@ -37,6 +37,7 @@ using namespace camitk;
//----------------------- constructor ------------------------
FrameExplorer::FrameExplorer(QString name) : Viewer(name, Viewer::DOCKED) {
explorerTree = nullptr;
setIcon(QPixmap(":/axes"));
}
//----------------------- getWidget ------------------------
......
......@@ -39,7 +39,7 @@ class FRAMEEXPLORER_API FrameExplorerExtension : public camitk::ViewerExtension
public:
/// Constructor
FrameExplorerExtension() : ViewerExtension() {};
FrameExplorerExtension() = default;
/// Destructor
virtual ~FrameExplorerExtension() = default;
......
......@@ -39,7 +39,7 @@ class INTERACTIVEGEOMETRYVIEWER_API InteractiveGeometryViewerExtension : public
public:
/// Constructor
InteractiveGeometryViewerExtension() : camitk::ViewerExtension() {};
InteractiveGeometryViewerExtension() = default;
/// Destructor
virtual ~InteractiveGeometryViewerExtension() = default;
......
......@@ -39,7 +39,7 @@ class INTERACTIVESLICEVIEWER_API InteractiveSliceViewerExtension : public camitk
public:
/// Constructor
InteractiveSliceViewerExtension() : ViewerExtension() {};
InteractiveSliceViewerExtension() = default;
/// Destructor
virtual ~InteractiveSliceViewerExtension() = default;
......
......@@ -39,7 +39,7 @@ class MEDICALIMAGEVIEWER_API MedicalImageViewerExtension : public camitk::Viewer
public:
/// Constructor
MedicalImageViewerExtension() : ViewerExtension() {};
MedicalImageViewerExtension() = default;
/// Destructor
virtual ~MedicalImageViewerExtension() = default;
......
......@@ -46,6 +46,7 @@ PropertyExplorer::PropertyExplorer(QString name) : Viewer(name, Viewer::DOCKED)
applyButton = nullptr;
currentComponent = nullptr;
setIcon(QPixmap(":/properties"));
createProperties();
}
......
......@@ -39,7 +39,7 @@ class PROPERTYEXPLORER_API PropertyExplorerExtension : public camitk::ViewerExte
public:
/// Constructor
PropertyExplorerExtension() : ViewerExtension() {};
PropertyExplorerExtension() = default;
/// Destructor
virtual ~PropertyExplorerExtension() = default;
......
......@@ -2,7 +2,6 @@
camitk_extension(VIEWER_EXTENSION
DEFAULT
DEFINES COMPILE_TEXT_VIEWER_API
DESCRIPTION "An extension to add TextViewer (a pure simple text viewer)"
DESCRIPTION "An extension to add a TextViewer (a pure simple text viewer)"
INSTALL_ALL_HEADERS
)
......@@ -38,11 +38,12 @@
using namespace camitk;
// -------------------- Constructor --------------------
TextViewer::TextViewer(QString name) : Viewer(name) {
TextViewer::TextViewer(QString name) : Viewer(name, Viewer::DOCKED) {
inverse = nullptr;
myMenu = nullptr;
myWidget = nullptr;
displayedTopLevelComponents = 0;
setIcon(QPixmap(":/textviewer"));
}
// -------------------- Destructor --------------------
......@@ -51,7 +52,7 @@ TextViewer::~TextViewer() {
}
// -------------------- refresh --------------------
void TextViewer::refresh(Viewer* whoIsAsking) {
void TextViewer::refresh(Viewer*) {
// view everything?
if (displayedTopLevelComponents != Application::getTopLevelComponents().size()) {
// if there the nr of Component changed since last refresh,
......
......@@ -29,6 +29,12 @@
// include generated actions headers
#include "TextViewer.h"
// --------------- constructor -------------------
TextViewerExtension::TextViewerExtension() : ViewerExtension() {
// initialize the icon resources
Q_INIT_RESOURCE(TextViewerExtensionIcons);
}
// --------------- getActions -------------------
void TextViewerExtension::init() {
registerDefaultViewer(TextViewer);
......
......@@ -36,7 +36,7 @@ class TextViewerExtension : public camitk::ViewerExtension {
public:
/// Constructor
TextViewerExtension() : ViewerExtension() {};
TextViewerExtension();
/// Destructor
virtual ~TextViewerExtension() = default;
......
<RCC>
<qresource prefix="/">
<file alias="explorer">resources/folder-orange.png</file>
<file alias="textviewer">resources/text-document.png</file>
</qresource>
</RCC>
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