Computer Assisted Medical Intervention Tool Kit  version 6.0
Loading...
Searching...
No Matches
TransformationManager.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 TRANSFORMATIONMANAGER_H
27#define TRANSFORMATIONMANAGER_H
28
29// -- Core stuff
30#include "CamiTKAPI.h"
31
32#include "FrameOfReference.h"
33#include "Transformation.h"
34
35// -- QT stuff
36#include <QHash>
37#include <QString>
38#include <QVector>
39#include <QPalette>
40#include <QVariant>
41
42#include <vtkSmartPointer.h>
43#include <vtkTransform.h>
44
45#include <memory>
46#include <unordered_set>
47
48namespace camitk {
49
50class Transformation;
52class Application;
53
234public:
235
237 static QString toString();
238
241
245 static std::shared_ptr<FrameOfReference> getFrameOfReferenceOwnership(const QUuid& uuid);
246
253 static std::shared_ptr<FrameOfReference> getFrameOfReferenceOwnership(const FrameOfReference*);
254
261 static std::shared_ptr<FrameOfReference> addFrameOfReference(QString name, QString description = "");
262
268 static std::shared_ptr<FrameOfReference> addFrameOfReference(const FrameOfReference&);
269
273 static QVector<FrameOfReference*> getFramesOfReference();
275
278
285 static bool hasPath(const FrameOfReference* from, const FrameOfReference* to);
286
292 static bool isDefaultIdentityToWorld(const Transformation*);
293
298
309 static std::shared_ptr<Transformation> getTransformationOwnership(const Transformation*);
310
321 static std::shared_ptr<Transformation> getTransformationOwnership(const QUuid& uuid);
322
333 static std::shared_ptr<Transformation> getTransformationOwnership(const FrameOfReference* from, const FrameOfReference* to);
334
339 static void ensurePathToWorld(const FrameOfReference* frame);
340
349
359 static const FrameOfReference* getWorldFrame();
360
364 static QVector<Transformation*> getDirectTransformations();
365
369 static QVector<Transformation*> getTransformations();
370
373 static std::shared_ptr<Transformation> addTransformation(const QVariant&);
374
378 static std::shared_ptr<Transformation> addTransformation(const FrameOfReference* from, const FrameOfReference* to);
379
381 static std::shared_ptr<Transformation> addTransformation(const std::shared_ptr<FrameOfReference>& from, const std::shared_ptr<FrameOfReference>& to);
382
388 static std::shared_ptr<Transformation> addTransformation(const FrameOfReference* from, const FrameOfReference* to, vtkSmartPointer<vtkTransform> vtkTr);
389
391 static std::shared_ptr<Transformation> addTransformation(const std::shared_ptr<FrameOfReference>& from, const std::shared_ptr<FrameOfReference>& to, vtkSmartPointer<vtkTransform> vtkTr);
392
396 static std::shared_ptr<Transformation> addTransformation(const FrameOfReference* from, const FrameOfReference* to, const vtkMatrix4x4* matrix);
397
399 static std::shared_ptr<Transformation> addTransformation(const std::shared_ptr<FrameOfReference>& from, const std::shared_ptr<FrameOfReference>& to, const vtkMatrix4x4* matrix);
400
401
406
422 static bool removeTransformation(std::shared_ptr<Transformation>& tr);
423
429 static bool removeTransformation(const FrameOfReference* from, const FrameOfReference* to);
430
437
439
442 static bool updateTransformation(const FrameOfReference* from, const FrameOfReference* to, vtkSmartPointer<vtkTransform> vtkTr);
443
445 static bool updateTransformation(const FrameOfReference* from, const FrameOfReference* to, vtkMatrix4x4* matrix);
446
449 static bool updateTransformation(Transformation* tr, vtkSmartPointer<vtkTransform> vtkTr);
450
452 static bool updateTransformation(Transformation* tr, vtkMatrix4x4* matrix);
453
455
459 static bool hasSources(const Transformation*);
460
464 static QVector<Transformation*> getSources(const Transformation*);
465
467 static bool isInverseTransformation(const Transformation*);
468
471
475 static bool isCompositeTransformation(const Transformation* tr);
476
478
486 static QVariant toVariant();
487
495 static void fromVariant(const QVariant&);
496
497private:
498
501
503 static std::shared_ptr<FrameOfReference> worldFrame;
504
506 static std::vector<std::shared_ptr<FrameOfReference>> frames;
507
509 static std::vector<std::shared_ptr<Transformation>> transformations;
510
512 static QHash<QUuid, FrameOfReference*> frameMap;
513
515 static QHash<QUuid, Transformation*> transformationMap;
516
521 static QHash<const Transformation*, QVector<std::shared_ptr<Transformation>>> transformationSources;
522
524 static QHash<const FrameOfReference*, QHash<const FrameOfReference*, Transformation*>> transformationFromTo;
525
542 static std::unordered_set<const Transformation*> defaultIdentityToWorldTransformations;
543
552 static std::shared_ptr<Transformation> registerTransformation(Transformation* tr, const QVector<std::shared_ptr<Transformation>>& sources = {});
553
563 static QVector<std::shared_ptr<Transformation>> getPath(const FrameOfReference* from, const FrameOfReference* to);
564
565
569 static std::shared_ptr<Transformation> addCompositeTransformation(QVector<std::shared_ptr<Transformation>> transforms);
570
575 static std::shared_ptr<FrameOfReference> addFrameOfReference(QUuid uuid, QString name, QString description, int dimensions = 3, const AnatomicalOrientation& ao = {}, std::vector<Unit> units = {"", "", "", "", ""});
576
580 static std::shared_ptr<FrameOfReference> addFrameOfReference(const QVariant&);
581
583
586 static bool removeDefaultPaths(const FrameOfReference* from, const FrameOfReference* to);
587
590 static void removeTransformationFromInternalStructures(const Transformation* trToDelete);
591
593 static void cleanupCompositeTransformations();
594
599 static std::shared_ptr<Transformation> getTransformationSharedPtr(const Transformation*);
600};
601}
602#endif // TRANSFORMATIONMANAGER_H
#define CAMITK_API
Definition CamiTKAPI.h:66
const char * description
Definition applications/cepgenerator/main.cpp:38
Definition AnatomicalOrientation.h:81
The generic/default application.
Definition Application.h:83
FrameOfReference is only a label for an abstract coordinate system.
Definition FrameOfReference.h:69
TransformationManager manages frames of reference and transformations for a CamiTK Application.
Definition TransformationManager.h:233
static bool preferredDefaultIdentityToWorldLink(const FrameOfReference *frame)
Call this method when you prefer (for visualization purpose only) to have a direct link to world from...
Definition TransformationManager.cpp:397
static void ensurePathToWorld(const FrameOfReference *frame)
Make sure there is a Transformation from the given Frame to the world Frame.
Definition TransformationManager.cpp:385
static bool isDefaultIdentityToWorld(const Transformation *)
Is the transformation a default one ?
Definition TransformationManager.cpp:320
static QString toString()
get current state as a QString
Definition TransformationManager.cpp:53
static std::shared_ptr< FrameOfReference > getFrameOfReferenceOwnership(const QUuid &uuid)
FrameOfReference Management.
Definition TransformationManager.cpp:137
static bool hasSources(const Transformation *)
Was this Transformation computed from others or not?
Definition TransformationManager.cpp:791
static bool updateTransformation(const FrameOfReference *from, const FrameOfReference *to, vtkSmartPointer< vtkTransform > vtkTr)
Modify the Transformation between the two frames by setting its vtkTransform.
Definition TransformationManager.cpp:781
static bool isCompositeTransformation(const Transformation *tr)
Is this transformation composed of two or more transformations ?
Definition TransformationManager.cpp:822
static QVector< FrameOfReference * > getFramesOfReference()
Get a list of all stored FrameOfReference.
Definition TransformationManager.cpp:204
static void fromVariant(const QVariant &)
Load Frame and Transformation data from a QVariant.
Definition TransformationManager.cpp:857
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 const FrameOfReference * getWorldFrame()
Get the WorldFrame.
Definition TransformationManager.cpp:116
static Transformation * getInverseTransformation(const Transformation *tr)
Definition TransformationManager.cpp:812
static bool hasPath(const FrameOfReference *from, const FrameOfReference *to)
Transformation Management.
Definition TransformationManager.cpp:213
static QVector< Transformation * > getTransformations()
Returns the list of all transformations managed in the system, independents or not.
Definition TransformationManager.cpp:128
static bool isInverseTransformation(const Transformation *)
Definition TransformationManager.cpp:802
static QVector< Transformation * > getDirectTransformations()
Returns the list of direct transformations, that is the transformations that are independent of any o...
Definition TransformationManager.cpp:410
static std::shared_ptr< Transformation > getTransformationOwnership(const Transformation *)
Get the shared_ptr that owns the given Transformation.
Definition TransformationManager.cpp:356
static QVariant toVariant()
Save Frame and Transformation data to a QVariant.
Definition TransformationManager.cpp:832
static Transformation * getTransformation(const FrameOfReference *from, const FrameOfReference *to)
Get a transformation if it exists or compute it if a path exists between the frames.
Definition TransformationManager.cpp:325
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
static bool removeTransformation(std::shared_ptr< Transformation > &tr)
Remove an existing transformation between the two frames.
Definition TransformationManager.cpp:671
static QVector< Transformation * > getSources(const Transformation *)
Get the list of sources used to compute the provided Transformation.
Definition TransformationManager.cpp:875
Transformation represents a geometrical transformation between two FrameOfReferences.
Definition Transformation.h:81
Definition Action.cpp:40