- **Relative** - if this option is switched on, trihedron axes scale to fit the size of the scene displayed in 3D viewer.
- **Show static trihedron** - allows to show/hide the static mini-trihedron located in the bottom-left corner of the viewer.
+ The settings below are for trihedron labels.
+
+ - **Use Custom Text Font** - allows to change text's font for trihedron labels individually for each axis (only for OCC 3D Viewer):
+
+ - X Text Font
+ - Y Text Font
+ - Z Text Font
+
+ Notes:
+ - Not all fonts are supported and could be automatically replaced by the similar ones.
+ - Changing the size of the font is not implemented at the moment.
+ - Works only with OCCT V7_7_0 and greater. With older versions altering the font settings does nothing.
+
+ - **Use Custom Text Color** - allows to change text's color for trihedron labels individually for each axis (only for OCC 3D Viewer and VTK 3D Viewer):
+
+ - X Text Color
+ - Y Text Color
+ - Z Text Color
+
.. _occ_preferences:
OCC 3D Viewer Preferences
SVTK_Viewer* vm = dynamic_cast<SVTK_Viewer*>( viewMgr->getViewModel() );
if( vm )
{
+ // TODO:
+ // Methods like setTrihedronSize() and setStaticTrihedronVisible() do nothing for a created view here
+ // because such a view doesn't exist on this step.
+ // It's going to be created on viewMgr->createViewWindow() way below.
+ // As a workaround we could update a view inside SVTK_Viewer::onViewCreated() method.
vm->setProjectionMode( resMgr->integerValue( "VTKViewer", "projection_mode", vm->projectionMode() ) );
vm->setStereoType( resMgr->integerValue( "VTKViewer", "stereo_type", vm->stereoType() ) );
vm->setAnaglyphFilter( resMgr->integerValue( "VTKViewer", "anaglyph_filter", vm->anaglyphFilter() ) );
anIndicesList << 0 << 1;
pref->setItemProperty( "strings", aValuesList, occZoomingStyleMode );
pref->setItemProperty( "indexes", anIndicesList, occZoomingStyleMode );
+
// ... "Trihedron" group <<start>>
int occTriGroup = pref->addPreference( tr( "PREF_TRIHEDRON" ), Viewer3DGroup );
pref->setItemProperty( "columns", 2, occTriGroup );
pref->setItemProperty( "max", 1000, occTS );
// .... -> relative size of trihedron
pref->addPreference( tr( "PREF_RELATIVE_SIZE" ), occTriGroup, LightApp_Preferences::Bool, "3DViewer", "relative_size" );
+
+ // .... -> trihedron text's font
+ const int trihedronTxtFontDef = pref->addPreference(tr("PREF_TRIHEDRON_TEXT_FONT_CUSTOM"), Viewer3DGroup, LightApp_Preferences::Auto, "3DViewer", "trihedron_text_font_custom");
+ pref->setItemProperty("columns", 1, trihedronTxtFontDef);
+
+ int trihedronFont = pref->addPreference(tr("PREF_TRIHEDRON_X_TEXT_FONT"), trihedronTxtFontDef, LightApp_Preferences::Font, "3DViewer", "trihedron_x_text_font");
+ pref->setItemProperty("features", QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic, trihedronFont);
+ trihedronFont = pref->addPreference(tr("PREF_TRIHEDRON_Y_TEXT_FONT"), trihedronTxtFontDef, LightApp_Preferences::Font, "3DViewer", "trihedron_y_text_font");
+ pref->setItemProperty("features", QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic, trihedronFont);
+ trihedronFont = pref->addPreference(tr("PREF_TRIHEDRON_Z_TEXT_FONT"), trihedronTxtFontDef, LightApp_Preferences::Font, "3DViewer", "trihedron_z_text_font");
+ pref->setItemProperty("features", QtxFontEdit::Family | QtxFontEdit::Bold | QtxFontEdit::Italic, trihedronFont);
+
+ // .... -> trihedron text's color
+ const int trihedronTxtColorDef = pref->addPreference(tr("PREF_TRIHEDRON_TEXT_COLOR_CUSTOM"), Viewer3DGroup, LightApp_Preferences::Auto, "3DViewer", "trihedron_text_color_custom");
+ pref->setItemProperty("columns", 3, trihedronTxtColorDef);
+
+ pref->addPreference(tr("PREF_TRIHEDRON_X_TEXT_COLOR"), trihedronTxtColorDef, LightApp_Preferences::Color, "3DViewer", "trihedron_x_text_color");
+ pref->addPreference(tr("PREF_TRIHEDRON_Y_TEXT_COLOR"), trihedronTxtColorDef, LightApp_Preferences::Color, "3DViewer", "trihedron_y_text_color");
+ pref->addPreference(tr("PREF_TRIHEDRON_Z_TEXT_COLOR"), trihedronTxtColorDef, LightApp_Preferences::Color, "3DViewer", "trihedron_z_text_color");
+
// .... -> show static trihedron
pref->addPreference( tr( "PREF_SHOW_STATIC_TRIHEDRON" ), occTriGroup, LightApp_Preferences::Bool, "3DViewer", "show_static_trihedron" );
// ... "Trihedron" group <<end>>
pref->retrieve();
}
+// Helper funcitons to reduce code repetition
+namespace
+{
+#ifndef DISABLE_OCCVIEWER
+ /*!
+ Iterates all OCCT viewers and call a given functor with each viewer as an argument.
+ \param app - current application
+ \param functor - function to call
+ */
+ template<typename T>
+ void forEachOcctViewer(const LightApp_Application& app, T functor)
+ {
+ QList<SUIT_ViewManager*> lst;
+
+ app.viewManagers(OCCViewer_Viewer::Type(), lst);
+ QListIterator<SUIT_ViewManager*> itOCC(lst);
+ while (itOCC.hasNext())
+ {
+ SUIT_ViewModel* vm = itOCC.next()->getViewModel();
+ if (!vm || !vm->inherits("OCCViewer_Viewer"))
+ continue;
+
+ OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
+ functor(occVM);
+ occVM->getAISContext()->UpdateCurrentViewer();
+ }
+ }
+#endif
+
+#if !defined DISABLE_VTKVIEWER && !defined DISABLE_SALOMEOBJECT
+/*!
+ Iterates all Vtk viewers and call a given functor with each viewer as an argument
+ \param app - current application
+ \param functor - function to call
+ */
+ template<typename T>
+ void forEachVtkViewer(const LightApp_Application& app, T functor)
+ {
+ QList<SUIT_ViewManager*> lst;
+
+ app.viewManagers(SVTK_Viewer::Type(), lst);
+ QListIterator<SUIT_ViewManager*> itVTK(lst);
+ while (itVTK.hasNext())
+ {
+ SUIT_ViewModel* vm = itVTK.next()->getViewModel();
+ if (!vm || !vm->inherits("SVTK_Viewer"))
+ continue;
+
+ SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>(vm);
+ if(vtkVM)
+ {
+ functor(vtkVM);
+ vtkVM->Repaint();
+ }
+ }
+ }
+#endif
+}
+
/*!
Changes appearance of application according to changed preferences
\param sec - section
#endif
}
+ if (sec == QString("3DViewer"))
+ {
+ if (param == QString("trihedron_text_font_custom") ||
+ param == QString("trihedron_x_text_font") ||
+ param == QString("trihedron_y_text_font") ||
+ param == QString("trihedron_z_text_font"))
+ {
+#ifndef DISABLE_OCCVIEWER
+ forEachOcctViewer(*this, [](OCCViewer_Viewer* occVM) {
+ occVM->setTrihedronTextFont();
+ occVM->setStaticTrihedronTextFont();
+ });
+#endif
+ }
+ else if (param == QString("trihedron_text_color_custom") ||
+ param == QString("trihedron_x_text_color") ||
+ param == QString("trihedron_y_text_color") ||
+ param == QString("trihedron_z_text_color"))
+ {
+#ifndef DISABLE_OCCVIEWER
+ forEachOcctViewer(*this, [](OCCViewer_Viewer* occVM) {
+ occVM->setTrihedronTextColor();
+ occVM->setStaticTrihedronTextColor();
+ });
+#endif
+#if !defined DISABLE_VTKVIEWER && !defined DISABLE_SALOMEOBJECT
+ forEachVtkViewer(*this, [](SVTK_Viewer* vtkVM) {
+ vtkVM->setTrihedronTextColor();
+ vtkVM->setStaticTrihedronTextColor();
+ });
+#endif
+ }
+ }
+
if ( sec == QString( "3DViewer" ) && param == QString( "show_static_trihedron" ) )
{
bool isVisible = resMgr->booleanValue( "3DViewer", "show_static_trihedron", true );
<section name="3DViewer">
<parameter name="trihedron_size" value="100" />
<parameter name="relative_size" value="true"/>
+ <parameter name="trihedron_text_font_custom" value="false"/>
+ <parameter name="trihedron_text_color_custom" value="false"/>
+ <parameter name="trihedron_x_text_font" value="Sans Serif,12"/>
+ <parameter name="trihedron_x_text_color" value="255, 0, 0"/>
+ <parameter name="trihedron_y_text_font" value="Sans Serif,12"/>
+ <parameter name="trihedron_y_text_color" value="0, 255, 0"/>
+ <parameter name="trihedron_z_text_font" value="Sans Serif,12"/>
+ <parameter name="trihedron_z_text_color" value="0, 0, 255"/>
<parameter name="navigation_mode" value="0" />
<parameter name="zooming_mode" value="1" />
<parameter name="show_static_trihedron" value="true"/>
<source>PREF_TRIHEDRON_SIZE</source>
<translation>Size</translation>
</message>
+ <message>
+ <source>PREF_TRIHEDRON_TEXT_FONT_CUSTOM</source>
+ <translation>Use Custom Text Font</translation>
+ </message>
+ <message>
+ <source>PREF_TRIHEDRON_TEXT_COLOR_CUSTOM</source>
+ <translation>Use Custom Text Color</translation>
+ </message>
+ <message>
+ <source>PREF_TRIHEDRON_X_TEXT_FONT</source>
+ <translation>X Text Font</translation>
+ </message>
+ <message>
+ <source>PREF_TRIHEDRON_X_TEXT_COLOR</source>
+ <translation>X Text Color</translation>
+ </message>
+ <message>
+ <source>PREF_TRIHEDRON_Y_TEXT_FONT</source>
+ <translation>Y Text Font</translation>
+ </message>
+ <message>
+ <source>PREF_TRIHEDRON_Y_TEXT_COLOR</source>
+ <translation>Y Text Color</translation>
+ </message>
+ <message>
+ <source>PREF_TRIHEDRON_Z_TEXT_FONT</source>
+ <translation>Z Text Font</translation>
+ </message>
+ <message>
+ <source>PREF_TRIHEDRON_Z_TEXT_COLOR</source>
+ <translation>Z Text Color</translation>
+ </message>
<message>
<source>OBJECT_BROWSER</source>
<translation>Object Browser</translation>
<source>PREF_TRIHEDRON_SIZE</source>
<translation>Taille</translation>
</message>
+ <message>
+ <source>PREF_TRIHEDRON_TEXT_FONT_CUSTOM</source>
+ <translation>Utiliser une police de texte personnalisée</translation>
+ </message>
+ <message>
+ <source>PREF_TRIHEDRON_TEXT_COLOR_CUSTOM</source>
+ <translation>Utiliser une couleur de texte personnalisée</translation>
+ </message>
+ <message>
+ <source>PREF_TRIHEDRON_X_TEXT_FONT</source>
+ <translation>X Police du texte</translation>
+ </message>
+ <message>
+ <source>PREF_TRIHEDRON_X_TEXT_COLOR</source>
+ <translation>X Couleur du texte</translation>
+ </message>
+ <message>
+ <source>PREF_TRIHEDRON_Y_TEXT_FONT</source>
+ <translation>Y Police du texte</translation>
+ </message>
+ <message>
+ <source>PREF_TRIHEDRON_Y_TEXT_COLOR</source>
+ <translation>Y Couleur du texte</translation>
+ </message>
+ <message>
+ <source>PREF_TRIHEDRON_Z_TEXT_FONT</source>
+ <translation>Z Police du texte</translation>
+ </message>
+ <message>
+ <source>PREF_TRIHEDRON_Z_TEXT_COLOR</source>
+ <translation>Z Couleur du texte</translation>
+ </message>
<message>
<source>OBJECT_BROWSER</source>
<translation>Arbre d'étude</translation>
<source>PREF_TRIHEDRON_SIZE</source>
<translation>サイズ</translation>
</message>
+ <message>
+ <source>PREF_TRIHEDRON_TEXT_FONT_CUSTOM</source>
+ <translation>カスタムテキストフォントを使用する</translation>
+ </message>
+ <message>
+ <source>PREF_TRIHEDRON_TEXT_COLOR_CUSTOM</source>
+ <translation>カスタムテキストカラーを使用する</translation>
+ </message>
+ <message>
+ <source>PREF_TRIHEDRON_X_TEXT_FONT</source>
+ <translation>X テキストフォント</translation>
+ </message>
+ <message>
+ <source>PREF_TRIHEDRON_X_TEXT_COLOR</source>
+ <translation>X テキストの色</translation>
+ </message>
+ <message>
+ <source>PREF_TRIHEDRON_Y_TEXT_FONT</source>
+ <translation>Y テキストフォント</translation>
+ </message>
+ <message>
+ <source>PREF_TRIHEDRON_Y_TEXT_COLOR</source>
+ <translation>Y テキストの色</translation>
+ </message>
+ <message>
+ <source>PREF_TRIHEDRON_Z_TEXT_FONT</source>
+ <translation>Z テキストフォント</translation>
+ </message>
+ <message>
+ <source>PREF_TRIHEDRON_Z_TEXT_COLOR</source>
+ <translation>Z テキストの色</translation>
+ </message>
<message>
<source>OBJECT_BROWSER</source>
<translation>オブジェクトブラウザー</translation>
SET(_other_HEADERS
OCCViewer.h
OCCViewer_ClipPlane.h
+ OCCViewer_TrihedronSetup.h
OCCViewer_VService.h
OCCViewer_Utilities.h
)
OCCViewer_FontWidget.cxx
OCCViewer_SetRotationPointDlg.cxx
OCCViewer_ToolTip.cxx
+ OCCViewer_TrihedronSetup.cxx
OCCViewer_VService.cxx
OCCViewer_ViewFrame.cxx
OCCViewer_ViewManager.cxx
*/
Quantity_Color OCCViewer::color( const QColor& c )
{
- Quantity_Color aColor;
- if ( c.isValid() )
- aColor = Quantity_Color( c.red() / 255., c.green() / 255.,
- c.blue() / 255., Quantity_TOC_RGB );
- return aColor;
+ if (c.isValid())
+ return Quantity_Color(c.redF(), c.greenF(), c.blueF(), Quantity_TOC_RGB);
+
+ return {};
}
/*!
--- /dev/null
+// Copyright (C) 2007-2023 CEA, EDF, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library 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 for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See https://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "OCCViewer_TrihedronSetup.h"
+
+#include <Basics_OCCTVersion.hxx>
+#include <AIS_Trihedron.hxx>
+#include <V3d_View.hxx>
+#include <V3d_Trihedron.hxx>
+
+#include <QFont>
+#include <QColor>
+
+
+// Common helper functions to separate algorithm from implementation
+// and reduce code repetition.
+namespace
+{
+ Font_FontAspect getFontAspect(const QFont& font)
+ {
+ if (font.bold() && font.italic())
+ {
+ return Font_FontAspect_BoldItalic;
+ }
+ else if (font.bold())
+ {
+ return Font_FontAspect_Bold;
+ }
+ else if (font.italic())
+ {
+ return Font_FontAspect_Italic;
+ }
+
+ return Font_FontAspect_Regular;
+ }
+
+ void setTextFontByAxis(const Handle(AIS_Trihedron)& trihedron, Prs3d_DatumParts axis, const QFont& font)
+ {
+#if OCC_VERSION_LARGE >= 0x07070000
+ Handle(Prs3d_Drawer) drawer = trihedron->Attributes();
+ if (!drawer->HasOwnDatumAspect())
+ {
+ return;
+ }
+
+ Handle(Prs3d_DatumAspect) daspect = drawer->DatumAspect();
+ daspect->TextAspect(axis)->SetFont(font.family().toStdString().c_str());
+
+ const Font_FontAspect fontAspect = getFontAspect(font);
+ daspect->TextAspect(axis)->Aspect()->SetTextFontAspect(fontAspect);
+#endif // OCC_VERSION_LARGE >= 0x0707000
+ }
+
+ void setTextColorByAxis(const Handle(AIS_Trihedron)& trihedron, Prs3d_DatumParts axis, const QColor& color)
+ {
+#if OCC_VERSION_LARGE >= 0x07070000
+ trihedron->SetTextColor(axis, OCCViewer::color(color));
+#endif // OCC_VERSION_LARGE >= 0x0707000
+ }
+
+ void setTextFontByAxis(const Handle(V3d_Trihedron)& trihedron, V3d_TypeOfAxe axis, const QFont& font)
+ {
+#if OCC_VERSION_LARGE >= 0x07070000
+ const Handle(Prs3d_TextAspect)& labelAspect = trihedron->LabelAspect(axis);
+ labelAspect->SetFont(font.family().toStdString().c_str());
+
+ const Font_FontAspect fontAspect = getFontAspect(font);
+ labelAspect->Aspect()->SetTextFontAspect(fontAspect);
+#endif // OCC_VERSION_LARGE >= 0x0707000
+ }
+
+ void setTextColorByAxis(const Handle(V3d_Trihedron)& trihedron, V3d_TypeOfAxe axis, const QColor& color)
+ {
+#if OCC_VERSION_LARGE >= 0x07070000
+ trihedron->LabelAspect(axis)->SetColor(OCCViewer::color(color));
+#endif // OCC_VERSION_LARGE >= 0x0707000
+ }
+}
+
+
+/*!
+ * Class : OCCViewer_TrihedronSetupAIS
+ * Description : Helper class to setup trihedron settings for AIS_Trihedron (OCCT viewer)
+ */
+
+QFont OCCViewer_TrihedronSetupAIS::getDefaultTextFont() const
+{
+ return QFont(Font_NOF_ASCII_MONO);
+}
+
+void OCCViewer_TrihedronSetupAIS::setTextFontX(const QFont& font)
+{
+ setTextFontByAxis(myTrihedron, Prs3d_DP_XAxis, font);
+}
+
+void OCCViewer_TrihedronSetupAIS::setTextFontY(const QFont& font)
+{
+ setTextFontByAxis(myTrihedron, Prs3d_DP_YAxis, font);
+}
+
+void OCCViewer_TrihedronSetupAIS::setTextFontZ(const QFont& font)
+{
+ setTextFontByAxis(myTrihedron, Prs3d_DP_ZAxis, font);
+}
+
+void OCCViewer_TrihedronSetupAIS::setTextColorX(const QColor& color)
+{
+ setTextColorByAxis(myTrihedron, Prs3d_DP_XAxis, color);
+}
+
+void OCCViewer_TrihedronSetupAIS::setTextColorY(const QColor& color)
+{
+ setTextColorByAxis(myTrihedron, Prs3d_DP_YAxis, color);
+}
+
+void OCCViewer_TrihedronSetupAIS::setTextColorZ(const QColor& color)
+{
+ setTextColorByAxis(myTrihedron, Prs3d_DP_ZAxis, color);
+}
+
+/*!
+ * Class : OCCViewer_TrihedronSetupV3d
+ * Description : Helper class to setup trihedron settings for V3d_Trihedron (OCCT viewer)
+ */
+
+QFont OCCViewer_TrihedronSetupV3d::getDefaultTextFont() const
+{
+ return QFont(Font_NOF_ASCII_MONO);
+}
+
+void OCCViewer_TrihedronSetupV3d::setTextFontX(const QFont& font)
+{
+ setTextFontByAxis(myTrihedron, V3d_TypeOfAxe::V3d_X, font);
+}
+
+void OCCViewer_TrihedronSetupV3d::setTextFontY(const QFont& font)
+{
+ setTextFontByAxis(myTrihedron, V3d_TypeOfAxe::V3d_Y, font);
+}
+
+void OCCViewer_TrihedronSetupV3d::setTextFontZ(const QFont& font)
+{
+ setTextFontByAxis(myTrihedron, V3d_TypeOfAxe::V3d_Z, font);
+}
+
+void OCCViewer_TrihedronSetupV3d::setTextColorX(const QColor& color)
+{
+ setTextColorByAxis(myTrihedron, V3d_TypeOfAxe::V3d_X, color);
+}
+
+void OCCViewer_TrihedronSetupV3d::setTextColorY(const QColor& color)
+{
+ setTextColorByAxis(myTrihedron, V3d_TypeOfAxe::V3d_Y, color);
+}
+
+void OCCViewer_TrihedronSetupV3d::setTextColorZ(const QColor& color)
+{
+ setTextColorByAxis(myTrihedron, V3d_TypeOfAxe::V3d_Z, color);
+}
--- /dev/null
+// Copyright (C) 2007-2023 CEA, EDF, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library 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 for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See https://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef OCCVIEWER_TRIHEDRON_SETUP_H
+#define OCCVIEWER_TRIHEDRON_SETUP_H
+
+#include "OCCViewer.h"
+#include "ViewerTools_TrihedronSetup.h"
+
+class AIS_Trihedron;
+class V3d_Trihedron;
+
+/*!
+ * Class : OCCViewer_TrihedronSetupAIS
+ * Description : Helper class to setup trihedron settings for AIS_Trihedron (OCCT viewer)
+ */
+class OCCVIEWER_EXPORT OCCViewer_TrihedronSetupAIS : public ViewerTools_TrihedronSetupBase
+{
+public:
+ OCCViewer_TrihedronSetupAIS(const Handle(AIS_Trihedron)& trihedron) : myTrihedron(trihedron) {}
+ virtual ~OCCViewer_TrihedronSetupAIS() {}
+
+protected:
+ virtual QFont getDefaultTextFont() const override;
+
+ virtual void setTextFontX(const QFont& font) override;
+ virtual void setTextFontY(const QFont& font) override;
+ virtual void setTextFontZ(const QFont& font) override;
+
+ virtual void setTextColorX(const QColor& color) override;
+ virtual void setTextColorY(const QColor& color) override;
+ virtual void setTextColorZ(const QColor& color) override;
+
+private:
+ const Handle(AIS_Trihedron)& myTrihedron;
+};
+
+/*!
+ * Class : OCCViewer_TrihedronSetupV3d
+ * Description : Helper class to setup trihedron settings for V3d_Trihedron (OCCT viewer)
+ */
+class OCCVIEWER_EXPORT OCCViewer_TrihedronSetupV3d : public ViewerTools_TrihedronSetupBase
+{
+public:
+ OCCViewer_TrihedronSetupV3d(const Handle(V3d_Trihedron)& trihedron) : myTrihedron(trihedron) {}
+ virtual ~OCCViewer_TrihedronSetupV3d() {}
+
+protected:
+ virtual QFont getDefaultTextFont() const override;
+
+ virtual void setTextFontX(const QFont& font) override;
+ virtual void setTextFontY(const QFont& font) override;
+ virtual void setTextFontZ(const QFont& font) override;
+
+ virtual void setTextColorX(const QColor& color) override;
+ virtual void setTextColorY(const QColor& color) override;
+ virtual void setTextColorZ(const QColor& color) override;
+
+private:
+ const Handle(V3d_Trihedron)& myTrihedron;
+};
+
+#endif
\ No newline at end of file
#include "OCCViewer_ViewPort3d.h"
#include "OCCViewer_ClippingDlg.h"
#include "OCCViewer_Utilities.h"
+#include "OCCViewer_TrihedronSetup.h"
#include "SUIT_ViewWindow.h"
#include "SUIT_ViewManager.h"
myColorScale->SetTransformPersistence( new Graphic3d_TransformPers (Graphic3d_TMF_2d, Aspect_TOTP_LEFT_LOWER) );
#endif
- /* create trihedron */
- if ( DisplayTrihedron )
+ if (DisplayTrihedron)
{
- Handle(Geom_Axis2Placement) anAxis = new Geom_Axis2Placement(gp::XOY());
- myTrihedron = new AIS_Trihedron(anAxis);
- myTrihedron->SetInfiniteState( Standard_True );
-
- Quantity_Color Col(193/255., 205/255., 193/255., Quantity_TOC_RGB);
- //myTrihedron->SetColor( Col );
- myTrihedron->SetArrowColor( Col.Name() );
- myTrihedron->SetSize(100);
- Handle(Prs3d_Drawer) drawer = myTrihedron->Attributes();
- if (drawer->HasOwnDatumAspect()) {
- Handle(Prs3d_DatumAspect) daspect = drawer->DatumAspect();
- daspect->LineAspect(Prs3d_DP_XAxis)->SetColor(Quantity_Color(1.0, 0.0, 0.0, Quantity_TOC_RGB));
- daspect->LineAspect(Prs3d_DP_YAxis)->SetColor(Quantity_Color(0.0, 1.0, 0.0, Quantity_TOC_RGB));
- daspect->LineAspect(Prs3d_DP_ZAxis)->SetColor(Quantity_Color(0.0, 0.0, 1.0, Quantity_TOC_RGB));
- }
+ initTrihedron();
}
/* create view cube */
}
}
+/*!
+ Inits trihedron if it's enabled
+*/
+void OCCViewer_Viewer::initTrihedron()
+{
+ // Basic params
+ Handle(Geom_Axis2Placement) anAxis = new Geom_Axis2Placement(gp::XOY());
+ myTrihedron = new AIS_Trihedron(anAxis);
+ myTrihedron->SetInfiniteState(Standard_True);
+ myTrihedron->SetSize(100);
+
+ // Init default colors
+ const Quantity_Color rColor(1.0, 0.0, 0.0, Quantity_TOC_RGB);
+ const Quantity_Color gColor(0.0, 1.0, 0.0, Quantity_TOC_RGB);
+ const Quantity_Color bColor(0.0, 0.0, 1.0, Quantity_TOC_RGB);
+
+#if OCC_VERSION_LARGE >= 0x07070000
+ // Set colors for axes
+ myTrihedron->SetDatumPartColor(Prs3d_DP_XAxis, rColor);
+ myTrihedron->SetDatumPartColor(Prs3d_DP_YAxis, gColor);
+ myTrihedron->SetDatumPartColor(Prs3d_DP_ZAxis, bColor);
+
+ // Set the same colors for axes' arrows
+ myTrihedron->SetArrowColor(Prs3d_DP_XAxis, rColor);
+ myTrihedron->SetArrowColor(Prs3d_DP_YAxis, gColor);
+ myTrihedron->SetArrowColor(Prs3d_DP_ZAxis, bColor);
+#else
+ Quantity_Color Col(193/255., 205/255., 193/255., Quantity_TOC_RGB);
+ myTrihedron->SetArrowColor( Col.Name() );
+ Handle(Prs3d_Drawer) drawer = myTrihedron->Attributes();
+ if (drawer->HasOwnDatumAspect())
+ {
+ Handle(Prs3d_DatumAspect) daspect = drawer->DatumAspect();
+
+ daspect->LineAspect(Prs3d_DP_XAxis)->SetColor(rColor);
+ daspect->LineAspect(Prs3d_DP_YAxis)->SetColor(gColor);
+ daspect->LineAspect(Prs3d_DP_ZAxis)->SetColor(bColor);
+ }
+#endif
+
+ setTrihedronTextFont();
+ setTrihedronTextColor();
+}
+
+/*!
+ Sets font for trihedron labels from the 3D Viewer settings
+*/
+void OCCViewer_Viewer::setTrihedronTextFont()
+{
+ OCCViewer_TrihedronSetupAIS trihedronSetup(myTrihedron);
+ trihedronSetup.setTextFont();
+}
+
+/*!
+ Sets color for trihedron labels from the 3D Viewer settings
+*/
+void OCCViewer_Viewer::setTrihedronTextColor()
+{
+ OCCViewer_TrihedronSetupAIS trihedronSetup(myTrihedron);
+ trihedronSetup.setTextColor();
+}
+
/*!
\return true if trihedron is visible
*/
if ( aView ) aView->showStaticTrihedron( on );
}
+/*!
+ Set the font for axes labels of static trihedron
+*/
+void OCCViewer_Viewer::setStaticTrihedronTextFont()
+{
+ OCCViewer_ViewPort3d* viewport = getViewPort();
+ if (!viewport)
+ return;
+
+ viewport->setStaticTrihedronTextFont();
+}
+
+
+/*!
+ Set the color for axes labels of static trihedron
+*/
+void OCCViewer_Viewer::setStaticTrihedronTextColor()
+{
+ OCCViewer_ViewPort3d* viewport = getViewPort();
+ if (!viewport)
+ return;
+
+ viewport->setStaticTrihedronTextColor();
+}
+
+/*!
+ Get the viewport for active view
+*/
+OCCViewer_ViewPort3d* OCCViewer_Viewer::getViewPort()
+{
+ OCCViewer_ViewWindow* aView = (OCCViewer_ViewWindow*)(myViewManager->getActiveView());
+ if (!aView)
+ return nullptr;
+
+ return aView->getViewPort();
+}
+
/*!
Get new and current trihedron size corresponding to the current model size
*/
bool isColorScaleVisible() const;
virtual void setColorScaleShown( const bool );
+ void initTrihedron();
+ void setTrihedronTextFont();
+ void setTrihedronTextColor();
+
//! returns true if 3d Trihedron in viewer was created
bool trihedronActivated() const { return !myTrihedron.IsNull(); }
int getSelectionCount() const { return (!myAISContext.IsNull())? myAISContext->NbSelected():0; }
void setStaticTrihedronDisplayed(const bool on);
+ void setStaticTrihedronTextFont();
+ void setStaticTrihedronTextColor();
+
+ OCCViewer_ViewPort3d* getViewPort();
/* Clip planes management */
Handle(Graphic3d_ClipPlane) createClipPlane(const gp_Pln& thePlane, const Standard_Boolean theIsOn);
#include "OCCViewer_VService.h"
#include "OCCViewer_ViewWindow.h"
#include "OCCViewer_ViewModel.h"
+#include "OCCViewer_TrihedronSetup.h"
#include <SUIT_ViewManager.h>
#include <SUIT_ViewModel.h>
if ( on ) {
aView->ZBufferTriedronSetup();
aView->TriedronDisplay( Aspect_TOTP_LEFT_LOWER, Quantity_NOC_WHITE, 0.05, V3d_ZBUFFER );
+
+ setStaticTrihedronTextFont();
+ setStaticTrihedronTextColor();
} else {
aView->TriedronErase();
}
aView->Update();
}
+/*!
+ Set the font for axes labels of static trihedron
+*/
+void OCCViewer_ViewPort3d::setStaticTrihedronTextFont()
+{
+ Handle(V3d_View) aView = activeView();
+ if (!aView)
+ return;
+
+#if OCC_VERSION_LARGE >= 0x07070000
+ OCCViewer_TrihedronSetupV3d trihedronSetup(aView->Trihedron());
+ trihedronSetup.setTextFont();
+#endif // OCC_VERSION_LARGE >= 0x0707000
+}
+
+/*!
+ Set the color for axes labels of static trihedron
+*/
+void OCCViewer_ViewPort3d::setStaticTrihedronTextColor()
+{
+ Handle(V3d_View) aView = activeView();
+ if (!aView)
+ return;
+
+#if OCC_VERSION_LARGE >= 0x07070000
+ OCCViewer_TrihedronSetupV3d trihedronSetup(aView->Trihedron());
+ trihedronSetup.setTextColor();
+#endif // OCC_VERSION_LARGE >= 0x0707000
+}
+
/*
* Create default cursor with a specific shape
*/
bool isAdvancedZoomingEnabled() const { return myIsAdvancedZoomingEnabled; }
void showStaticTrihedron( bool );
+ void setStaticTrihedronTextFont();
+ void setStaticTrihedronTextColor();
void setDefaultCursor( Qt::CursorShape theCursorShape );
QCursor* getDefaultCursor() const;
SVTK_SelectionEvent.h
SVTK_Selector.h
SVTK_SpaceMouse.h
+ SVTK_TrihedronSetup.h
SVTK_Utils.h
SVTK_Hash.h
)
SVTK_SetRotationPointDlg.cxx
SVTK_SpaceMouse.cxx
SVTK_Trihedron.cxx
+ SVTK_TrihedronSetup.cxx
SVTK_UpdateRateDlg.cxx
SVTK_Utils.cxx
SVTK_View.cxx
--- /dev/null
+// Copyright (C) 2007-2023 CEA, EDF, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library 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 for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See https://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "SVTK_TrihedronSetup.h"
+
+#include "VTKViewer_Trihedron.h"
+
+#include "salomevtkPVAxesWidget.h"
+#include "salomevtkPVAxesActor.h"
+
+#include "vtkProperty.h"
+
+#include <QFont>
+#include <QColor>
+
+// Common helper functions to separate algorithm from implementation
+// and reduce code repetition.
+namespace
+{
+ void setTextColorByAxis(VTKViewer_Trihedron* trihedron, VTKViewer_Trihedron::Axis axis, const QColor& color)
+ {
+ trihedron->SetTextColor(axis, color.red(), color.green(), color.blue());
+ }
+
+ void setTextColorByAxis(vtkProperty* property, const QColor& color)
+ {
+ property->SetColor(color.redF(), color.greenF(), color.blueF());
+ }
+}
+
+/*!
+ * Class : SVTK_TrihedronSetupVTK
+ * Description : Helper class to setup trihedron settings for VTKViewer_Trihedron (Vtk viewer)
+ */
+
+QFont SVTK_TrihedronSetupVTK::getDefaultTextFont() const
+{
+ // TODO: implement this method
+ return {};
+}
+
+void SVTK_TrihedronSetupVTK::setTextFontX(const QFont& font)
+{
+ // TODO: find an easy method to change font for vtkVectorText (VTKViewer_Axis::myVectorText).
+ // Vtk defines only VTK_ARIAL, VTK_COURIER, VTK_TIMES and VTK_FONT_FILE ids to use with vtkTextProperty.
+ // Maybe vtkFreeTypeTools class could give some hints.
+ (void)font; // disable unused param warning
+}
+
+void SVTK_TrihedronSetupVTK::setTextFontY(const QFont& font)
+{
+ // TODO: implement this method
+ (void)font; // disable unused param warning
+}
+
+void SVTK_TrihedronSetupVTK::setTextFontZ(const QFont& font)
+{
+ // TODO: implement this method
+ (void)font; // disable unused param warning
+}
+
+void SVTK_TrihedronSetupVTK::setTextColorX(const QColor& color)
+{
+ setTextColorByAxis(myTrihedron, VTKViewer_Trihedron::Axis::X, color);
+}
+
+void SVTK_TrihedronSetupVTK::setTextColorY(const QColor& color)
+{
+ setTextColorByAxis(myTrihedron, VTKViewer_Trihedron::Axis::Y, color);
+}
+
+void SVTK_TrihedronSetupVTK::setTextColorZ(const QColor& color)
+{
+ setTextColorByAxis(myTrihedron, VTKViewer_Trihedron::Axis::Z, color);
+}
+
+
+/*!
+ * Class : SVTK_TrihedronSetupPVAxes
+ * Description : Helper class to setup static trihedron settings for salomevtk::vtkPVAxesActor (Vtk viewer)
+ */
+
+QFont SVTK_TrihedronSetupPVAxes::getDefaultTextFont() const
+{
+ // TODO: implement this method
+ return {};
+}
+
+void SVTK_TrihedronSetupPVAxes::setTextFontX(const QFont& font)
+{
+ // TODO: find an easy method to change font for vtkVectorText (VTKViewer_Axis::myVectorText).
+ // Vtk defines only VTK_ARIAL, VTK_COURIER, VTK_TIMES and VTK_FONT_FILE ids to use with vtkTextProperty.
+ // Maybe vtkFreeTypeTools class could give some hints.
+ (void)font; // disable unused param warning
+}
+
+void SVTK_TrihedronSetupPVAxes::setTextFontY(const QFont& font)
+{
+ // TODO: implement this method
+ (void)font; // disable unused param warning
+}
+
+void SVTK_TrihedronSetupPVAxes::setTextFontZ(const QFont& font)
+{
+ // TODO: implement this method
+ (void)font; // disable unused param warning
+}
+
+void SVTK_TrihedronSetupPVAxes::setTextColorX(const QColor& color)
+{
+ setTextColorByAxis(myTrihedron->GetAxesActor()->GetXAxisLabelProperty(), color);
+}
+
+void SVTK_TrihedronSetupPVAxes::setTextColorY(const QColor& color)
+{
+ setTextColorByAxis(myTrihedron->GetAxesActor()->GetYAxisLabelProperty(), color);
+}
+
+void SVTK_TrihedronSetupPVAxes::setTextColorZ(const QColor& color)
+{
+ setTextColorByAxis(myTrihedron->GetAxesActor()->GetZAxisLabelProperty(), color);
+}
\ No newline at end of file
--- /dev/null
+// Copyright (C) 2007-2023 CEA, EDF, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library 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 for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See https://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef SVTK_TRIHEDRON_SETUP_H
+#define SVTK_TRIHEDRON_SETUP_H
+
+#include "SVTK.h"
+#include "ViewerTools_TrihedronSetup.h"
+
+class VTKViewer_Trihedron;
+
+namespace salomevtk
+{
+ class vtkPVAxesWidget;
+}
+
+/*!
+ * Class : SVTK_TrihedronSetupVTK
+ * Description : Helper class to setup trihedron settings for VTKViewer_Trihedron (Vtk viewer)
+ */
+class SVTK_EXPORT SVTK_TrihedronSetupVTK : public ViewerTools_TrihedronSetupBase
+{
+public:
+ SVTK_TrihedronSetupVTK(VTKViewer_Trihedron* trihedron) : myTrihedron(trihedron) {}
+ virtual ~SVTK_TrihedronSetupVTK() {}
+
+protected:
+ virtual QFont getDefaultTextFont() const override;
+
+ virtual void setTextFontX(const QFont& font) override;
+ virtual void setTextFontY(const QFont& font) override;
+ virtual void setTextFontZ(const QFont& font) override;
+
+ virtual void setTextColorX(const QColor& color) override;
+ virtual void setTextColorY(const QColor& color) override;
+ virtual void setTextColorZ(const QColor& color) override;
+
+private:
+ VTKViewer_Trihedron* myTrihedron = nullptr;
+};
+
+/*!
+ * Class : SVTK_TrihedronSetupPVAxes
+ * Description : Helper class to setup static trihedron settings for salomevtk::vtkPVAxesWidget (Vtk viewer)
+ */
+class SVTK_EXPORT SVTK_TrihedronSetupPVAxes : public ViewerTools_TrihedronSetupBase
+{
+public:
+ SVTK_TrihedronSetupPVAxes(salomevtk::vtkPVAxesWidget* trihedron) : myTrihedron(trihedron) {}
+ virtual ~SVTK_TrihedronSetupPVAxes() {}
+
+protected:
+ virtual QFont getDefaultTextFont() const override;
+
+ virtual void setTextFontX(const QFont& font) override;
+ virtual void setTextFontY(const QFont& font) override;
+ virtual void setTextFontZ(const QFont& font) override;
+
+ virtual void setTextColorX(const QColor& color) override;
+ virtual void setTextColorY(const QColor& color) override;
+ virtual void setTextColorZ(const QColor& color) override;
+
+private:
+ salomevtk::vtkPVAxesWidget* myTrihedron = nullptr;
+};
+
+#endif
\ No newline at end of file
#include "SVTK_Renderer.h"
//#include "SVTK_MainWindow.h"
#include "SVTK_Prs.h"
+#include "SVTK_TrihedronSetup.h"
#include "VTKViewer_Algorithm.h"
#include "VTKViewer_ViewModel.h"
+#include "VTKViewer_Trihedron.h"
#include "SUIT_ViewModel.h"
#include "SUIT_ViewManager.h"
}
}
+/*!
+ Set color of trihedron's text of the viewer
+*/
+void SVTK_Viewer::setTrihedronTextColor()
+{
+ const SUIT_ViewManager* aViewManager = getViewManager();
+ if (!aViewManager)
+ {
+ return;
+ }
+
+ const QVector<SUIT_ViewWindow*> aViews = aViewManager->getViews();
+ for (int i = 0; i < aViews.count(); i++)
+ {
+ if (TViewWindow* aView = dynamic_cast<TViewWindow*>(aViews.at(i)))
+ {
+ VTKViewer_Trihedron* trihedron = aView->GetRenderer()->GetTrihedron();
+ SVTK_TrihedronSetupVTK trihedronSetup(trihedron);
+ trihedronSetup.setTextColor();
+ }
+ }
+}
+
/*!
\return visibility status of the static trihedron
*/
}
}
+/*!
+ Sets static trihedron's text color
+*/
+void SVTK_Viewer::setStaticTrihedronTextColor()
+{
+ const SUIT_ViewManager* aViewManager = getViewManager();
+ if (!aViewManager)
+ return;
+
+ QVector<SUIT_ViewWindow*> aViews = aViewManager->getViews();
+ for (int i = 0; i < aViews.count(); i++)
+ {
+ if (TViewWindow* aView = dynamic_cast<TViewWindow*>(aViews.at(i)))
+ {
+ aView->setStaticTrihedronTextColor();
+ }
+ }
+}
+
/*!
\return projection mode
*/
if ( SVTK_ViewWindow* svw = dynamic_cast<SVTK_ViewWindow*>( view ) )
QTimer::singleShot(500, [svw] () { svw->Repaint(); } );
#endif
+
+ setTrihedronTextColor();
+ setStaticTrihedronTextColor();
}
//! Set size of trihedron of the viewer (see #SVTK_Renderer::SetTrihedronSize)
void setTrihedronSize( const double, const bool = true );
+ //! Set color of trihedron's text of the viewer
+ void setTrihedronTextColor();
+
//! Get visibility status of the static trihedron
bool isStaticTrihedronVisible() const;
//! Set visibility status of the static trihedron
void setStaticTrihedronVisible( const bool );
+ //! Sets static trihedron's text color
+ void setStaticTrihedronTextColor();
+
//! Gets projection mode
int projectionMode() const;
#include "SVTK_Selector.h"
#include "SVTK_Recorder.h"
#include "SVTK_RecorderDlg.h"
+#include "SVTK_TrihedronSetup.h"
#include "salomevtkPVAxesWidget.h"
#include "salomevtkPVAxesActor.h"
myAxesWidget->SetEnabled( (int)theIsVisible );
}
+/*!
+ Sets static trihedron's text color
+*/
+void SVTK_ViewWindow::setStaticTrihedronTextColor()
+{
+ SVTK_TrihedronSetupPVAxes trihedronSetup(myAxesWidget);
+ trihedronSetup.setTextColor();
+}
+
/*!
Performs action
\param accelAction - action
//! Set visibility status of the static trihedron
virtual void SetStaticTrihedronVisible( const bool );
+ //! Sets static trihedron's text color
+ virtual void setStaticTrihedronTextColor();
+
//! Methods to save/restore visual parameters of a view (pan, zoom, etc.)
virtual QString getVisualParameters();
#endif
}
+/*! Sets color for myLabelActor
+ */
+void VTKViewer_Axis::SetTextColor(double theRed, double theGreen, double theBlue)
+{
+#ifdef IPAL21440
+ vtkTextProperty* aProperty = vtkTextProperty::New();
+ aProperty->SetColor(theRed, theGreen, theBlue);
+
+ myLabelActor->SetTextProperty(aProperty);
+#else
+ vtkProperty* aProperty = vtkProperty::New();
+ aProperty->SetColor(theRed, theGreen, theBlue);
+
+ myLabelActor->SetProperty(aProperty);
+#endif
+
+aProperty->Delete();
+}
+
/*! Set size of VTKViewer_Axis
*/
void VTKViewer_Axis::SetSize(double theSize)
}
return false;
}
+
+/*! Sets a color to a text for the given axis
+ * \param axis - axis to change a text color
+ * \param theRed - red color component
+ * \param theGreen - green color component
+ * \param theBlue - blue color component
+ */
+void VTKViewer_Trihedron::SetTextColor(Axis axis, double theRed, double theGreen, double theBlue)
+{
+ myAxis[axis]->SetTextColor(theRed, theGreen, theBlue);
+}
/*!This class provide support trihedron object in vtk viewer.*/
class VTKVIEWER_EXPORT VTKViewer_Trihedron : public vtkObject
{
+public:
+ enum Axis { X = 0, Y, Z };
+
protected:
/*!Initialize fields by default values.*/
VTKViewer_Trihedron();
*/
virtual bool OwnActor(const vtkActor* theActor);
+ /*! Sets a color to a text for the given axis
+ * \param axis - axis to change a text color
+ * \param theRed - red color component
+ * \param theGreen - green color component
+ * \param theBlue - blue color component
+ */
+ virtual void SetTextColor(Axis axis, double theRed, double theGreen, double theBlue);
+
protected:
/*! Actor collection*/
vtkActorCollection* myPresent;
* \param theBlue - blue component of the color
*/
virtual void SetColor(double theRed, double theGreen, double theBlue);
+
+ /*! Sets color for myLabelActor
+ * \param theRed - red component of the color
+ * \param theGreen - green component of the color
+ * \param theBlue - blue component of the color
+ */
+ virtual void SetTextColor(double theRed, double theGreen, double theBlue);
/*! Set size of VTKViewer_Axis
*/
INCLUDE_DIRECTORIES(
${QT_INCLUDES}
${PROJECT_SOURCE_DIR}/src/Qtx
+ ${PROJECT_SOURCE_DIR}/src/SUIT
)
# additional preprocessor / compiler flags
ADD_DEFINITIONS(${QT_DEFINITIONS})
# libraries to link to
-SET(_link_LIBRARIES ${QT_LIBRARIES} qtx)
+SET(_link_LIBRARIES ${QT_LIBRARIES} qtx suit)
# --- headers ---
)
# header files / no moc processing
-SET(_other_HEADERS ViewerTools.h)
+SET(_other_HEADERS
+ ViewerTools.h
+ ViewerTools_TrihedronSetup.h
+)
# header files / to install
SET(ViewerTools_HEADERS ${_moc_HEADERS} ${_other_HEADERS})
ViewerTools_CubeAxesDlgBase.cxx
ViewerTools_DialogBase.cxx
ViewerTools_FontWidgetBase.cxx
+ ViewerTools_TrihedronSetup.cxx
)
# sources / to compile
--- /dev/null
+// Copyright (C) 2007-2023 CEA, EDF, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library 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 for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See https://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "ViewerTools_TrihedronSetup.h"
+
+#include "SUIT_ResourceMgr.h"
+#include "SUIT_Session.h"
+
+#include <QFont>
+#include <QColor>
+
+namespace
+{
+ // Settings names to use with resource manager
+ const char* THE_3DSECTION_TITLE = "3DViewer";
+};
+
+/*!
+ * Class : ViewerTools_TrihedronSetupBase
+ * Description : Helper class to setup trihedron settings for different viewers
+ */
+
+bool ViewerTools_TrihedronSetupBase::isCustomTextFontOn() const
+{
+ return SUIT_Session::session()->resourceMgr()->booleanValue(
+ THE_3DSECTION_TITLE, "trihedron_text_font_custom", false);
+}
+
+bool ViewerTools_TrihedronSetupBase::isCustomTextColorOn() const
+{
+ return SUIT_Session::session()->resourceMgr()->booleanValue(
+ THE_3DSECTION_TITLE, "trihedron_text_color_custom", false);
+}
+
+void ViewerTools_TrihedronSetupBase::setTextFont()
+{
+ if (isCustomTextFontOn())
+ {
+ const SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
+
+ // Set the fonts from application settings
+ setTextFontX(resMgr->fontValue(THE_3DSECTION_TITLE, "trihedron_x_text_font"));
+ setTextFontY(resMgr->fontValue(THE_3DSECTION_TITLE, "trihedron_y_text_font"));
+ setTextFontZ(resMgr->fontValue(THE_3DSECTION_TITLE, "trihedron_z_text_font"));
+ }
+ else
+ {
+ // Set the font defined for trihedron by default
+ setTextFontX(getDefaultTextFont());
+ setTextFontY(getDefaultTextFont());
+ setTextFontZ(getDefaultTextFont());
+ }
+}
+
+void ViewerTools_TrihedronSetupBase::setTextColor()
+{
+ if (isCustomTextColorOn())
+ {
+ const SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
+
+ // Set the colors from application settings
+ setTextColorX(resMgr->colorValue(THE_3DSECTION_TITLE, "trihedron_x_text_color"));
+ setTextColorY(resMgr->colorValue(THE_3DSECTION_TITLE, "trihedron_y_text_color"));
+ setTextColorZ(resMgr->colorValue(THE_3DSECTION_TITLE, "trihedron_z_text_color"));
+ }
+ else
+ {
+ // Set the colors defined for trihedron by default
+ static const QColor colorX = QColor(255, 0.0, 0.0);
+ static const QColor colorY = QColor(0.0, 255, 0.0);
+ static const QColor colorZ = QColor(0.0, 0.0, 255);
+
+ setTextColorX(colorX);
+ setTextColorY(colorY);
+ setTextColorZ(colorZ);
+ }
+}
--- /dev/null
+// Copyright (C) 2007-2023 CEA, EDF, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library 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 for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See https://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef VIEWERTOOLS_TRIHEDRON_SETUP_H
+#define VIEWERTOOLS_TRIHEDRON_SETUP_H
+
+#include "ViewerTools.h"
+
+class QFont;
+class QColor;
+
+/*!
+ * Class : ViewerTools_TrihedronSetupBase
+ * Description : Helper class to setup trihedron settings for different viewers
+ */
+class VIEWERTOOLS_EXPORT ViewerTools_TrihedronSetupBase
+{
+public:
+ virtual ~ViewerTools_TrihedronSetupBase() {}
+
+ bool isCustomTextFontOn() const;
+ bool isCustomTextColorOn() const;
+
+ virtual void setTextFont();
+ virtual void setTextColor();
+
+protected:
+ // Pure virtual methods should be implemented for each trihedron class
+ virtual QFont getDefaultTextFont() const = 0;
+
+ virtual void setTextFontX(const QFont& font) = 0;
+ virtual void setTextFontY(const QFont& font) = 0;
+ virtual void setTextFontZ(const QFont& font) = 0;
+
+ virtual void setTextColorX(const QColor& color) = 0;
+ virtual void setTextColorY(const QColor& color) = 0;
+ virtual void setTextColorZ(const QColor& color) = 0;
+};
+
+#endif
\ No newline at end of file