the other view.
<hr>
+\image html occ_view_ray_tracing.png
+\anchor ray_tracing
+
+<b>Ray tracing</b> - allows to switch between rendering methods in run-time
+in the current OCCT 3D view. It can be used to produce images with photorealistic quality.
+
+\image html doc_ray_tracing.png
+
+- <b>Ray tracing</b> - specifies rendering mode: OpenGL rasterization (by default) or GPU ray-tracing.
+
+ - <b>Depth</b> - defines maximum ray-tracing depth.
+
+ - <b>Specular reflections</b> - enables/disables specular reflections.
+
+ - <b>Adaptive anti-aliasing</b> - enables/disables adaptive anti-aliasing.
+
+ - <b>Shadows rendering</b> - enables/disables shadows rendering.
+
+ - <b>Transparent shadow</b> - enables/disables light propagation through transparent media.
+
+<hr>
+
+\image html occ_view_env_texture.png
+
+\anchor env_texture
+
+<b>Environment texture</b> - allows to set parameters for environment texture.
+This is a special mode of texture mapping when specular reflection of environment texture
+is simulated by OpenGL using a special texture coordinates generation algorithm (a sphere map).
+
+\image html doc_env_texture.png
+
+- <b>Environment texture</b> - enables/disables environment texture in the current OCCT 3D view.
+
+User can select one of 7 predefined environment texture from the list or define its texture from file by
+choosing item <b>"Custom..."</b> in a combo box.
+
+\note Note that the environment texture file should normally satisfy the following requirements
+in order to produce good visual result:
+- The image file should have 2:1 width-to-height ratio.
+- It should constitute a 360-degrees panoramic image created using a fish-eye lens.
+
+<hr>
+
+\image html occ_view_light_source.png
+
+\anchor light_source
+
+<b>Light source</b> - allows to set parameters for light source.
+
+It's possible to choose a type of light source between directional and positional light.
+
+\image html doc_dir_light_source.png
+
+<b>Directional</b> light - creates a directional light source in the viewer.
+It is defined by direction coordinates, color and headlight parameter.
+
+\image html doc_pos_light_source.png
+
+<b>Positional</b> light - creates an isolated light source X,Y,Z in the viewer.
+It is also defined by the color and headlight parameter.
+
+Click:
+
+- <b>Apply and Close</b> to apply defined light source to the OCC 3D Viewer.
+
+- <b>Default</b> to restore default values of light source.
+
+- <b>Close</b> to return parameters of light source on initial values.
+
+<hr>
*/
pref->setItemProperty( "step", 0.1, scaleFactor );
// ... "Clipping" group <<end>>
+ // ... "Ray tracing" group <<start>>
+ int occRayTracingGroup = pref->addPreference( tr( "PREF_GROUP_RAY_TRACING" ), occGroup );
+ int rtPref = pref->addPreference( "", occRayTracingGroup, LightApp_Preferences::Frame );
+ pref->setItemProperty( "columns", 2, rtPref );
+ // .... -> depth
+ int rt_depth = pref->addPreference( tr( "PREF_RAY_TRACING_DEPTH" ), rtPref,
+ LightApp_Preferences::IntSpin, "OCCViewer", "rt_depth" );
+ pref->setItemProperty( "min", 1, rt_depth );
+ pref->setItemProperty( "max", 10, rt_depth );
+ pref->setItemProperty( "step", 1, rt_depth );
+ pref->addPreference( "", rtPref, LightApp_Preferences::Frame );
+ // .... -> specular reflections
+ pref->addPreference( tr( "PREF_RAY_TRACING_REFLECTION" ), rtPref,
+ LightApp_Preferences::Bool, "OCCViewer", "rt_reflection" );
+ // .... -> adaptive anti-aliasing
+ pref->addPreference( tr( "PREF_RAY_TRACING_ANTIALIASING" ), rtPref,
+ LightApp_Preferences::Bool, "OCCViewer", "rt_antialiasing" );
+ // .... -> shadows rendering
+ pref->addPreference( tr( "PREF_RAY_TRACING_SHADOW" ), rtPref,
+ LightApp_Preferences::Bool, "OCCViewer", "rt_shadow" );
+ // .... -> transparent shadow
+ pref->addPreference( tr( "PREF_RAY_TRACING_TRANS_SHADOW" ), rtPref,
+ LightApp_Preferences::Bool, "OCCViewer", "rt_trans_shadow" );
+ // ... "Ray tracing" group <<end>>
+
+ // ... "Light source" group <<start>>
+ int occLightGroup = pref->addPreference( tr( "PREF_GROUP_LIGHT" ), occGroup );
+ // .... -> light color
+ pref->addPreference( tr( "PREF_LIGHT_COLOR" ), occLightGroup,
+ LightApp_Preferences::Color, "OCCViewer", "light_color" );
+ int directionPref = pref->addPreference( "", occLightGroup, LightApp_Preferences::Frame );
+ pref->setItemProperty( "columns", 3, directionPref );
+ // .... -> light direction (dx component)
+ int light_dx = pref->addPreference( tr( "Dx" ), directionPref,
+ LightApp_Preferences::DblSpin, "OCCViewer", "light_dx" );
+ pref->setItemProperty( "precision", 2, light_dx );
+ pref->setItemProperty( "min", -1.0E03, light_dx );
+ pref->setItemProperty( "max", 1.0E03, light_dx );
+ pref->setItemProperty( "step", 0.1, light_dx );
+ // .... -> light direction (dy component)
+ int light_dy = pref->addPreference( tr( "Dy" ), directionPref,
+ LightApp_Preferences::DblSpin, "OCCViewer", "light_dy" );
+ pref->setItemProperty( "precision", 2, light_dy );
+ pref->setItemProperty( "min", -1.0E03, light_dy );
+ pref->setItemProperty( "max", 1.0E03, light_dy );
+ pref->setItemProperty( "step", 0.1, light_dy );
+ // .... -> light direction (dz component)
+ int light_dz = pref->addPreference( tr( "Dz" ), directionPref,
+ LightApp_Preferences::DblSpin, "OCCViewer", "light_dz" );
+ pref->setItemProperty( "precision", 2, light_dz );
+ pref->setItemProperty( "min", -1.0E03, light_dz );
+ pref->setItemProperty( "max", 1.0E03, light_dz );
+ pref->setItemProperty( "step", 0.1, light_dz );
+ // ... "Light source" group <<end>>
+
// ... -> empty frame (for layout) <<start>>
int occGen = pref->addPreference( "", occGroup, LightApp_Preferences::Frame );
pref->setItemProperty( "margin", 0, occGen );
<parameter name="clipping_use_default_texture" value="true"/>
<parameter name="clipping_modulate" value="true"/>
<parameter name="clipping_scale" value="1.0"/>
+ <parameter name="rt_depth" value="3"/>
+ <parameter name="rt_reflection" value="true"/>
+ <parameter name="rt_antialiasing" value="false"/>
+ <parameter name="rt_shadow" value="true"/>
+ <parameter name="rt_trans_shadow" value="false"/>
+ <parameter name="light_color" value="255, 255, 255"/>
+ <parameter name="light_dx" value="0.0"/>
+ <parameter name="light_dy" value="0.0"/>
+ <parameter name="light_dz" value="-1.0"/>
<parameter name="background" value="bt=2;fn=;tm=0;ts=false;c1=#cddbff;c2=#698fff;gt=1;gr=" />
<parameter name="xz_background" value="bt=2;fn=;tm=0;ts=false;c1=#cddbff;c2=#698fff;gt=1;gr=" />
<parameter name="yz_background" value="bt=2;fn=;tm=0;ts=false;c1=#cddbff;c2=#698fff;gt=1;gr=" />
<source>PREF_CLIPPING_SCALE</source>
<translation>Scale factor</translation>
</message>
+ <message>
+ <source>PREF_GROUP_RAY_TRACING</source>
+ <translation>Ray tracing</translation>
+ </message>
+ <message>
+ <source>PREF_RAY_TRACING_DEPTH</source>
+ <translation>Depth</translation>
+ </message>
+ <message>
+ <source>PREF_RAY_TRACING_REFLECTION</source>
+ <translation>Specular reflections</translation>
+ </message>
+ <message>
+ <source>PREF_RAY_TRACING_ANTIALIASING</source>
+ <translation>Adaptive anti-aliasing</translation>
+ </message>
+ <message>
+ <source>PREF_RAY_TRACING_SHADOW</source>
+ <translation>Shadows rendering</translation>
+ </message>
+ <message>
+ <source>PREF_RAY_TRACING_TRANS_SHADOW</source>
+ <translation>Transparent shadow</translation>
+ </message>
+ <message>
+ <source>PREF_GROUP_LIGHT</source>
+ <translation>Light source</translation>
+ </message>
+ <message>
+ <source>PREF_LIGHT_COLOR</source>
+ <translation>Color</translation>
+ </message>
<message>
<source>TOT_CLOSE</source>
<translation>Close</translation>
<source>PREF_CLIPPING_SCALE</source>
<translation>Facteur d'échelle</translation>
</message>
+ <message>
+ <source>PREF_GROUP_RAY_TRACING</source>
+ <translation type="unfinished">Ray tracing</translation>
+ </message>
+ <message>
+ <source>PREF_RAY_TRACING_DEPTH</source>
+ <translation type="unfinished">Depth</translation>
+ </message>
+ <message>
+ <source>PREF_RAY_TRACING_REFLECTION</source>
+ <translation type="unfinished">Specular reflections</translation>
+ </message>
+ <message>
+ <source>PREF_RAY_TRACING_ANTIALIASING</source>
+ <translation type="unfinished">Adaptive anti-aliasing</translation>
+ </message>
+ <message>
+ <source>PREF_RAY_TRACING_SHADOW</source>
+ <translation type="unfinished">Shadows rendering</translation>
+ </message>
+ <message>
+ <source>PREF_RAY_TRACING_TRANS_SHADOW</source>
+ <translation type="unfinished">Transparent shadow</translation>
+ </message>
+ <message>
+ <source>PREF_GROUP_LIGHT</source>
+ <translation type="unfinished">Light source</translation>
+ </message>
+ <message>
+ <source>PREF_LIGHT_COLOR</source>
+ <translation type="unfinished">Color</translation>
+ </message>
<message>
<source>TOT_CLOSE</source>
<translation>Fermer</translation>
<source>PREF_CLIPPING_SCALE</source>
<translation>スケールファクタ</translation>
</message>
+ <message>
+ <source>PREF_GROUP_RAY_TRACING</source>
+ <translation type="unfinished">Ray tracing</translation>
+ </message>
+ <message>
+ <source>PREF_RAY_TRACING_DEPTH</source>
+ <translation type="unfinished">Depth</translation>
+ </message>
+ <message>
+ <source>PREF_RAY_TRACING_REFLECTION</source>
+ <translation type="unfinished">Specular reflections</translation>
+ </message>
+ <message>
+ <source>PREF_RAY_TRACING_ANTIALIASING</source>
+ <translation type="unfinished">Adaptive anti-aliasing</translation>
+ </message>
+ <message>
+ <source>PREF_RAY_TRACING_SHADOW</source>
+ <translation type="unfinished">Shadows rendering</translation>
+ </message>
+ <message>
+ <source>PREF_RAY_TRACING_TRANS_SHADOW</source>
+ <translation type="unfinished">Transparent shadow</translation>
+ </message>
+ <message>
+ <source>PREF_GROUP_LIGHT</source>
+ <translation type="unfinished">Light source</translation>
+ </message>
+ <message>
+ <source>PREF_LIGHT_COLOR</source>
+ <translation type="unfinished">Color</translation>
+ </message>
<message>
<source>TOT_CLOSE</source>
<translation>閉じる</translation>
${PROJECT_SOURCE_DIR}/src/ViewerData
${PROJECT_SOURCE_DIR}/src/ViewerTools
${PROJECT_SOURCE_DIR}/src/OpenGLUtils
+ ${PROJECT_SOURCE_DIR}/src/CAF
)
# additional preprocessor / compiler flags
SET(_link_LIBRARIES
${OPENGL_LIBRARIES} ${QT_LIBRARIES} ${CAS_KERNEL} ${CAS_VIEWER} ${CAS_TKGeomAlgo}
${CAS_TKTopAlgo} ${CAS_TKG2d} ${CAS_TKOpenGl}
- CASCatch qtx suit ViewerTools ViewerData OpenGLUtils
+ CASCatch qtx suit ViewerTools ViewerData OpenGLUtils caf
)
# --- headers ---
OCCViewer_AISSelector.h
OCCViewer_AxialScaleDlg.h
OCCViewer_ClippingDlg.h
+ OCCViewer_RayTracingDlg.h
+ OCCViewer_EnvTextureDlg.h
+ OCCViewer_LightSourceDlg.h
OCCViewer_CreateRestoreViewDlg.h
OCCViewer_CubeAxesDlg.h
OCCViewer_FontWidget.h
resources/occ_view_triedre.png
resources/occ_view_zoom.png
resources/occ_view_zooming_style_switch.png
+ resources/occ_view_ray_tracing.png
+ resources/occ_view_env_texture.png
+ resources/occ_view_light_source.png
)
# --- sources ---
OCCViewer_AISSelector.cxx
OCCViewer_AxialScaleDlg.cxx
OCCViewer_ClippingDlg.cxx
+ OCCViewer_RayTracingDlg.cxx
+ OCCViewer_EnvTextureDlg.cxx
+ OCCViewer_LightSourceDlg.cxx
OCCViewer_ClipPlane.cxx
OCCViewer_CreateRestoreViewDlg.cxx
OCCViewer_CubeAxesDlg.cxx
--- /dev/null
+// Copyright (C) 2015 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// 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 http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+// internal includes
+#include "OCCViewer_EnvTextureDlg.h"
+#include "OCCViewer_ViewWindow.h"
+#include "OCCViewer_ViewPort3d.h"
+#include "OCCViewer_ViewFrame.h"
+
+// GUI includes
+#include <SUIT_Session.h>
+
+// OCCT includes
+#include <Graphic3d_TextureEnv.hxx>
+
+// QT Includes
+#include <QGroupBox>
+#include <QVBoxLayout>
+#include <QPushButton>
+#include <QComboBox>
+#include <QFileDialog>
+#include <QLineEdit>
+
+/*!
+ \class OCCViewer_EnvTextureDlg
+ \brief Dialog allowing to assign parameters of environment texture
+*/
+
+/*!
+ \brief Constructor
+ \param view - parent widget
+*/
+OCCViewer_EnvTextureDlg::OCCViewer_EnvTextureDlg( OCCViewer_ViewWindow* view )
+ :QDialog( view )
+{
+
+ // get current view frame (OCCViewer_ViewWindow->QFrame->OCCViewer_ViewFrame)
+ myViewFrame = dynamic_cast<OCCViewer_ViewFrame*>( view->parent()->parent() );
+ myView3d = view->getViewPort()->getView();
+
+ setObjectName( "OCCViewer_EnvTextureDlg" );
+ setWindowTitle( tr( "ENV_TEXTURE" ) );
+ setModal( false );
+
+ setAttribute( Qt::WA_DeleteOnClose, true );
+
+ // Create layout for this dialog
+ QVBoxLayout* dlglayout = new QVBoxLayout( this );
+ dlglayout->setSpacing( 6 );
+ dlglayout->setMargin( 11 );
+
+ // Create "Environment texture" group
+
+ myEnvTextureGroup = new QGroupBox( tr( "ENV_TEXTURE" ) );
+ myEnvTextureGroup->setCheckable( true );
+
+ QGridLayout* envTextureLayout = new QGridLayout( myEnvTextureGroup );
+ envTextureLayout->setSpacing( 6 );
+ envTextureLayout->setMargin( 11 );
+
+ myEnvTextureId = new QComboBox();
+ myEnvTextureId->addItem( tr( "ENV_CLOUDS" ) );
+ myEnvTextureId->addItem( tr( "ENV_CV" ) );
+ myEnvTextureId->addItem( tr( "ENV_MEDIT" ) );
+ myEnvTextureId->addItem( tr( "ENV_PEARL" ) );
+ myEnvTextureId->addItem( tr( "ENV_SKY1" ) );
+ myEnvTextureId->addItem( tr( "ENV_SKY2" ) );
+ myEnvTextureId->addItem( tr( "ENV_LINES" ) );
+ myEnvTextureId->addItem( tr( "ENV_ROAD" ) );
+ myEnvTextureId->addItem( tr( "ENV_CUSTOM" ) );
+ myEnvTextureId->setMinimumWidth( 300 );
+
+ myEnvTextureName = new QLineEdit();
+ myEnvTextureName->setVisible( false );
+ myFileButton = new QPushButton();
+ myFileButton->setText("...");
+ myFileButton->setVisible( false );
+
+ envTextureLayout->addWidget( myEnvTextureId, 0, 0, 1, 2 );
+ envTextureLayout->addWidget( myEnvTextureName, 1, 0 );
+ envTextureLayout->addWidget( myFileButton, 1, 1 );
+
+ // Create "Buttons" group
+
+ QGroupBox* groupButtons = new QGroupBox( this );
+ QHBoxLayout* groupButtonsLayout = new QHBoxLayout( groupButtons );
+ groupButtonsLayout->setSpacing( 6 );
+ groupButtonsLayout->setMargin( 11 );
+
+ QPushButton* buttonClose = new QPushButton( tr( "BUT_CLOSE" ) );
+ buttonClose->setDefault( true );
+
+ QPushButton* buttonHelp = new QPushButton( tr( "GEOM_BUT_HELP" ) );
+
+ groupButtonsLayout->addStretch();
+ groupButtonsLayout->addWidget( buttonClose );
+ groupButtonsLayout->addWidget( buttonHelp );
+
+ dlglayout->addWidget( myEnvTextureGroup );
+ dlglayout->addWidget( groupButtons );
+
+ // Initializations
+ initParam();
+
+ // Signals and slots connections
+ connect( myEnvTextureGroup, SIGNAL( toggled(bool) ), this, SLOT( onEnvTexture(bool) ) );
+ connect( myEnvTextureId, SIGNAL( currentIndexChanged(int) ), this, SLOT( onTextureChanged() ) );
+ connect( myFileButton, SIGNAL( clicked() ), this, SLOT( onFileSelectionClicked() ) );
+ connect( buttonClose, SIGNAL( clicked() ), this, SLOT( close() ) );
+ connect( buttonHelp, SIGNAL( clicked() ), this, SLOT( ClickOnHelp() ) );
+}
+
+/*!
+ \brief Destructor
+*/
+OCCViewer_EnvTextureDlg::~OCCViewer_EnvTextureDlg()
+{
+}
+
+QString OCCViewer_EnvTextureDlg::getName()
+{
+ // return the name of object
+ return QString( "OCCViewer_EnvTextureDlg" );
+}
+
+/*!
+ Initialization of initial values of widgets
+*/
+void OCCViewer_EnvTextureDlg::initParam()
+{
+ Handle(Graphic3d_TextureEnv) aTexture = myView3d->TextureEnv();
+ bool anIsTexture = !aTexture.IsNull();
+ myEnvTextureGroup->setChecked( anIsTexture );
+ if ( anIsTexture ) {
+ int aTextureId = myView3d->TextureEnv()->Name();
+ myEnvTextureId->setCurrentIndex( aTextureId );
+ if ( aTextureId == myEnvTextureId->count() - 1 ) {
+ TCollection_AsciiString aFileName;
+ aTexture->Path().SystemName( aFileName );
+ myEnvTextureName->setText( QString( aFileName.ToCString() ) );
+ myFileButton->setVisible( true );
+ myEnvTextureName->setVisible( true );
+ }
+ }
+}
+
+/*!
+ SLOT on "Environment texture" group click
+*/
+void OCCViewer_EnvTextureDlg::onEnvTexture( bool theIsChecked )
+{
+ if ( theIsChecked )
+ onTextureChanged();
+ else {
+ Handle(Graphic3d_TextureEnv) aTexture;
+ setEnvTexture( aTexture, V3d_TEX_ALL );
+ }
+}
+
+/*!
+ SLOT on when user changed the texture
+*/
+void OCCViewer_EnvTextureDlg::onTextureChanged()
+{
+ Handle(Graphic3d_TextureEnv) aTexture;
+ bool isCustom = myEnvTextureId->currentIndex() == myEnvTextureId->count()-1;
+ myEnvTextureName->setVisible( isCustom );
+ myFileButton->setVisible( isCustom );
+ if( isCustom ) {
+ if( myEnvTextureName->text().isEmpty() )
+ onFileSelectionClicked();
+ aTexture = new Graphic3d_TextureEnv( TCollection_AsciiString( myEnvTextureName->text().toStdString().c_str() ) );
+ }
+ else {
+ myEnvTextureName->setText("");
+ Graphic3d_NameOfTextureEnv aStandardTexture;
+ QList<Graphic3d_NameOfTextureEnv> aTextures;
+ aTextures << Graphic3d_NOT_ENV_CLOUDS << Graphic3d_NOT_ENV_CV << Graphic3d_NOT_ENV_MEDIT
+ << Graphic3d_NOT_ENV_PEARL << Graphic3d_NOT_ENV_SKY1 << Graphic3d_NOT_ENV_SKY2
+ << Graphic3d_NOT_ENV_LINES << Graphic3d_NOT_ENV_ROAD;
+ aTexture = new Graphic3d_TextureEnv( aTextures.at( myEnvTextureId->currentIndex() ) );
+ }
+ setEnvTexture( aTexture, V3d_TEX_ENVIRONMENT );
+}
+
+/*!
+ SLOT on file selection button click
+*/
+void OCCViewer_EnvTextureDlg::onFileSelectionClicked()
+{
+ QString selFile = QFileDialog::getOpenFileName( this,tr( "GEOM_SELECT_IMAGE" ),QString(), tr( "OCC_TEXTURE_FILES" ) );
+ if ( !selFile.isEmpty() ) {
+ myEnvTextureName->setText( selFile );
+ onTextureChanged();
+ }
+}
+
+/*!
+ SLOT on help button click: opens a help page
+*/
+void OCCViewer_EnvTextureDlg::ClickOnHelp()
+{
+ SUIT_Application* app = SUIT_Session::session()->activeApplication();
+ if ( app )
+ app->onHelpContextModule( "GUI", "occ_3d_viewer_page.html", "env_texture" );
+}
+
+/*!
+ Sets current texture environment for all view in the viewer
+*/
+void OCCViewer_EnvTextureDlg::setEnvTexture( Handle(Graphic3d_TextureEnv) theTexture, V3d_TypeOfSurfaceDetail theMode )
+{
+ for ( int i = OCCViewer_ViewFrame::BOTTOM_RIGHT; i <= OCCViewer_ViewFrame::TOP_RIGHT; i++ ) {
+ if ( OCCViewer_ViewWindow* aViewWindow = myViewFrame->getView(i) ) {
+ Handle(V3d_View) aView = aViewWindow->getViewPort()->getView();
+ aView->SetTextureEnv( theTexture );
+ aView->SetSurfaceDetail( theMode );
+ aView->Redraw();
+ }
+ }
+}
--- /dev/null
+// Copyright (C) 2015 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// 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 http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef OCCVIEWER_ENVTEXTUREDLG_H
+#define OCCVIEWER_ENVTEXTUREDLG_H
+
+#include "OCCViewer.h"
+#include <QDialog>
+#include <V3d_View.hxx>
+
+class OCCViewer_ViewWindow;
+class OCCViewer_ViewFrame;
+class QGroupBox;
+class QComboBox;
+class QLineEdit;
+
+class OCCVIEWER_EXPORT OCCViewer_EnvTextureDlg : public QDialog
+{
+ Q_OBJECT
+
+ public:
+ OCCViewer_EnvTextureDlg( OCCViewer_ViewWindow* );
+ ~OCCViewer_EnvTextureDlg();
+
+ static QString getName();
+
+private slots:
+
+ void onEnvTexture( bool );
+ void onTextureChanged();
+ void onFileSelectionClicked();
+
+ void ClickOnHelp();
+
+private:
+ void initParam();
+ void setEnvTexture( Handle(Graphic3d_TextureEnv), V3d_TypeOfSurfaceDetail );
+
+ OCCViewer_ViewFrame* myViewFrame;
+ Handle(V3d_View) myView3d;
+
+ QGroupBox* myEnvTextureGroup;
+ QComboBox* myEnvTextureId;
+ QLineEdit* myEnvTextureName;
+ QPushButton* myFileButton;
+};
+
+#endif // OCCVIEWER_ENVTEXTUREDLG_H
--- /dev/null
+// Copyright (C) 2015 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// 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 http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+// internal includes
+#include "OCCViewer_LightSourceDlg.h"
+#include "OCCViewer_ViewWindow.h"
+#include "OCCViewer_ViewModel.h"
+
+// GUI includes
+#include <SUIT_Session.h>
+#include <CAF_Tools.h>
+#include <QtxDoubleSpinBox.h>
+#include <QtxColorButton.h>
+
+// Qt includes
+#include <QGroupBox>
+#include <QVBoxLayout>
+#include <QHBoxLayout>
+#include <QLabel>
+#include <QPushButton>
+#include <QCheckBox>
+#include <QStackedLayout>
+#include <QRadioButton>
+
+/*!
+ \class OCCViewer_LightSourceDlg
+ \brief Dialog allowing to assign parameters of light source
+*/
+
+/*!
+ \brief Constructor
+ \param view - parent widget
+ \param model - viewer
+*/
+OCCViewer_LightSourceDlg::OCCViewer_LightSourceDlg( OCCViewer_ViewWindow* view, OCCViewer_Viewer* model )
+ :QDialog( view ),
+ myModel( model )
+{
+ setObjectName( "OCCViewer_LightSourceDlg" );
+ setWindowTitle( tr( "LIGHT_SOURCE" ) );
+ setModal( false );
+
+ setAttribute( Qt::WA_DeleteOnClose, true );
+
+ // Create layout for this dialog
+ QVBoxLayout* dlglayout = new QVBoxLayout( this );
+ dlglayout->setSpacing( 6 ); dlglayout->setMargin( 11 );
+
+ QGroupBox* typeGroup = new QGroupBox( tr( "TYPE" ), this );
+ QHBoxLayout* typeLayout = new QHBoxLayout( typeGroup );
+ typeLayout->setSpacing( 6 ); typeLayout->setMargin( 11 );
+
+ myDirType = new QRadioButton( tr( "DIRECTIONAL" ), typeGroup );
+ myPosType = new QRadioButton( tr( "POSITIONAL" ), typeGroup );
+
+ typeLayout->addWidget( myDirType );
+ typeLayout->addWidget( myPosType );
+
+ myStackedLayout = new QStackedLayout();
+
+ const double min = -RealLast();
+ const double max = RealLast();
+ const int precision = 3;
+
+ /********************** Directional light **********************/
+ /* Controls for directional light:
+ Dx, Dy, Dz - direction
+ Headlight - headlight flag
+ Color - the color of a light source
+ */
+
+ QWidget* dirWidget = new QWidget( this );
+ QVBoxLayout* dirLayout = new QVBoxLayout( dirWidget );
+ dirLayout->setSpacing( 6 ); dirLayout->setMargin( 11 );
+
+ // Create "Direction" group
+
+ const double dir_step = 0.1;
+
+ QGroupBox* dirCoordGroup = new QGroupBox( tr( "DIRECTION" ), this );
+ QHBoxLayout* dirCoordLayout = new QHBoxLayout( dirCoordGroup );
+ dirCoordLayout->setSpacing( 6 ); dirCoordLayout->setMargin( 11 );
+
+ QLabel* dxLabel = new QLabel( tr("Dx:"), dirCoordGroup );
+ myDx = new QtxDoubleSpinBox( min, max, dir_step, dirCoordGroup );
+ myDx->setValue( 0.0 );
+ myDx->setMinimumWidth( 80 );
+
+ QLabel* dyLabel = new QLabel( tr("Dy:"), dirCoordGroup );
+ myDy = new QtxDoubleSpinBox( min, max, dir_step, dirCoordGroup );
+ myDy->setValue( 0.0 );
+ myDy->setMinimumWidth( 80 );
+
+ QLabel* dzLabel = new QLabel( tr("Dz:"), dirCoordGroup );
+ myDz = new QtxDoubleSpinBox( min, max, dir_step, dirCoordGroup );
+ myDz->setValue( -1.0 );
+ myDz->setMinimumWidth( 80 );
+
+ dirCoordLayout->addWidget( dxLabel );
+ dirCoordLayout->addWidget( myDx );
+ dirCoordLayout->addWidget( dyLabel );
+ dirCoordLayout->addWidget( myDy );
+ dirCoordLayout->addWidget( dzLabel );
+ dirCoordLayout->addWidget( myDz );
+
+ // Create "Parameters" group
+
+ QGroupBox* dirParamGroup = new QGroupBox( dirWidget );
+ QHBoxLayout* dirParamLayout = new QHBoxLayout( dirParamGroup );
+ dirParamLayout->setSpacing( 6 ); dirParamLayout->setMargin( 11 );
+
+ myDirHeadLight = new QCheckBox( tr("HEADLIGHT"), dirParamGroup );
+ myDirHeadLight->setChecked( false );
+
+ QLabel* aColorLabel = new QLabel( tr( "COLOR" ), dirParamGroup );
+ myDirColor = new QtxColorButton( dirParamGroup );
+ myDirColor->setColor( Qt::white );
+
+ dirParamLayout->addWidget( myDirHeadLight );
+ dirParamLayout->addWidget( aColorLabel );
+ dirParamLayout->addWidget( myDirColor );
+ dirParamLayout->addStretch();
+
+ dirLayout->addWidget( dirCoordGroup );
+ dirLayout->addWidget( dirParamGroup );
+
+ /********************** Positional light **********************/
+ /* Controls for positional light:
+ X, Y, Z - position
+ Headlight - headlight flag
+ Color - the color of a light source
+ */
+
+ QWidget* posWidget = new QWidget( this );
+ QVBoxLayout* posLayout = new QVBoxLayout( posWidget );
+ posLayout->setSpacing( 6 ); posLayout->setMargin( 11 );
+
+ // Create "Position" group
+
+ const double pos_step = 1.0;
+
+ QGroupBox* posCoordGroup = new QGroupBox( tr( "POSITION" ), posWidget );
+ QHBoxLayout* posCoordLayout = new QHBoxLayout( posCoordGroup );
+ posCoordLayout->setSpacing( 6 ); posCoordLayout->setMargin( 11 );
+
+ QLabel* xLabel = new QLabel( tr("X:"), posCoordGroup );
+ myX = new QtxDoubleSpinBox( min, max, pos_step, posCoordGroup );
+ myX->setValue( 0.0 );
+ myX->setMinimumWidth( 80 );
+
+ QLabel* yLabel = new QLabel( tr("Y:"), posCoordGroup );
+ myY = new QtxDoubleSpinBox( min, max, pos_step, posCoordGroup );
+ myY->setValue( 0.0 );
+ myY->setMinimumWidth( 80 );
+
+ QLabel* zLabel = new QLabel( tr("Z:"), posCoordGroup );
+ myZ = new QtxDoubleSpinBox( min, max, pos_step, posCoordGroup );
+ myZ->setValue( 0.0 );
+ myZ->setMinimumWidth( 80 );
+
+ posCoordLayout->addWidget( xLabel );
+ posCoordLayout->addWidget( myX );
+ posCoordLayout->addWidget( yLabel );
+ posCoordLayout->addWidget( myY );
+ posCoordLayout->addWidget( zLabel );
+ posCoordLayout->addWidget( myZ );
+
+ // Create "Parameters" group
+
+ QGroupBox* posParamGroup = new QGroupBox( posWidget );
+ QHBoxLayout* posParamLayout = new QHBoxLayout( posParamGroup );
+ posParamLayout->setSpacing( 6 ); posParamLayout->setMargin( 11 );
+
+ myPosHeadLight = new QCheckBox( tr("HEADLIGHT"), posParamGroup );
+ myPosHeadLight->setChecked( false );
+
+ aColorLabel = new QLabel( tr( "COLOR" ), posParamGroup );
+ myPosColor = new QtxColorButton( posParamGroup );
+ myPosColor->setColor( Qt::white );
+
+ posParamLayout->addWidget( myPosHeadLight );
+ posParamLayout->addWidget( aColorLabel );
+ posParamLayout->addWidget( myPosColor );
+ posParamLayout->addStretch();
+
+ posLayout->addWidget( posCoordGroup );
+ posLayout->addWidget( posParamGroup );
+
+ // add widgets in the stacked layout
+ myStackedLayout->addWidget( dirWidget );
+ myStackedLayout->addWidget( posWidget );
+
+ // Create "Buttons" group
+
+ QGroupBox* buttonGroup = new QGroupBox( this );
+ QHBoxLayout* buttonLayout = new QHBoxLayout( buttonGroup );
+ buttonLayout->setSpacing( 6 );
+ buttonLayout->setMargin( 11 );
+
+ QPushButton* okButton = new QPushButton( tr( "BUT_APPLY_AND_CLOSE" ), buttonGroup );
+ okButton->setDefault( true );
+ QPushButton* defaultButton = new QPushButton( tr( "BUT_DEFAULT" ), buttonGroup );
+ QPushButton* closeButton = new QPushButton( tr( "BUT_CLOSE" ), buttonGroup );
+ QPushButton* helpButton = new QPushButton( tr( "GEOM_BUT_HELP" ), buttonGroup );
+
+ buttonLayout->addWidget( okButton );
+ buttonLayout->addWidget( defaultButton );
+ buttonLayout->addStretch();
+ buttonLayout->addWidget( closeButton );
+ buttonLayout->addWidget( helpButton );
+
+ dlglayout->addWidget( typeGroup );
+ dlglayout->addLayout( myStackedLayout );
+ dlglayout->addWidget( buttonGroup );
+
+ this->setLayout( dlglayout );
+
+ // Initializations
+ initParam();
+ isBusy = false;
+
+ // Signals and slots connections
+ connect( myDirType, SIGNAL( clicked( bool ) ), this, SLOT( onTypeChanged() ) );
+ connect( myPosType, SIGNAL( clicked( bool ) ), this, SLOT( onTypeChanged() ) );
+
+ connect( myDx, SIGNAL( valueChanged( double ) ), this, SLOT( onDirChanged() ) );
+ connect( myDy, SIGNAL( valueChanged( double ) ), this, SLOT( onDirChanged() ) );
+ connect( myDz, SIGNAL( valueChanged( double ) ), this, SLOT( onDirChanged() ) );
+ connect( myDirHeadLight, SIGNAL( clicked( bool ) ), this, SLOT( onDirChanged() ) );
+ connect( myDirColor, SIGNAL( changed( QColor ) ), this, SLOT( onDirChanged() ) );
+
+ connect( myX, SIGNAL( valueChanged( double ) ), this, SLOT( onPosChanged() ) );
+ connect( myY, SIGNAL( valueChanged( double ) ), this, SLOT( onPosChanged() ) );
+ connect( myZ, SIGNAL( valueChanged( double ) ), this, SLOT( onPosChanged() ) );
+ connect( myPosHeadLight, SIGNAL( clicked( bool ) ), this, SLOT( onPosChanged() ) );
+ connect( myPosColor, SIGNAL( changed( QColor ) ), this, SLOT( onPosChanged() ) );
+
+ connect( okButton, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
+ connect( defaultButton, SIGNAL( clicked() ), this, SLOT( ClickOnDefault() ) );
+ connect( closeButton, SIGNAL( clicked() ), this, SLOT( ClickOnClose() ) );
+ connect( helpButton, SIGNAL( clicked() ), this, SLOT( ClickOnHelp() ) );
+
+ resize( minimumSizeHint() );
+}
+
+/*!
+ \brief Destructor
+*/
+OCCViewer_LightSourceDlg::~OCCViewer_LightSourceDlg()
+{
+ ( myInType == V3d_DIRECTIONAL ) ? myModel->getViewer3d()->DelLight( myPosLight ) :
+ myModel->getViewer3d()->DelLight( myDirLight );
+}
+
+QString OCCViewer_LightSourceDlg::getName()
+{
+ // return the name of object
+ return QString( "OCCViewer_LightSourceDlg" );
+}
+
+/*!
+ Initialization of initial values of widgets
+*/
+void OCCViewer_LightSourceDlg::initParam( bool theIsDefault )
+{
+ Handle(V3d_Light) aLight;
+ myModel->getViewer3d()->InitDefinedLights();
+ while ( myModel->getViewer3d()->MoreDefinedLights() )
+ {
+ aLight = myModel->getViewer3d()->DefinedLight();
+ if ( aLight->Type() == V3d_DIRECTIONAL ) {
+ myDirLight = Handle(V3d_DirectionalLight)::DownCast( aLight );
+ myPosLight = new V3d_PositionalLight( myModel->getViewer3d(), 0, 0, 0 );
+ myDirType->setChecked( true );
+ myStackedLayout->setCurrentIndex(0);
+ break;
+ }
+ if ( aLight->Type() == V3d_POSITIONAL ) {
+ myPosLight = Handle(V3d_PositionalLight)::DownCast( aLight );
+ myDirLight = new V3d_DirectionalLight( myModel->getViewer3d() );
+ myPosType->setChecked( true );
+ myStackedLayout->setCurrentIndex(1);
+ break;
+ }
+ myModel->getViewer3d()->NextDefinedLights();
+ }
+
+ double aX, aY, aZ;
+ Quantity_Color aColor = aLight->Color();
+ if( myDirType->isChecked() ) {
+ myDirColor->setColor( CAF_Tools::color( aColor ) );
+ myDirLight->Direction( aX, aY, aZ );
+ myDx->setValue( aX );
+ myDy->setValue( aY );
+ myDz->setValue( aZ );
+ myDirHeadLight->setChecked( myDirLight->Headlight() );
+ }
+ else if( myPosType->isChecked() ) {
+ myPosColor->setColor( CAF_Tools::color( aColor ) );
+ myPosLight->Position( aX, aY, aZ );
+ myX->setValue( aX );
+ myY->setValue( aY );
+ myZ->setValue( aZ );
+ myPosHeadLight->setChecked( myPosLight->Headlight() );
+ }
+
+ if ( !theIsDefault ) {
+ myInX = aX; myInY = aY; myInZ = aZ;
+ myInColor = aColor;
+ myInHeadLight = aLight->Headlight();
+ myInType = aLight->Type();
+ }
+}
+
+/*!
+ SLOT: called on type of light source changed
+*/
+void OCCViewer_LightSourceDlg::onTypeChanged()
+{
+ if( isBusy )
+ return;
+ myStackedLayout->setCurrentIndex( myPosType->isChecked() );
+ if( myPosType->isChecked() ) {
+ myModel->getViewer3d()->SetLightOff( myDirLight );
+ onPosChanged();
+ }
+ else if( myDirType->isChecked() ) {
+ myModel->getViewer3d()->SetLightOff( myPosLight );
+ onDirChanged();
+ }
+}
+
+/*!
+ SLOT: called on value of directional light source changed
+*/
+void OCCViewer_LightSourceDlg::onDirChanged()
+{
+ if( isBusy )
+ return;
+ myModel->getViewer3d()->SetLightOff( myDirLight );
+ if ( !( myDx->value() == 0 && myDy->value() == 0 && myDz->value() == 0 ) ) {
+ myDirLight->SetDirection( myDx->value(), myDy->value(), myDz->value() );
+ myDirLight->SetColor( CAF_Tools::color( myDirColor->color() ) );
+ myDirLight->SetHeadlight( myDirHeadLight->isChecked() );
+ myModel->getViewer3d()->SetLightOn( myDirLight );
+ }
+ myModel->getViewer3d()->UpdateLights();
+}
+
+/*!
+ SLOT: called on value of positional light source changed
+*/
+void OCCViewer_LightSourceDlg::onPosChanged()
+{
+ if( isBusy )
+ return;
+ myModel->getViewer3d()->SetLightOff( myPosLight );
+ myPosLight->SetPosition( myX->value(), myY->value(), myZ->value() );
+ myPosLight->SetColor( CAF_Tools::color( myPosColor->color() ) );
+ myPosLight->SetHeadlight( myPosHeadLight->isChecked() );
+ myModel->getViewer3d()->SetLightOn( myPosLight );
+ myModel->getViewer3d()->UpdateLights();
+}
+
+/*!
+ \brief SLOT on "Apply and Close" button click: sets current light source and closes dialog
+*/
+void OCCViewer_LightSourceDlg::ClickOnOk()
+{
+ // need save a current type for deleting other light when dialog will be closed
+ myInType = myDirType->isChecked() ? V3d_DIRECTIONAL : V3d_POSITIONAL;
+ close();
+}
+
+/*!
+ \brief SLOT on "Default" button click: sets default light source
+*/
+void OCCViewer_LightSourceDlg::ClickOnDefault()
+{
+ isBusy = true;
+ myModel->setDefaultLights();
+ initParam( true );
+ myModel->getViewer3d()->UpdateLights();
+ isBusy = false;
+}
+
+/*!
+ \brief SLOT on "Close" button click: sets initial light source and closes dialog
+*/
+void OCCViewer_LightSourceDlg::ClickOnClose()
+{
+ if( myInType == V3d_DIRECTIONAL ) {
+ myDirLight->SetDirection( myInX, myInY, myInZ );
+ myDirLight->SetColor( myInColor );
+ myDirLight->SetHeadlight( myInHeadLight );
+ myModel->getViewer3d()->SetLightOn( myDirLight );
+ }
+ else {
+ myPosLight->SetPosition( myInX, myInY, myInZ );
+ myPosLight->SetColor( myInColor );
+ myPosLight->SetHeadlight( myInHeadLight );
+ myModel->getViewer3d()->SetLightOn( myPosLight );
+ }
+ close();
+}
+
+/*!
+ \brief SLOT on help button click: opens a help page
+*/
+void OCCViewer_LightSourceDlg::ClickOnHelp()
+{
+ SUIT_Application* app = SUIT_Session::session()->activeApplication();
+ if ( app )
+ app->onHelpContextModule( "GUI", "occ_3d_viewer_page.html", "light_source" );
+}
--- /dev/null
+// Copyright (C) 2015 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// 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 http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef OCCVIEWER_LIGHTSOURCEDLG_H
+#define OCCVIEWER_LIGHTSOURCEDLG_H
+
+#include "OCCViewer.h"
+#include <QDialog>
+#include <V3d_DirectionalLight.hxx>
+#include <V3d_PositionalLight.hxx>
+#include <V3d_TypeOfLight.hxx>
+
+class OCCViewer_ViewWindow;
+class OCCViewer_Viewer;
+class QtxDoubleSpinBox;
+class QtxColorButton;
+class QPushButton;
+class QCheckBox;
+class QRadioButton;
+class QStackedLayout;
+
+class OCCVIEWER_EXPORT OCCViewer_LightSourceDlg: public QDialog
+{
+ Q_OBJECT
+
+public:
+ OCCViewer_LightSourceDlg( OCCViewer_ViewWindow*, OCCViewer_Viewer* );
+ ~OCCViewer_LightSourceDlg();
+
+ static QString getName();
+
+protected slots:
+
+private slots:
+ void onTypeChanged();
+ void onDirChanged();
+ void onPosChanged();
+
+ void ClickOnOk();
+ void ClickOnDefault();
+ void ClickOnClose();
+ void ClickOnHelp();
+
+private:
+ void initParam( bool theIsDefault = false );
+
+ OCCViewer_Viewer* myModel;
+
+ Handle(V3d_DirectionalLight) myDirLight;
+ Handle(V3d_PositionalLight) myPosLight;
+
+ QRadioButton* myDirType;
+ QRadioButton* myPosType;
+
+ QStackedLayout* myStackedLayout;
+
+ QtxDoubleSpinBox* myDx;
+ QtxDoubleSpinBox* myDy;
+ QtxDoubleSpinBox* myDz;
+ QCheckBox* myDirHeadLight;
+ QtxColorButton* myDirColor;
+
+ QtxDoubleSpinBox* myX;
+ QtxDoubleSpinBox* myY;
+ QtxDoubleSpinBox* myZ;
+ QCheckBox* myPosHeadLight;
+ QtxColorButton* myPosColor;
+
+ double myInX, myInY, myInZ;
+ bool myInHeadLight;
+ Quantity_Color myInColor;
+ V3d_TypeOfLight myInType;
+
+ bool isBusy;
+};
+
+#endif // OCCVIEWER_LIGHTSOURCEDLG_H
--- /dev/null
+// Copyright (C) 2015 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// 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 http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+// internal includes
+#include "OCCViewer_RayTracingDlg.h"
+#include "OCCViewer_ViewWindow.h"
+#include "OCCViewer_ViewPort3d.h"
+#include "OCCViewer_ViewFrame.h"
+
+// GUI includes
+#include <SUIT_Session.h>
+#include <QtxIntSpinBox.h>
+
+// QT Includes
+#include <QGroupBox>
+#include <QVBoxLayout>
+#include <QLabel>
+#include <QPushButton>
+#include <QCheckBox>
+
+/*!
+ \class OCCViewer_RayTracingDlg
+ \brief Dialog allowing to assign parameters of ray tracing
+*/
+
+/*!
+ \brief Constructor
+ \param view - parent widget
+*/
+OCCViewer_RayTracingDlg::OCCViewer_RayTracingDlg( OCCViewer_ViewWindow* view )
+ :QDialog( view )
+{
+ // get current view frame (OCCViewer_ViewWindow->QFrame->OCCViewer_ViewFrame)
+ myViewFrame = dynamic_cast<OCCViewer_ViewFrame*>( view->parent()->parent() );
+ myView3d = view->getViewPort()->getView();
+ setObjectName( "OCCViewer_RayTracingDlg" );
+ setWindowTitle( tr( "RAY_TRACING" ) );
+ setModal( false );
+
+ setAttribute( Qt::WA_DeleteOnClose, true );
+
+ // Create layout for this dialog
+ QVBoxLayout* dlglayout = new QVBoxLayout( this );
+ dlglayout->setSpacing( 6 );
+ dlglayout->setMargin( 11 );
+
+ // Create "Ray tracing" group
+
+ myRayTracingGroup = new QGroupBox( tr( "RAY_TRACING" ) );
+ myRayTracingGroup->setCheckable( true );
+
+ QGridLayout* rayTracingLayout = new QGridLayout( myRayTracingGroup );
+ rayTracingLayout->setSpacing( 6 );
+ rayTracingLayout->setMargin( 11 );
+
+ myShadow = new QCheckBox( tr("SHADOW") );
+ myReflection = new QCheckBox( tr("REFLECTION") );
+ myAntialiasing = new QCheckBox( tr("ANTIALIASING") );
+ myTransparentShadow = new QCheckBox( tr("TRANSPARENT_SHADOW") );
+ QLabel* depthLabel = new QLabel( tr( "DEPTH" ) );
+ myDepth = new QtxIntSpinBox( 1, 10 );
+
+ rayTracingLayout->addWidget( depthLabel, 0, 0 );
+ rayTracingLayout->addWidget( myDepth, 0, 1 );
+ rayTracingLayout->addWidget( myReflection, 1, 0 );
+ rayTracingLayout->addWidget( myAntialiasing, 1, 1 );
+ rayTracingLayout->addWidget( myShadow, 2, 0 );
+ rayTracingLayout->addWidget( myTransparentShadow, 2, 1 );
+
+ // Create "Buttons" group
+
+ QGroupBox* groupButtons = new QGroupBox( this );
+ QHBoxLayout* groupButtonsLayout = new QHBoxLayout( groupButtons );
+ groupButtonsLayout->setSpacing( 6 );
+ groupButtonsLayout->setMargin( 11 );
+
+ QPushButton* buttonClose = new QPushButton( tr( "BUT_CLOSE" ) );
+ buttonClose->setDefault( true );
+
+ QPushButton* buttonHelp = new QPushButton( tr( "GEOM_BUT_HELP" ) );
+
+ groupButtonsLayout->addStretch();
+ groupButtonsLayout->addWidget( buttonClose );
+ groupButtonsLayout->addWidget( buttonHelp );
+
+ dlglayout->addWidget( myRayTracingGroup );
+ dlglayout->addWidget( groupButtons );
+
+ // Initializations
+ initParam();
+
+ // Signals and slots connections
+ connect( myRayTracingGroup, SIGNAL( toggled(bool) ), this, SLOT( onRayTracing(bool) ) );
+ connect( myShadow, SIGNAL( toggled(bool) ), this, SLOT( onValueChanged() ) );
+ connect( myReflection, SIGNAL( toggled(bool) ), this, SLOT( onValueChanged() ) );
+ connect( myAntialiasing, SIGNAL( toggled(bool) ), this, SLOT( onValueChanged() ) );
+ connect( myTransparentShadow, SIGNAL( toggled(bool) ), this, SLOT( onValueChanged() ) );
+ connect( myDepth, SIGNAL( valueChanged(int) ), this, SLOT( onValueChanged() ) );
+ connect( buttonClose, SIGNAL( clicked() ), this, SLOT( close() ) ) ;
+ connect( buttonHelp, SIGNAL( clicked() ), this, SLOT( ClickOnHelp() ) );
+}
+
+/*!
+ \brief Destructor
+*/
+OCCViewer_RayTracingDlg::~OCCViewer_RayTracingDlg()
+{
+}
+
+QString OCCViewer_RayTracingDlg::getName()
+{
+ // return the name of object
+ return QString( "OCCViewer_RayTracingDlg" );
+}
+
+/*!
+ Initialization of initial values of widgets
+*/
+void OCCViewer_RayTracingDlg::initParam()
+{
+ Graphic3d_RenderingParams aParams = myView3d->RenderingParams();
+ myRayTracingGroup->setChecked( aParams.Method == Graphic3d_RM_RAYTRACING );
+ myDepth->setValue( aParams.RaytracingDepth );
+ myReflection->setChecked( aParams.IsReflectionEnabled );
+ myAntialiasing->setChecked( aParams.IsAntialiasingEnabled );
+ myShadow->setChecked( aParams.IsShadowEnabled );
+ myTransparentShadow->setChecked( aParams.IsTransparentShadowEnabled );
+}
+
+/*!
+ SLOT: called on value of ray tracing changed
+*/
+void OCCViewer_RayTracingDlg::onValueChanged()
+{
+ for ( int i = OCCViewer_ViewFrame::BOTTOM_RIGHT; i <= OCCViewer_ViewFrame::TOP_RIGHT; i++ ) {
+ if ( OCCViewer_ViewWindow* aViewWindow = myViewFrame->getView(i) ) {
+ Handle(V3d_View) aView = aViewWindow->getViewPort()->getView();
+ Graphic3d_RenderingParams& aParams = aView->ChangeRenderingParams();
+ aParams.IsShadowEnabled = myShadow->isChecked();
+ aParams.IsReflectionEnabled = myReflection->isChecked();
+ aParams.IsAntialiasingEnabled = myAntialiasing->isChecked();
+ aParams.IsTransparentShadowEnabled = myTransparentShadow->isChecked();
+ aParams.RaytracingDepth = myDepth->value();
+ aView->Redraw();
+ }
+ }
+}
+
+/*!
+ SLOT on "Ray tracing" group click
+*/
+void OCCViewer_RayTracingDlg::onRayTracing( bool theIsChecked )
+{
+ for ( int i = OCCViewer_ViewFrame::BOTTOM_RIGHT; i <= OCCViewer_ViewFrame::TOP_RIGHT; i++ ) {
+ if ( OCCViewer_ViewWindow* aViewWindow = myViewFrame->getView(i) ) {
+ Handle(V3d_View) aView = aViewWindow->getViewPort()->getView();
+ Graphic3d_RenderingParams& aParams = aView->ChangeRenderingParams();
+ theIsChecked ? aParams.Method = Graphic3d_RM_RAYTRACING : aParams.Method = Graphic3d_RM_RASTERIZATION;
+ aView->Redraw();
+ }
+ }
+}
+
+/*!
+ SLOT on help button click: opens a help page
+*/
+void OCCViewer_RayTracingDlg::ClickOnHelp()
+{
+ SUIT_Application* app = SUIT_Session::session()->activeApplication();
+ if ( app )
+ app->onHelpContextModule( "GUI", "occ_3d_viewer_page.html", "ray_tracing" );
+}
--- /dev/null
+// Copyright (C) 2015 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// 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 http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef OCCVIEWER_RAYTRACINGDLG_H
+#define OCCVIEWER_RAYTRACINGDLG_H
+
+#include "OCCViewer.h"
+#include <QDialog>
+#include <V3d_View.hxx>
+
+class OCCViewer_ViewWindow;
+class OCCViewer_ViewFrame;
+class QCheckBox;
+class QtxIntSpinBox;
+class QGroupBox;
+
+
+class OCCVIEWER_EXPORT OCCViewer_RayTracingDlg : public QDialog
+{
+ Q_OBJECT
+
+ public:
+ OCCViewer_RayTracingDlg( OCCViewer_ViewWindow* );
+ ~OCCViewer_RayTracingDlg();
+
+ static QString getName();
+
+private slots:
+
+ void onValueChanged();
+ void onRayTracing(bool);
+
+ void ClickOnHelp();
+
+private:
+ void initParam();
+
+ OCCViewer_ViewFrame* myViewFrame;
+ Handle(V3d_View) myView3d;
+
+ QGroupBox* myRayTracingGroup;
+ QtxIntSpinBox* myDepth;
+ QCheckBox* myReflection;
+ QCheckBox* myAntialiasing;
+ QCheckBox* myShadow;
+ QCheckBox* myTransparentShadow;
+};
+
+#endif // OCCVIEWER_RAYTRACINGDLG_H
// QT includes
#include <QImage>
#include <QAction>
+#include <QDialog>
Handle(Image_PixMap) OCCViewer_Utilities::imageToPixmap( const QImage& anImage )
{
return anOldMode;
}
+
+bool OCCViewer_Utilities::isDialogOpened( OCCViewer_ViewWindow* theView, const QString& theName )
+{
+ bool isFound = false;
+ OCCViewer_ViewFrame* aViewFrame = dynamic_cast<OCCViewer_ViewFrame*>( theView->parent()->parent() );
+ QList<QDialog*> allDialogs = qFindChildren<QDialog*>( aViewFrame );
+ foreach ( QDialog* d, allDialogs )
+ if ( d->objectName() == theName )
+ isFound = true;
+ return isFound;
+}
setViewer2DMode( OCCViewer_Viewer* theViewer,
const OCCViewer_ViewWindow::Mode2dType& theMode );
+ /*!
+ * Find dialog in the current view frame by name
+ * \param theView an OCC view
+ * \param theName name of dialog
+ * \return true/false if dialog is opened/isn't opened
+ */
+ static bool isDialogOpened( OCCViewer_ViewWindow* theView, const QString& theName );
+
};
#endif // OCCVIEWER_UTILITIES_H
#include "OCCViewer_ViewFrame.h"
#include "OCCViewer_ViewWindow.h"
#include "OCCViewer_ViewModel.h"
+#include "OCCViewer_ViewPort3d.h"
#include <SUIT_ViewManager.h>
#include <SUIT_Session.h>
view->setDropDownButtons( dropDownButtons() );
connectViewSignals(view);
view->setBackground(aModel->background(i));
+ setSubViewParams( view );
}
}
}
+//**************************************************************************************
+void OCCViewer_ViewFrame::setSubViewParams( OCCViewer_ViewWindow* theView )
+{
+ Handle(V3d_View) aView = theView->getViewPort()->getView();
+ Handle(V3d_View) aMainView = myViews.at( MAIN_VIEW )->getViewPort()->getView();
+
+ // set ray tracing parameters
+ aView->ChangeRenderingParams() = aMainView->RenderingParams();
+
+ // set environment texture parameters
+ aView->SetTextureEnv( aMainView->TextureEnv() );
+ aView->SetSurfaceDetail( aMainView->SurfaceDetail() );
+}
+
void OCCViewer_ViewFrame::splitSubViews()
{
if( mySplitMode == -1 )
void updateWindowTitle( OCCViewer_ViewWindow* theView );
void createSubViews();
void splitSubViews();
+ void setSubViewParams( OCCViewer_ViewWindow* theView );
QList<OCCViewer_ViewWindow*> myViews;
QGridLayout* myLayout;
#include "ViewerData_AISShape.hxx"
+#include "CAF_Tools.h"
+
#include <Basics_OCCTVersion.hxx>
#include "QtxActionToolMgr.h"
#include <Visual3d_View.hxx>
+#include <V3d_DirectionalLight.hxx>
+#include <V3d_AmbientLight.hxx>
+
/*!
Get data for supported background modes: gradient types, identifiers and supported image formats
*/
// init CasCade viewers
myV3dViewer = OCCViewer_VService::CreateViewer( TCollection_ExtendedString("Viewer3d").ToExtString() );
//myV3dViewer->Init(); // to avoid creation of the useless perspective view (see OCCT issue 0024267)
- myV3dViewer->SetDefaultLights();
+ setDefaultLights();
// init selector
myAISContext = new AIS_InteractiveContext( myV3dViewer );
emit selectionChanged();
}
+/*
+ * Defines default lights
+ */
+void OCCViewer_Viewer::setDefaultLights()
+{
+ // clear all light sources
+ myV3dViewer->InitDefinedLights();
+ while ( myV3dViewer->MoreDefinedLights() )
+ {
+ myV3dViewer->DelLight( myV3dViewer->DefinedLight() );
+ myV3dViewer->InitDefinedLights();
+ }
+
+ // get light source parameters from preferences
+ QColor aColor = SUIT_Session::session()->resourceMgr()->colorValue( "OCCViewer", "light_color", QColor( 0, 0, 0 ) );
+ double aDx = SUIT_Session::session()->resourceMgr()->doubleValue( "OCCViewer", "light_dx", 0.0 );
+ double aDy = SUIT_Session::session()->resourceMgr()->doubleValue( "OCCViewer", "light_dy", 0.0 );
+ double aDz = SUIT_Session::session()->resourceMgr()->doubleValue( "OCCViewer", "light_dz", -1.0 );
+
+ Handle(V3d_DirectionalLight) aLight =
+ new V3d_DirectionalLight( myV3dViewer, V3d_Zneg, CAF_Tools::color( aColor ).Name(), Standard_True );
+ if( !( aDx == 0 && aDy == 0 && aDz == 0 ) )
+ aLight->SetDirection( aDx, aDy, aDz );
+ myV3dViewer->SetLightOn( aLight );
+ myV3dViewer->SetLightOn( new V3d_AmbientLight( myV3dViewer ) );
+}
+
/*!
Hilights/unhilights object in viewer
\param obj - object to be updated
void performSelectionChanged();
// emit signal selectionChanged
+ void setDefaultLights();
+
QColor backgroundColor() const; // obsolete
void setBackgroundColor( const QColor& ); // obsolete
Qtx::BackgroundData background() const;
#include <SUIT_ViewManager.h>
#include <SUIT_ViewModel.h>
+#include <SUIT_Session.h>
+#include <SUIT_ResourceMgr.h>
#include <QColor>
#include <QFileInfo>
}
#endif
- setBackground( Qtx::BackgroundData( Qt::black ) ); // set default background
+ setDefaultParams();
myCursor = NULL;
}
{
return myCursor;
}
+
+/*
+ * Set default parameters from preferences
+ */
+void OCCViewer_ViewPort3d::setDefaultParams()
+{
+ setBackground( Qtx::BackgroundData( Qt::black ) ); // set default background
+
+ // get ray tracing parameters from preferences
+ int aDepth = SUIT_Session::session()->resourceMgr()->integerValue( "OCCViewer", "rt_depth", 3 );
+ bool aReflection = SUIT_Session::session()->resourceMgr()->booleanValue( "OCCViewer", "rt_reflection", true );
+ bool anAntialiasing = SUIT_Session::session()->resourceMgr()->booleanValue( "OCCViewer", "rt_antialiasing", false );
+ bool aShadow = SUIT_Session::session()->resourceMgr()->booleanValue( "OCCViewer", "rt_shadow", true );
+ bool aTransparentShadow = SUIT_Session::session()->resourceMgr()->booleanValue( "OCCViewer", "rt_trans_shadow", true );
+
+ Graphic3d_RenderingParams& aParams = myActiveView->ChangeRenderingParams();
+ aParams.RaytracingDepth = aDepth;
+ aParams.IsReflectionEnabled = aReflection;
+ aParams.IsAntialiasingEnabled = anAntialiasing;
+ aParams.IsShadowEnabled = aShadow;
+ aParams.IsTransparentShadowEnabled = aTransparentShadow;
+ myActiveView->Redraw();
+}
bool setWindow( const Handle(V3d_View)& );
bool mapped( const Handle(V3d_View)& ) const;
void updateBackground();
+ void setDefaultParams();
private:
Handle(V3d_View) myActiveView;
#include "OCCViewer_AxialScaleDlg.h"
#include "OCCViewer_CubeAxesDlg.h"
#include "OCCViewer_ClippingDlg.h"
+#include "OCCViewer_RayTracingDlg.h"
+#include "OCCViewer_EnvTextureDlg.h"
+#include "OCCViewer_LightSourceDlg.h"
+#include "OCCViewer_Utilities.h"
#include <SUIT_Desktop.h>
#include <SUIT_Session.h>
#undef KeyPress
#endif
+// Enable ray tracing features
+#define ENABLE_RAY_TRACING
+
const char* imageZoomCursor[] = {
"32 32 3 1",
". c None",
// Synchronize View
toolMgr()->registerAction( synchronizeAction(), SynchronizeId );
+#ifdef ENABLE_RAY_TRACING
+ // Ray tracing
+ aAction = new QtxAction( tr("MNU_RAY_TRACING"), aResMgr->loadPixmap( "OCCViewer", tr("ICON_OCCVIEWER_RAY_TRACING") ),
+ tr("MNU_RAY_TRACING"), 0, this );
+ aAction->setStatusTip( tr("DSC_RAY_TRACING") );
+ connect( aAction, SIGNAL( triggered() ), this, SLOT( onRayTracing() ) );
+ toolMgr()->registerAction( aAction, RayTracingId );
+
+ // Environment texture
+ aAction = new QtxAction( tr("MNU_ENV_TEXTURE"), aResMgr->loadPixmap( "OCCViewer", tr("ICON_OCCVIEWER_ENV_TEXTURE") ),
+ tr("MNU_ENV_TEXTURE"), 0, this );
+ aAction->setStatusTip( tr("DSC_ENV_TEXTURE") );
+ connect( aAction, SIGNAL( triggered() ), this, SLOT( onEnvTexture() ) );
+ toolMgr()->registerAction( aAction, EnvTextureId );
+
+ // Light source
+ aAction = new QtxAction( tr("MNU_LIGHT_SOURCE"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_LIGHT_SOURCE" ) ),
+ tr( "MNU_LIGHT_SOURCE" ), 0, this );
+ aAction->setStatusTip( tr("DSC_LIGHT_SOURCE") );
+ connect( aAction, SIGNAL( triggered() ), this, SLOT( onLightSource() ) );
+ toolMgr()->registerAction( aAction, LightSourceId );
+#endif
}
/*!
toolMgr()->append( MaximizedId, tid );
toolMgr()->append( SynchronizeId, tid );
+#ifdef ENABLE_RAY_TRACING
+ toolMgr()->append( RayTracingId, tid );
+ toolMgr()->append( EnvTextureId, tid );
+ toolMgr()->append( LightSourceId, tid );
+#endif
}
/*!
const QString& fileName,
const QString& format )
{
+ bool res = false;
+ QApplication::setOverrideCursor( Qt::WaitCursor );
if ( format != "PS" && format != "EPS")
- return SUIT_ViewWindow::dumpViewToFormat( img, fileName, format );
+ res = myViewPort->getView()->Dump( fileName.toStdString().c_str() );
Handle(Visual3d_View) a3dView = myViewPort->getView()->View();
if (format == "PS")
- a3dView->Export(strdup(qPrintable(fileName)), Graphic3d_EF_PostScript);
+ res = a3dView->Export(strdup(qPrintable(fileName)), Graphic3d_EF_PostScript);
else if (format == "EPS")
- a3dView->Export(strdup(qPrintable(fileName)), Graphic3d_EF_EnhPostScript);
+ res = a3dView->Export(strdup(qPrintable(fileName)), Graphic3d_EF_EnhPostScript);
- return true;
+ QApplication::restoreOverrideCursor();
+ return res;
}
data << QString( "gtTickmarkLengthX=%1" ).arg( params.gtTickmarkLengthX );
data << QString( "gtTickmarkLengthY=%1" ).arg( params.gtTickmarkLengthY );
data << QString( "gtTickmarkLengthZ=%1" ).arg( params.gtTickmarkLengthZ );
+
+ // ray tracing parameters
+ Graphic3d_RenderingParams rendParams = this->getViewPort()->getView()->RenderingParams();
+ if ( rendParams.Method == Graphic3d_RM_RAYTRACING ) {
+ QString RayTracing = "rayTracing=";
+ RayTracing += QString( "rtDepth~%1;" ).arg( rendParams.RaytracingDepth );
+ RayTracing += QString( "rtReflection~%1;" ).arg( rendParams.IsReflectionEnabled );
+ RayTracing += QString( "rtAntialiasing~%1;" ).arg( rendParams.IsAntialiasingEnabled );
+ RayTracing += QString( "rtShadow~%1;" ).arg( rendParams.IsShadowEnabled );
+ RayTracing += QString( "rtTransShadow~%1;" ).arg( rendParams.IsTransparentShadowEnabled );
+ data << RayTracing;
+ }
+
+ // environment texture parameters
+ Handle(Graphic3d_TextureEnv) aTexture = this->getViewPort()->getView()->TextureEnv();
+ if ( !aTexture.IsNull() ) {
+ QString EnvTexture = "envTexture=";
+ if ( aTexture->Name() == Graphic3d_NOT_ENV_UNKNOWN ) {
+ TCollection_AsciiString aFileName;
+ aTexture->Path().SystemName( aFileName );
+ EnvTexture += QString( "etFile~%1;" ).arg( aFileName.ToCString() );
+ }
+ else
+ EnvTexture += QString( "etNumber~%1;" ).arg( aTexture->Name() );
+ data << EnvTexture;
+ }
+
+ // light source parameters
+ myModel->getViewer3d()->InitDefinedLights();
+ while ( myModel->getViewer3d()->MoreDefinedLights() )
+ {
+ Handle(V3d_Light) aLight = myModel->getViewer3d()->DefinedLight();
+ if ( aLight->Type() != V3d_AMBIENT ) {
+ QString LightSource = QString( "lightSource=" );
+ LightSource += QString( "lightType~%1;" ).arg( aLight->Type() );
+ double aX, aY, aZ;
+ if ( aLight->Type() == V3d_DIRECTIONAL )
+ Handle(V3d_DirectionalLight)::DownCast( aLight )->Direction( aX, aY, aZ );
+ else if ( aLight->Type() == V3d_POSITIONAL )
+ Handle(V3d_PositionalLight)::DownCast( aLight )->Position( aX, aY, aZ );
+ LightSource += QString( "lightX~%1;" ).arg( aX );
+ LightSource += QString( "lightY~%1;" ).arg( aY );
+ LightSource += QString( "lightZ~%1;" ).arg( aZ );
+ LightSource += QString( "lightColorR~%1;" ).arg( aLight->Color().Red() );
+ LightSource += QString( "lightColorG~%1;" ).arg( aLight->Color().Green() );
+ LightSource += QString( "lightColorB~%1;" ).arg( aLight->Color().Blue() );
+ LightSource += QString( "lightHeadlight~%1;" ).arg( aLight->Headlight() );
+ data << LightSource;
+ }
+ myModel->getViewer3d()->NextDefinedLights();
+ }
+
QString bg = Qtx::backgroundToString( background() ).replace( "=", "$" );
data << QString( "background=%1" ).arg( bg );
else if ( paramName == "gtTickmarkLengthX" ) params.gtTickmarkLengthX = paramValue.toInt();
else if ( paramName == "gtTickmarkLengthY" ) params.gtTickmarkLengthY = paramValue.toInt();
else if ( paramName == "gtTickmarkLengthZ" ) params.gtTickmarkLengthZ = paramValue.toInt();
+ else if ( paramName == "rayTracing" )
+ {
+ Graphic3d_RenderingParams& rendParams = this->getViewPort()->getView()->ChangeRenderingParams();
+ rendParams.Method = Graphic3d_RM_RAYTRACING;
+ QStringList rtData = paramValue.split( ';' );
+ foreach( QString rtParam, rtData )
+ {
+ QString rt_paramName = rtParam.section( '~', 0, 0 ).trimmed();
+ QString rt_paramValue = rtParam.section( '~', 1, 1 ).trimmed();
+ if ( rt_paramName == "rtDepth" ) rendParams.RaytracingDepth = rt_paramValue.toInt();
+ else if ( rt_paramName == "rtReflection" ) rendParams.IsReflectionEnabled = rt_paramValue.toInt();
+ else if ( rt_paramName == "rtAntialiasing" ) rendParams.IsAntialiasingEnabled = rt_paramValue.toInt();
+ else if ( rt_paramName == "rtShadow" ) rendParams.IsShadowEnabled = rt_paramValue.toInt();
+ else if ( rt_paramName == "rtTransShadow" ) rendParams.IsTransparentShadowEnabled = rt_paramValue.toInt();
+ }
+ }
+ else if ( paramName == "envTexture" )
+ {
+ Handle(Graphic3d_TextureEnv) aTexture;
+ QStringList etData = paramValue.split( ';' );
+ foreach( QString etParam, etData )
+ {
+ QString et_paramName = etParam.section( '~', 0, 0 ).trimmed();
+ QString et_paramValue = etParam.section( '~', 1, 1 ).trimmed();
+ if ( et_paramName == "etNumber" )
+ aTexture = new Graphic3d_TextureEnv( Graphic3d_NameOfTextureEnv( et_paramValue.toInt() ) );
+ else if ( et_paramName == "etFile" )
+ aTexture = new Graphic3d_TextureEnv( TCollection_AsciiString( et_paramValue.toStdString().c_str() ) );
+ Handle(V3d_View) aView = this->getViewPort()->getView();
+ aView->SetTextureEnv( aTexture );
+ aView->SetSurfaceDetail( V3d_TEX_ENVIRONMENT );
+ }
+ }
+ else if ( paramName == "lightSource" )
+ {
+ myModel->getViewer3d()->InitDefinedLights();
+ while ( myModel->getViewer3d()->MoreDefinedLights() )
+ {
+ Handle(V3d_Light) aLight = myModel->getViewer3d()->DefinedLight();
+ if( aLight->Type() != V3d_AMBIENT )
+ myModel->getViewer3d()->DelLight( aLight );
+ myModel->getViewer3d()->NextDefinedLights();
+ }
+ double aX, aY, aZ;
+ double cR, cG, cB;
+ V3d_TypeOfLight aType;
+ bool isHeadlight;
+ QStringList lsData = paramValue.split( ';' );
+ foreach( QString lsParam, lsData )
+ {
+ QString ls_paramName = lsParam.section( '~', 0, 0 ).trimmed();
+ QString ls_paramValue = lsParam.section( '~', 1, 1 ).trimmed();
+ if ( ls_paramName == "lightType" ) aType = V3d_TypeOfLight( ls_paramValue.toInt() );
+ else if ( ls_paramName == "lightX" ) aX = ls_paramValue.toDouble();
+ else if ( ls_paramName == "lightY" ) aY = ls_paramValue.toDouble();
+ else if ( ls_paramName == "lightZ" ) aZ = ls_paramValue.toDouble();
+ else if ( ls_paramName == "lightColorR" ) cR = ls_paramValue.toDouble();
+ else if ( ls_paramName == "lightColorG" ) cG = ls_paramValue.toDouble();
+ else if ( ls_paramName == "lightColorB" ) cB = ls_paramValue.toDouble();
+ else if ( ls_paramName == "lightHeadlight" ) isHeadlight = ls_paramValue.toInt();
+ }
+ Quantity_Color aColor = Quantity_Color( cR, cG, cB, Quantity_TOC_RGB );
+ if( aType == V3d_DIRECTIONAL ) {
+ Handle(V3d_DirectionalLight) aLight = new V3d_DirectionalLight( myModel->getViewer3d() );
+ aLight->SetDirection( aX, aY, aZ );
+ aLight->SetColor( aColor );
+ aLight->SetHeadlight( isHeadlight );
+ myModel->getViewer3d()->SetLightOn( aLight );
+ }
+ else if( aType == V3d_POSITIONAL ) {
+ Handle(V3d_PositionalLight) aLight = new V3d_PositionalLight( myModel->getViewer3d(), aX, aY, aZ, aColor.Name() );
+ aLight->SetHeadlight( isHeadlight );
+ myModel->getViewer3d()->SetLightOn( aLight );
+ }
+ }
else if ( paramName == "background" ) {
QString bg = paramValue.replace( "$", "=" );
bgData = Qtx::stringToBackground( bg );
}
}
}
+
+void OCCViewer_ViewWindow::onRayTracing()
+{
+ if( !OCCViewer_Utilities::isDialogOpened( this, OCCViewer_RayTracingDlg::getName() ) ) {
+ QDialog* aDlg = new OCCViewer_RayTracingDlg( this );
+ if ( aDlg != NULL )
+ aDlg->show();
+ }
+}
+
+void OCCViewer_ViewWindow::onEnvTexture()
+{
+ if( !OCCViewer_Utilities::isDialogOpened( this, OCCViewer_EnvTextureDlg::getName() ) ) {
+ QDialog* aDlg = new OCCViewer_EnvTextureDlg( this );
+ if ( aDlg != NULL )
+ aDlg->show();
+ }
+}
+
+void OCCViewer_ViewWindow::onLightSource()
+{
+ if( !OCCViewer_Utilities::isDialogOpened( this, OCCViewer_LightSourceDlg::getName() ) ) {
+ QDialog* aDlg = new OCCViewer_LightSourceDlg( this, myModel );
+ if ( aDlg != NULL )
+ aDlg->show();
+ }
+}
SwitchInteractionStyleId, SwitchZoomingStyleId,
SwitchPreselectionId, SwitchSelectionId,
MaximizedId, SynchronizeId, ReturnTo3dViewId,
- OrthographicId, PerspectiveId, StereoId,
+ OrthographicId, PerspectiveId, StereoId, RayTracingId, EnvTextureId, LightSourceId,
UserId };
enum OperationType{ NOTHING, PANVIEW, ZOOMVIEW, ROTATE,
virtual void onSwitchZoomingStyle( bool on );
virtual void onSwitchPreselection( bool on );
virtual void onSwitchSelection( bool on );
+ virtual void onRayTracing();
+ virtual void onEnvTexture();
+ virtual void onLightSource();
virtual void activateSetRotationGravity();
virtual void activateSetRotationSelected( double theX, double theY, double theZ );
<source>ICON_OCCVIEWER_STEREO</source>
<translation>occ_view_stereo.png</translation>
</message>
+ <message>
+ <source>ICON_OCCVIEWER_RAY_TRACING</source>
+ <translation>occ_view_ray_tracing.png</translation>
+ </message>
+ <message>
+ <source>ICON_OCCVIEWER_ENV_TEXTURE</source>
+ <translation>occ_view_env_texture.png</translation>
+ </message>
+ <message>
+ <source>ICON_OCCVIEWER_LIGHT_SOURCE</source>
+ <translation>occ_view_light_source.png</translation>
+ </message>
</context>
</TS>
<source>DSC_RETURN_3D_VIEW</source>
<translation>Return to 3D view</translation>
</message>
+ <message>
+ <source>MNU_RAY_TRACING</source>
+ <translation>Ray tracing</translation>
+ </message>
+ <message>
+ <source>DSC_RAY_TRACING</source>
+ <translation>Ray tracing</translation>
+ </message>
+ <message>
+ <source>MNU_ENV_TEXTURE</source>
+ <translation>Environment texture</translation>
+ </message>
+ <message>
+ <source>DSC_ENV_TEXTURE</source>
+ <translation>Environment texture</translation>
+ </message>
+ <message>
+ <source>MNU_LIGHT_SOURCE</source>
+ <translation>Light source</translation>
+ </message>
+ <message>
+ <source>DSC_LIGHT_SOURCE</source>
+ <translation>Light source</translation>
+ </message>
<message>
<source>OCC_IMAGE_FILES</source>
<translation>Images Files (*.bmp *.png *.jpg *.jpeg *.eps *.ps)</translation>
<translation>&Help</translation>
</message>
</context>
+<context>
+ <name>OCCViewer_RayTracingDlg</name>
+ <message>
+ <source>RAY_TRACING</source>
+ <translation>Ray tracing</translation>
+ </message>
+ <message>
+ <source>DEPTH</source>
+ <translation>Depth</translation>
+ </message>
+ <message>
+ <source>SHADOW</source>
+ <translation>Shadows rendering</translation>
+ </message>
+ <message>
+ <source>REFLECTION</source>
+ <translation>Specular reflections</translation>
+ </message>
+ <message>
+ <source>ANTIALIASING</source>
+ <translation>Adaptive anti-aliasing</translation>
+ </message>
+ <message>
+ <source>TRANSPARENT_SHADOW</source>
+ <translation>Transparent shadow</translation>
+ </message>
+</context>
+<context>
+ <name>OCCViewer_EnvTextureDlg</name>
+ <message>
+ <source>ENV_TEXTURE</source>
+ <translation>Environment texture</translation>
+ </message>
+ <message>
+ <source>ENV_CLOUDS</source>
+ <translation>Clouds</translation>
+ </message>
+ <message>
+ <source>ENV_CV</source>
+ <translation>Cv</translation>
+ </message>
+ <message>
+ <source>ENV_MEDIT</source>
+ <translation>Medit</translation>
+ </message>
+ <message>
+ <source>ENV_PEARL</source>
+ <translation>Pearl</translation>
+ </message>
+ <message>
+ <source>ENV_SKY1</source>
+ <translation>Sky1</translation>
+ </message>
+ <message>
+ <source>ENV_SKY2</source>
+ <translation>Sky2</translation>
+ </message>
+ <message>
+ <source>ENV_LINES</source>
+ <translation>Lines</translation>
+ </message>
+ <message>
+ <source>ENV_ROAD</source>
+ <translation>Road</translation>
+ </message>
+ <message>
+ <source>ENV_CUSTOM</source>
+ <translation>Custom...</translation>
+ </message>
+</context>
+<context>
+ <name>OCCViewer_LightSourceDlg</name>
+ <message>
+ <source>LIGHT_SOURCE</source>
+ <translation>Light source</translation>
+ </message>
+ <message>
+ <source>TYPE</source>
+ <translation>Type</translation>
+ </message>
+ <message>
+ <source>DIRECTIONAL</source>
+ <translation>Directional</translation>
+ </message>
+ <message>
+ <source>DIRECTION</source>
+ <translation>Direction</translation>
+ </message>
+ <message>
+ <source>POSITIONAL</source>
+ <translation>Positional</translation>
+ </message>
+ <message>
+ <source>POSITION</source>
+ <translation>Position</translation>
+ </message>
+ <message>
+ <source>COLOR</source>
+ <translation>Color</translation>
+ </message>
+ <message>
+ <source>HEADLIGHT</source>
+ <translation>Headlight</translation>
+ </message>
+ <message>
+ <source>BUT_DEFAULT</source>
+ <translation>Default</translation>
+ </message>
+</context>
</TS>
<source>DSC_RETURN_3D_VIEW</source>
<translation>Retour à la vue 3D</translation>
</message>
+ <message>
+ <source>MNU_RAY_TRACING</source>
+ <translation type="unfinished">Ray tracing</translation>
+ </message>
+ <message>
+ <source>DSC_RAY_TRACING</source>
+ <translation type="unfinished">Ray tracing</translation>
+ </message>
+ <message>
+ <source>MNU_ENV_TEXTURE</source>
+ <translation type="unfinished">Environment texture</translation>
+ </message>
+ <message>
+ <source>DSC_ENV_TEXTURE</source>
+ <translation type="unfinished">Environment texture</translation>
+ </message>
+ <message>
+ <source>MNU_LIGHT_SOURCE</source>
+ <translation type="unfinished">Light source</translation>
+ </message>
+ <message>
+ <source>DSC_LIGHT_SOURCE</source>
+ <translation type="unfinished">Light source</translation>
+ </message>
<message>
<source>OCC_IMAGE_FILES</source>
<translation>Fichiers images (*.bmp *.png *.jpg *.jpeg *.eps *.ps)</translation>
<translation>Ai&de</translation>
</message>
</context>
+<context>
+ <name>OCCViewer_RayTracingDlg</name>
+ <message>
+ <source>RAY_TRACING</source>
+ <translation type="unfinished">Ray tracing</translation>
+ </message>
+ <message>
+ <source>DEPTH</source>
+ <translation type="unfinished">Depth</translation>
+ </message>
+ <message>
+ <source>SHADOW</source>
+ <translation type="unfinished">Shadows rendering</translation>
+ </message>
+ <message>
+ <source>REFLECTION</source>
+ <translation type="unfinished">Specular reflections</translation>
+ </message>
+ <message>
+ <source>ANTIALIASING</source>
+ <translation type="unfinished">Adaptive anti-aliasing</translation>
+ </message>
+ <message>
+ <source>TRANSPARENT_SHADOW</source>
+ <translation type="unfinished">Transparent shadow</translation>
+ </message>
+</context>
+<context>
+ <name>OCCViewer_EnvTextureDlg</name>
+ <message>
+ <source>ENV_TEXTURE</source>
+ <translation type="unfinished">Environment texture</translation>
+ </message>
+ <message>
+ <source>ENV_CLOUDS</source>
+ <translation type="unfinished">Clouds</translation>
+ </message>
+ <message>
+ <source>ENV_CV</source>
+ <translation type="unfinished">Cv</translation>
+ </message>
+ <message>
+ <source>ENV_MEDIT</source>
+ <translation type="unfinished">Medit</translation>
+ </message>
+ <message>
+ <source>ENV_PEARL</source>
+ <translation type="unfinished">Pearl</translation>
+ </message>
+ <message>
+ <source>ENV_SKY1</source>
+ <translation type="unfinished">Sky1</translation>
+ </message>
+ <message>
+ <source>ENV_SKY2</source>
+ <translation type="unfinished">Sky2</translation>
+ </message>
+ <message>
+ <source>ENV_LINES</source>
+ <translation type="unfinished">Lines</translation>
+ </message>
+ <message>
+ <source>ENV_ROAD</source>
+ <translation type="unfinished">Road</translation>
+ </message>
+ <message>
+ <source>ENV_CUSTOM</source>
+ <translation type="unfinished">Custom...</translation>
+ </message>
+</context>
+<context>
+ <name>OCCViewer_LightSourceDlg</name>
+ <message>
+ <source>LIGHT_SOURCE</source>
+ <translation type="unfinished">Light source</translation>
+ </message>
+ <message>
+ <source>TYPE</source>
+ <translation type="unfinished">Type</translation>
+ </message>
+ <message>
+ <source>DIRECTIONAL</source>
+ <translation type="unfinished">Directional</translation>
+ </message>
+ <message>
+ <source>DIRECTION</source>
+ <translation type="unfinished">Direction</translation>
+ </message>
+ <message>
+ <source>POSITIONAL</source>
+ <translation type="unfinished">Positional</translation>
+ </message>
+ <message>
+ <source>POSITION</source>
+ <translation type="unfinished">Position</translation>
+ </message>
+ <message>
+ <source>COLOR</source>
+ <translation type="unfinished">Color</translation>
+ </message>
+ <message>
+ <source>HEADLIGHT</source>
+ <translation type="unfinished">Headlight</translation>
+ </message>
+ <message>
+ <source>BUT_DEFAULT</source>
+ <translation type="unfinished">Default</translation>
+ </message>
+</context>
</TS>
<source>MNU_RETURN_3D_VIEW</source>
<translation>3D に戻る</translation>
</message>
+ <message>
+ <source>MNU_RAY_TRACING</source>
+ <translation type="unfinished">Ray tracing</translation>
+ </message>
+ <message>
+ <source>DSC_RAY_TRACING</source>
+ <translation type="unfinished">Ray tracing</translation>
+ </message>
+ <message>
+ <source>MNU_ENV_TEXTURE</source>
+ <translation type="unfinished">Environment texture</translation>
+ </message>
+ <message>
+ <source>DSC_ENV_TEXTURE</source>
+ <translation type="unfinished">Environment texture</translation>
+ </message>
+ <message>
+ <source>MNU_LIGHT_SOURCE</source>
+ <translation type="unfinished">Light source</translation>
+ </message>
+ <message>
+ <source>DSC_LIGHT_SOURCE</source>
+ <translation type="unfinished">Light source</translation>
+ </message>
<message>
<source>DSC_RETURN_3D_VIEW</source>
<translation>3D view に戻る</translation>
<translation>ヘルプ(&H)</translation>
</message>
</context>
+ <context>
+ <name>OCCViewer_RayTracingDlg</name>
+ <message>
+ <source>RAY_TRACING</source>
+ <translation type="unfinished">Ray tracing</translation>
+ </message>
+ <message>
+ <source>DEPTH</source>
+ <translation type="unfinished">Depth</translation>
+ </message>
+ <message>
+ <source>SHADOW</source>
+ <translation type="unfinished">Shadows rendering</translation>
+ </message>
+ <message>
+ <source>REFLECTION</source>
+ <translation type="unfinished">Specular reflections</translation>
+ </message>
+ <message>
+ <source>ANTIALIASING</source>
+ <translation type="unfinished">Adaptive anti-aliasing</translation>
+ </message>
+ <message>
+ <source>TRANSPARENT_SHADOW</source>
+ <translation type="unfinished">Transparent shadow</translation>
+ </message>
+ </context>
+ <context>
+ <name>OCCViewer_EnvTextureDlg</name>
+ <message>
+ <source>ENV_TEXTURE</source>
+ <translation type="unfinished">Environment texture</translation>
+ </message>
+ <message>
+ <source>ENV_CLOUDS</source>
+ <translation type="unfinished">Clouds</translation>
+ </message>
+ <message>
+ <source>ENV_CV</source>
+ <translation type="unfinished">Cv</translation>
+ </message>
+ <message>
+ <source>ENV_MEDIT</source>
+ <translation type="unfinished">Medit</translation>
+ </message>
+ <message>
+ <source>ENV_PEARL</source>
+ <translation type="unfinished">Pearl</translation>
+ </message>
+ <message>
+ <source>ENV_SKY1</source>
+ <translation type="unfinished">Sky1</translation>
+ </message>
+ <message>
+ <source>ENV_SKY2</source>
+ <translation type="unfinished">Sky2</translation>
+ </message>
+ <message>
+ <source>ENV_LINES</source>
+ <translation type="unfinished">Lines</translation>
+ </message>
+ <message>
+ <source>ENV_ROAD</source>
+ <translation type="unfinished">Road</translation>
+ </message>
+ <message>
+ <source>ENV_CUSTOM</source>
+ <translation>Custom...</translation>
+ </message>
+ </context>
+ <context>
+ <name>OCCViewer_LightSourceDlg</name>
+ <message>
+ <source>LIGHT_SOURCE</source>
+ <translation type="unfinished">Light source</translation>
+ </message>
+ <message>
+ <source>TYPE</source>
+ <translation type="unfinished">Type</translation>
+ </message>
+ <message>
+ <source>DIRECTIONAL</source>
+ <translation type="unfinished">Directional</translation>
+ </message>
+ <message>
+ <source>DIRECTION</source>
+ <translation type="unfinished">Direction</translation>
+ </message>
+ <message>
+ <source>POSITIONAL</source>
+ <translation type="unfinished">Positional</translation>
+ </message>
+ <message>
+ <source>POSITION</source>
+ <translation type="unfinished">Position</translation>
+ </message>
+ <message>
+ <source>COLOR</source>
+ <translation type="unfinished">Color</translation>
+ </message>
+ <message>
+ <source>HEADLIGHT</source>
+ <translation type="unfinished">Headlight</translation>
+ </message>
+ <message>
+ <source>BUT_DEFAULT</source>
+ <translation type="unfinished">Default</translation>
+ </message>
+ </context>
</TS>