11/* *
22 * \file QtVtkTransformationPanel.cpp
33 * \author Charles PIGNEROL, CEA/DAM/DCLC
4- * \date 16 /01/2026
4+ * \date 20 /01/2026
55 */
66#include " QtVtk/QtVtkTransformationPanel.h"
77#include " QtVtk/QtVTKPointLocalizatorPanel.h"
@@ -584,7 +584,33 @@ void QtVtkIntrinsicTransformationPanel::transformationModifiedCallback ( )
584584 if ((0 != _renderer) && (true == displayTrihedron ( )))
585585 {
586586 if (0 != _localTrihedron)
587- _localTrihedron->SetTransform (getTransformation ( ));
587+ {
588+ vtkSmartPointer<vtkTransform> transform (getTransformation ( ));
589+ _localTrihedron->SetTransform (transform);
590+ double center [3 ] = { 0 ., 0 ., 0 . };
591+ if (0 != transform)
592+ transform->GetPosition (center);
593+ double scale [3 ] = {
594+ _localTrihedron->GetXAxisArrowActor ( ).GetScale ( )[0 ],
595+ _localTrihedron->GetYAxisArrowActor ( ).GetScale ( )[1 ],
596+ _localTrihedron->GetZAxisArrowActor ( ).GetScale ( )[2 ],
597+ };
598+ double xcoords [3 ] = { scale [0 ] * 1 ., 0.1 , 0 . };
599+ transform->MultiplyPoint (xcoords, xcoords);
600+ _localTrihedron->GetXAxisLabelActor2D ( )->GetPositionCoordinate ( )->SetCoordinateSystemToWorld ( );
601+ _localTrihedron->GetXAxisLabelActor2D ( )->GetPositionCoordinate ( )->SetValue (
602+ xcoords [0 ] + center [0 ], xcoords [1 ] + center [1 ], xcoords [2 ] + center [2 ]);
603+ double ycoords [3 ] = { 0.1 , scale [1 ], 0 . };
604+ transform->MultiplyPoint (ycoords, ycoords);
605+ _localTrihedron->GetYAxisLabelActor2D ( )->GetPositionCoordinate ( )->SetCoordinateSystemToWorld ( );
606+ _localTrihedron->GetYAxisLabelActor2D ( )->GetPositionCoordinate ( )->SetValue (
607+ ycoords [0 ], ycoords [1 ], ycoords [2 ]); // center a priori inutile pour y ...
608+ double zcoords [3 ] = { 0 ., 0.1 , scale [2 ] };
609+ transform->MultiplyPoint (zcoords, zcoords);
610+ _localTrihedron->GetZAxisLabelActor2D ( )->GetPositionCoordinate ( )->SetCoordinateSystemToWorld ( );
611+ _localTrihedron->GetZAxisLabelActor2D ( )->GetPositionCoordinate ( )->SetValue (
612+ zcoords [0 ] + center [0 ], zcoords [1 ] + center [1 ], zcoords [2 ] + center [2 ]);
613+ } // if (0 != _localTrihedron)
588614 if (0 != _renderer->GetRenderWindow ( ))
589615 _renderer->GetRenderWindow ( )->Render ( );
590616 } // if ((0 != _renderer) && (true == displayTrihedron ( )))
@@ -596,27 +622,38 @@ void QtVtkIntrinsicTransformationPanel::transformationModifiedCallback ( )
596622static vtkTrihedron* createTrihedron (bool global, vtkFloatingPointType bounds [6 ])
597623{
598624 // Les trièdres doivent dépasser légèrement de la zone d'intérêt :
599- const double xscale = 1.25 * (bounds [1 ] - bounds [0 ]);
600- const double yscale = 1.25 * (bounds [3 ] - bounds [2 ]);
601- const double zscale = 1.25 * (bounds [5 ] - bounds [4 ]);
602-
625+ double xscale = 1.25 * (bounds [1 ] - bounds [0 ]);
626+ double yscale = 1.25 * (bounds [3 ] - bounds [2 ]);
627+ double zscale = 1.25 * (bounds [5 ] - bounds [4 ]);
628+ // On peut arriver du 2D : si les 3 sont ~nuls on est mort !
629+ if (fabs (yscale) < 1E-9 ) yscale = std::max (xscale, zscale);
630+ if (fabs (zscale) < 1E-9 ) zscale = std::max (xscale, yscale);
631+ if (fabs (xscale) < 1E-9 ) xscale = std::max (yscale, zscale);
632+
603633 vtkTrihedron* trihedron = vtkTrihedron::New ( );
634+ const int labelOffset = 2 ;
604635 if (true == global)
605636 {
606- trihedron->SetAxisLabels (" x" , " y" , " z" );
607- trihedron->SetLabelsOffsets (-15 , -15 , -15 );
637+ trihedron->SetAxisLabels (" x" , " y" , " z" );
638+ trihedron->SetLabelsOffsets (-labelOffset , -labelOffset , -labelOffset );
608639 }
609640 else
610641 {
611- trihedron->SetAxisLabels (" x' " , " y' " , " z' " );
612- trihedron->SetLabelsOffsets (- 15 , - 15 , - 15 );
642+ trihedron->SetAxisLabels (" x'" , " y'" , " z'" );
643+ trihedron->SetLabelsOffsets (labelOffset, labelOffset, labelOffset );
613644 } // else if (true == global)
614645
615646 trihedron->SetLabel2D (true );
647+ assert (0 != trihedron->GetXAxisLabelActor2D ( ));
648+ assert (0 != trihedron->GetYAxisLabelActor2D ( ));
649+ assert (0 != trihedron->GetZAxisLabelActor2D ( ));
616650 // Rem CP : c'est sans effet si je passe des valeurs != à SetScale pour x, y et z. Pourquoi ???
617651 trihedron->GetXAxisArrowActor ( ).SetScale (xscale, xscale, xscale);
618652 trihedron->GetYAxisArrowActor ( ).SetScale (yscale, yscale, yscale);
619653 trihedron->GetZAxisArrowActor ( ).SetScale (zscale, zscale, zscale);
654+ trihedron->GetXAxisLabelActor2D ( )->GetPositionCoordinate ( )->SetValue (xscale * 1 ., 0.1 , 0 .);
655+ trihedron->GetYAxisLabelActor2D ( )->GetPositionCoordinate ( )->SetValue (0.1 , yscale * 1 ., 0 .);
656+ trihedron->GetZAxisLabelActor2D ( )->GetPositionCoordinate ( )->SetValue (0 ., 0.1 , zscale * 1 .);
620657 trihedron->GetXAxisArrowSource ( ).SetShaftRadius (QtVtkTransformationPanel::shaftRadius / xscale);
621658 trihedron->GetXAxisArrowSource ( ).SetTipRadius (QtVtkTransformationPanel::tipRadius / xscale);
622659 trihedron->GetXAxisArrowSource ( ).SetTipLength (QtVtkTransformationPanel::tipLength / xscale);
@@ -871,11 +908,16 @@ const QtVtkIntrinsicTransformationPanel& QtVtkTransformationPanel::getIntrinsicP
871908
872909void QtVtkTransformationPanel::transformationTypeModifiedCallback ( )
873910{
911+ assert (0 != _intrinsicPanel);
912+ assert (0 != _extrinsicPanel);
913+ assert (0 != _contextualHelpLabel);
914+ assert (0 != _imageLabel);
874915 const bool extrinsic = isExtrinsic ( );
875916 if (true == extrinsic)
876917 {
877918 _intrinsicPanel->setVisible (false );
878919 _extrinsicPanel->setVisible (true );
920+ _contextualHelpLabel->setText (QSTR (" Transformation extrinsèque (dans le repère global) : les axes ne bougent pas." ));
879921 QPixmap pixmap (" :/images/extrinsic.png" );
880922 QSize s = pixmap.size ( );
881923 pixmap = pixmap.scaledToHeight (0.5 * s.height ( ), Qt::SmoothTransformation);
@@ -885,9 +927,10 @@ void QtVtkTransformationPanel::transformationTypeModifiedCallback ( )
885927 {
886928 _extrinsicPanel->setVisible (false );
887929 _intrinsicPanel->setVisible (true );
930+ _contextualHelpLabel->setText (QSTR (" Transformation intrinsèque (dans le repère local) : les axes sont soumis à chaque étape de la transformation." ));
888931 QPixmap pixmap (" :/images/intrinsic.png" );
889932 QSize s = pixmap.size ( );
890- pixmap = pixmap.scaledToHeight (0 .5 * s. height ( ), Qt::SmoothTransformation);
933+ pixmap = pixmap.scaledToHeight (1 .5 * _intrinsicPanel-> height ( ), Qt::SmoothTransformation);
891934 _imageLabel->setPixmap (pixmap);
892935 } // else if (true == extrinsic)
893936
0 commit comments