1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
|
/*****************************************************************************
* $CAMITK_LICENCE_BEGIN$
*
* CamiTK - Computer Assisted Medical Intervention ToolKit
* (c) 2001-2025 Univ. Grenoble Alpes, CNRS, Grenoble INP - UGA, TIMC, 38000 Grenoble, France
*
* 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>
#include <InteractiveGeometryViewer.h>
#include <InteractiveSliceViewer.h>
#include <Log.h>
//-- Qt stuff
#include <QGridLayout>
using namespace camitk;
// -------------------- Constructor --------------------
MixedViewer::MixedViewer(QString name) : Viewer(name) {
myWidget = nullptr;
setComponentClassNames(QStringList() << "ImageComponent" << "MixedComponent");
setDescription("A two panels viewer (left is axial, right is 3D), specialized in mixed component");
}
// -------------------- Destructor --------------------
MixedViewer::~MixedViewer() {
delete myWidget;
}
// -------------------- refresh --------------------
void MixedViewer::refresh(Viewer*) {
// 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("Axial Viewer")->setVisible(true);
Application::getViewer("3D Viewer")->setVisible(true);
}
// -------------------- getWidget --------------------
QWidget* MixedViewer::getWidget() {
if (myWidget == nullptr) {
myWidget = new QWidget();
//-- init layout
auto* myWidgetLayout = new QGridLayout();
myWidgetLayout->setSpacing(0);
myWidgetLayout->setContentsMargins(0, 0, 0, 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 embedded them somewhere else in the meanwhile)
InteractiveGeometryViewer* default3DViewer = dynamic_cast<InteractiveGeometryViewer*>(Application::getViewer("3D Viewer"));
if (default3DViewer != nullptr) {
default3DViewer->setEmbedder(rightLayout);
}
else {
CAMITK_WARNING(tr("Cannot find \"3D Viewer\". This viewer is mandatory for building \"Mixed Viewer\"."))
}
InteractiveSliceViewer* axialViewer = dynamic_cast<InteractiveSliceViewer*>(Application::getViewer("Axial Viewer"));
if (default3DViewer != nullptr) {
axialViewer->setEmbedder(leftLayout);
}
else {
CAMITK_WARNING(tr("Cannot find \"Axial Viewer\". This viewer is mandatory for building \"Mixed Viewer\"."))
}
return myWidget;
}
|