Computer Assisted Medical Intervention Tool Kit version 6.0
 
Loading...
Searching...
No Matches
TestTransformationExplorer.h
Go to the documentation of this file.
1/*****************************************************************************
2 * $CAMITK_LICENCE_BEGIN$
3 *
4 * CamiTK - Computer Assisted Medical Intervention ToolKit
5 * (c) 2001-2025 Univ. Grenoble Alpes, CNRS, Grenoble INP - UGA, TIMC, 38000 Grenoble, France
6 *
7 * Visit http://camitk.imag.fr for more information
8 *
9 * This file is part of CamiTK.
10 *
11 * CamiTK is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
14 *
15 * CamiTK is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public License
21 * version 3 along with CamiTK. If not, see <http://www.gnu.org/licenses/>.
22 *
23 * $CAMITK_LICENCE_END$
24 ****************************************************************************/
25
26#ifndef CAMITK_TESTTRANSFORMATIONEXPLORER_H
27#define CAMITK_TESTTRANSFORMATIONEXPLORER_H
28
29#include <QTest>
30
31#include <ranges>
32
33#include "FrameOfReference.h"
34#include "Transformation.h"
36#include "MeshComponent.h"
37#include "Application.h"
38#include "ExtensionManager.h"
40#include "Log.h"
41
42#include <vtkPolyData.h>
43#include <vtkSphereSource.h>
44#include <vtkMatrix4x4.h>
45#include <vtkTransform.h>
46
47
48using namespace camitk;
49
50class TestTransformationExplorer: public QObject {
51 Q_OBJECT
52
53 TransformationExplorer* explorer;
54
58 auto createFramesAndTransformation(QString frame1, QString frame2) {
61
63 return std::make_tuple(fr1, fr2, tr);
64 }
65
69 Component* createSphere(float radius = 1.0) {
70 auto sphereSource = vtkSmartPointer<vtkSphereSource>::New();
71 sphereSource->SetRadius(radius);
72 vtkSmartPointer<vtkPointSet> sphere(sphereSource->GetOutput());
73 return new MeshComponent(sphere, "Sphere");
74 }
75
76private slots:
77
79 void initTestCase() {
80 // show all log messages in the console
82 // no log messages will generate a QMessageBox
84 // no time stamp for reproducible log diff
86
87 // Make sure we load the TransformationExplorer viewer
88 // Load all the viewer extensions in order to use the TransformationExplorer factory (Application::getNewViewer)
90 // Create a new custom Geometry Viewer
91 explorer = dynamic_cast<TransformationExplorer*>(Application::getNewViewer("Explorer test", "TransformationExplorer"));
92 QVERIFY(explorer != nullptr);
93
94 // Initialize the widget and show the widget in order to build the widget (and its frame)
95 // and force the new viewer frame to be truly visible so that calling setFrame(..)
96 // (that itself calls refresh(..)) really updates of the actor transformation, the aim of this test
97 explorer->getWidget();
98
99 // Register the viewer so that it can be used in comp->setVisibility(...)
100 // and be automatically called during Application::refresh()
102 }
103
105 void cleanupTestCase() {
106 }
107
109 void cleanup() {
110
111 }
112
114 void playWithFramesTransformationsAndComponents() {
115 explorer->refresh();
116 auto [fr1, fr2, tr] = createFramesAndTransformation("Frame1", "Frame2");
117 explorer->refresh();
118 Component* c1 = createSphere();
119 QVERIFY(c1 != nullptr);
120 explorer->refresh();
121 delete c1;
122 explorer->refresh();
123 fr1 = nullptr;
124 fr2 = nullptr;
125 tr = nullptr;
127 explorer->refresh();
129 }
130
131};
132
133// } // namespace camitk
134
135#endif // CAMITK_TESTTRANSFORMATIONEXPLORER_H
Definition TestTransformationExplorer.h:50
Show a simplified version for the current TransformationManager state with existing transformations a...
Definition TransformationExplorer.h:59
static Viewer * getNewViewer(QString name, QString className)
instantiate a new viewer of the given name and given class name (Viewer inheriting class).
Definition Application.cpp:1119
static bool registerViewer(Viewer *)
register a viewer in the viewer list (therefore allowing it to be refreshed by the main window automa...
Definition Application.cpp:1046
A Component represents something that could be included in the explorer view, the interactive 3D view...
Definition sdk/libraries/core/component/Component.h:304
virtual void refresh()
refresh all the viewer that are currently displaying this Component At the end the InterfaceNode modi...
Definition sdk/libraries/core/component/Component.cpp:253
static void autoload()
Autoload component, action and viewer extensions (dlls) as well as registered CamiTK extension file.
Definition ExtensionManager.cpp:46
@ VIEWER
Viewer extensions: manages the presentation and user interaction logic.
Definition ExtensionManager.h:68
virtual void setTimeStampInformation(bool showTimeStamp)=0
By default a logger should always show the time-stamp in the form of "yyyy-MM-dd HH:mm:ss....
virtual void setMessageBoxLevel(LogLevel level)=0
Set the lowest log level that will open modal message box for messages instead of (silently/undisrupt...
virtual void setLogLevel(LogLevel level)=0
Sets Current verbosity level of the log.
@ TRACE
all types of messages are logged
Definition InterfaceLogger.h:65
@ NONE
No message is logged.
Definition InterfaceLogger.h:61
static InterfaceLogger * getLogger()
get the current application logger
Definition Log.cpp:50
Basic component to manage any kind of mesh.
Definition MeshComponent.h:53
static QVector< FrameOfReference * > getFramesOfReference()
Get a list of all stored FrameOfReference.
Definition TransformationManager.cpp:204
static std::shared_ptr< Transformation > addTransformation(const QVariant &)
Create and register a new Transformation from a QVariant (usually from a JSON representation in a ....
Definition TransformationManager.cpp:533
static std::shared_ptr< FrameOfReference > addFrameOfReference(QString name, QString description="")
Add a FrameOfReference with a name and description This is the standard way to create a new FrameOfRe...
Definition TransformationManager.cpp:168
static void cleanupFramesAndTransformations()
Remove transformations and frames that are unused (i.e.
Definition TransformationManager.cpp:630
Definition Action.cpp:40