From 4cd15d4b28dfac406c3709789d07ff955db43d32 Mon Sep 17 00:00:00 2001 From: skv Date: Fri, 29 Jul 2016 11:26:23 +0300 Subject: [PATCH] Porting on OCCT7.0.1: persistence --- CMakeLists.txt | 9 ++++- src/CMakeLists.txt | 5 ++- src/OCCViewer/CMakeLists.txt | 4 +- src/OCCViewer/OCCViewer.cxx | 47 ++++++++++++++++++++++ src/OCCViewer/OCCViewer.h | 10 +++++ src/OCCViewer/OCCViewer_EnvTextureDlg.cxx | 14 +++++++ src/OCCViewer/OCCViewer_EnvTextureDlg.h | 5 +++ src/OCCViewer/OCCViewer_LightSourceDlg.cxx | 10 ++--- src/OCCViewer/OCCViewer_VService.cxx | 6 +++ src/OCCViewer/OCCViewer_ViewFrame.cxx | 2 + src/OCCViewer/OCCViewer_ViewModel.cxx | 7 ++-- src/OCCViewer/OCCViewer_ViewWindow.cxx | 2 + 12 files changed, 109 insertions(+), 12 deletions(-) create mode 100644 src/OCCViewer/OCCViewer.cxx mode change 100755 => 100644 src/OCCViewer/OCCViewer.h mode change 100755 => 100644 src/OCCViewer/OCCViewer_VService.cxx mode change 100755 => 100644 src/OCCViewer/OCCViewer_ViewModel.cxx mode change 100755 => 100644 src/OCCViewer/OCCViewer_ViewWindow.cxx diff --git a/CMakeLists.txt b/CMakeLists.txt index 1ef75e6b8..e65f907d7 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -325,11 +325,18 @@ INCLUDE(CMakePackageConfigHelpers) # List of targets in this project we want to make visible to the rest of the world. # They all have to be INSTALL'd with the option "EXPORT ${PROJECT_NAME}TargetGroup" SET(_${PROJECT_NAME}_exposed_targets - caf CAM CASCatch DDS Event LightApp LogWindow ObjBrowser + CAM CASCatch DDS Event LightApp LogWindow ObjBrowser QDS qtx SalomePrs SalomeStyle std SUITApp suit ViewerTools ViewerData ImageComposer ) +# CAF package (not compilable while TDocStd_Application::Formats is removed) +MESSAGE( STATUS "CAS_VERSION_STR: " ${CAS_VERSION_STR} ) +IF(CAS_VERSION_STR VERSION_LESS "7.0.1") + LIST(APPEND _${PROJECT_NAME}_exposed_targets + caf) +ENDIF() + IF(SALOME_USE_OCCVIEWER OR SALOME_USE_VTKVIEWER OR SALOME_USE_GLVIEWER) LIST(APPEND _${PROJECT_NAME}_exposed_targets OpenGLUtils) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d1ebdb032..f7161a9cc 100755 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -32,7 +32,10 @@ ADD_SUBDIRECTORY(ObjBrowser) ADD_SUBDIRECTORY(SUIT) ADD_SUBDIRECTORY(SUITApp) ADD_SUBDIRECTORY(STD) -ADD_SUBDIRECTORY(CAF) +# CAF package (not compilable while TDocStd_Application::Formats is removed) +IF(CAS_VERSION_STR VERSION_LESS "7.0.1") + ADD_SUBDIRECTORY(CAF) +ENDIF() ADD_SUBDIRECTORY(CAM) ADD_SUBDIRECTORY(LogWindow) ADD_SUBDIRECTORY(Prs) diff --git a/src/OCCViewer/CMakeLists.txt b/src/OCCViewer/CMakeLists.txt index 528be766b..837b6f2c0 100755 --- a/src/OCCViewer/CMakeLists.txt +++ b/src/OCCViewer/CMakeLists.txt @@ -36,7 +36,6 @@ INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/src/ViewerData ${PROJECT_SOURCE_DIR}/src/ViewerTools ${PROJECT_SOURCE_DIR}/src/OpenGLUtils - ${PROJECT_SOURCE_DIR}/src/CAF ) # additional preprocessor / compiler flags @@ -46,7 +45,7 @@ ADD_DEFINITIONS(${QT_DEFINITIONS} ${CAS_DEFINITIONS} ${OGL_DEFINITIONS}) 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 caf + CASCatch qtx suit ViewerTools ViewerData OpenGLUtils ) # --- headers --- @@ -159,6 +158,7 @@ QT_ADD_RESOURCES(_rcc_SOURCES ${_rcc_RESOURCES}) # sources / static SET(_other_SOURCES + OCCViewer.cxx OCCViewer_AISSelector.cxx OCCViewer_AxialScaleDlg.cxx OCCViewer_ClippingDlg.cxx diff --git a/src/OCCViewer/OCCViewer.cxx b/src/OCCViewer/OCCViewer.cxx new file mode 100644 index 000000000..2293972a4 --- /dev/null +++ b/src/OCCViewer/OCCViewer.cxx @@ -0,0 +1,47 @@ +// Copyright (C) 2015-2016 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.h" + +/*! + \brief Convert QColor object to Quantity_Color object. + \param c color object in Qt format + \return color object in OCC format +*/ +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; +} + +/*! + \brief Convert Quantity_Color object to QColor object. + \param c color object in OCC format + \return color object in Qt format +*/ +QColor OCCViewer::color( const Quantity_Color& c ) +{ + return QColor ( int( c.Red() * 255 ), + int( c.Green() * 255 ), + int( c.Blue() * 255 ) ); +} diff --git a/src/OCCViewer/OCCViewer.h b/src/OCCViewer/OCCViewer.h old mode 100755 new mode 100644 index bafdba426..7a3139d00 --- a/src/OCCViewer/OCCViewer.h +++ b/src/OCCViewer/OCCViewer.h @@ -37,4 +37,14 @@ #pragma warning ( disable: 4251 ) #endif +#include + +#include + +namespace OCCViewer +{ + OCCVIEWER_EXPORT Quantity_Color color( const QColor& ); + OCCVIEWER_EXPORT QColor color( const Quantity_Color& ); +}; + #endif //OCCVIEWER_H diff --git a/src/OCCViewer/OCCViewer_EnvTextureDlg.cxx b/src/OCCViewer/OCCViewer_EnvTextureDlg.cxx index 958cb4870..b6e952481 100644 --- a/src/OCCViewer/OCCViewer_EnvTextureDlg.cxx +++ b/src/OCCViewer/OCCViewer_EnvTextureDlg.cxx @@ -169,7 +169,11 @@ void OCCViewer_EnvTextureDlg::onEnvTexture( bool theIsChecked ) onTextureChanged(); else { Handle(Graphic3d_TextureEnv) aTexture; +#if OCC_VERSION_LARGE > 0x07000000 + setEnvTexture( aTexture ); +#else setEnvTexture( aTexture, V3d_TEX_ALL ); +#endif } } @@ -196,7 +200,11 @@ void OCCViewer_EnvTextureDlg::onTextureChanged() << Graphic3d_NOT_ENV_LINES << Graphic3d_NOT_ENV_ROAD; aTexture = new Graphic3d_TextureEnv( aTextures.at( myEnvTextureId->currentIndex() ) ); } +#if OCC_VERSION_LARGE > 0x07000000 + setEnvTexture( aTexture ); +#else setEnvTexture( aTexture, V3d_TEX_ENVIRONMENT ); +#endif } /*! @@ -224,13 +232,19 @@ void OCCViewer_EnvTextureDlg::ClickOnHelp() /*! Sets current texture environment for all view in the viewer */ +#if OCC_VERSION_LARGE > 0x07000000 +void OCCViewer_EnvTextureDlg::setEnvTexture( Handle(Graphic3d_TextureEnv) theTexture) +#else void OCCViewer_EnvTextureDlg::setEnvTexture( Handle(Graphic3d_TextureEnv) theTexture, V3d_TypeOfSurfaceDetail theMode ) +#endif { 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 ); +#if OCC_VERSION_LARGE <= 0x07000000 aView->SetSurfaceDetail( theMode ); +#endif aView->Redraw(); } } diff --git a/src/OCCViewer/OCCViewer_EnvTextureDlg.h b/src/OCCViewer/OCCViewer_EnvTextureDlg.h index db345a03a..d06c67985 100644 --- a/src/OCCViewer/OCCViewer_EnvTextureDlg.h +++ b/src/OCCViewer/OCCViewer_EnvTextureDlg.h @@ -23,6 +23,7 @@ #include "OCCViewer.h" #include #include +#include class OCCViewer_ViewWindow; class OCCViewer_ViewFrame; @@ -50,7 +51,11 @@ private slots: private: void initParam(); +#if OCC_VERSION_LARGE > 0x07000000 + void setEnvTexture( Handle(Graphic3d_TextureEnv) ); +#else void setEnvTexture( Handle(Graphic3d_TextureEnv), V3d_TypeOfSurfaceDetail ); +#endif OCCViewer_ViewFrame* myViewFrame; Handle(V3d_View) myView3d; diff --git a/src/OCCViewer/OCCViewer_LightSourceDlg.cxx b/src/OCCViewer/OCCViewer_LightSourceDlg.cxx index 20afd9cb5..2247273c5 100644 --- a/src/OCCViewer/OCCViewer_LightSourceDlg.cxx +++ b/src/OCCViewer/OCCViewer_LightSourceDlg.cxx @@ -19,12 +19,12 @@ // internal includes #include "OCCViewer_LightSourceDlg.h" +#include "OCCViewer.h" #include "OCCViewer_ViewWindow.h" #include "OCCViewer_ViewModel.h" // GUI includes #include -#include #include #include @@ -304,7 +304,7 @@ void OCCViewer_LightSourceDlg::initParam( bool theIsDefault ) double aX, aY, aZ; Quantity_Color aColor = aLight->Color(); if( myDirType->isChecked() ) { - myDirColor->setColor( CAF_Tools::color( aColor ) ); + myDirColor->setColor( OCCViewer::color( aColor ) ); myDirLight->Direction( aX, aY, aZ ); myDx->setValue( aX ); myDy->setValue( aY ); @@ -312,7 +312,7 @@ void OCCViewer_LightSourceDlg::initParam( bool theIsDefault ) myDirHeadLight->setChecked( myDirLight->Headlight() ); } else if( myPosType->isChecked() ) { - myPosColor->setColor( CAF_Tools::color( aColor ) ); + myPosColor->setColor( OCCViewer::color( aColor ) ); myPosLight->Position( aX, aY, aZ ); myX->setValue( aX ); myY->setValue( aY ); @@ -356,7 +356,7 @@ void OCCViewer_LightSourceDlg::onDirChanged() 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->SetColor( OCCViewer::color( myDirColor->color() ) ); myDirLight->SetHeadlight( myDirHeadLight->isChecked() ); myModel->getViewer3d()->SetLightOn( myDirLight ); } @@ -372,7 +372,7 @@ void OCCViewer_LightSourceDlg::onPosChanged() return; myModel->getViewer3d()->SetLightOff( myPosLight ); myPosLight->SetPosition( myX->value(), myY->value(), myZ->value() ); - myPosLight->SetColor( CAF_Tools::color( myPosColor->color() ) ); + myPosLight->SetColor( OCCViewer::color( myPosColor->color() ) ); myPosLight->SetHeadlight( myPosHeadLight->isChecked() ); myModel->getViewer3d()->SetLightOn( myPosLight ); myModel->getViewer3d()->UpdateLights(); diff --git a/src/OCCViewer/OCCViewer_VService.cxx b/src/OCCViewer/OCCViewer_VService.cxx old mode 100755 new mode 100644 index c6c1bf9e0..ec09bc0a9 --- a/src/OCCViewer/OCCViewer_VService.cxx +++ b/src/OCCViewer/OCCViewer_VService.cxx @@ -87,7 +87,13 @@ Handle(V3d_Viewer) OCCViewer_VService::CreateViewer( const Standard_ExtString na #endif } +#if OCC_VERSION_LARGE > 0x07000000 + return new V3d_Viewer( aGraphicDriver, name, domain, viewSize, viewProjection, + Quantity_NOC_GRAY30, V3d_ZBUFFER, V3d_GOURAUD, V3d_WAIT, + computedMode, defaultComputedMode ); +#else return new V3d_Viewer( aGraphicDriver, name, domain, viewSize, viewProjection, Quantity_NOC_GRAY30, V3d_ZBUFFER, V3d_GOURAUD, V3d_WAIT, computedMode, defaultComputedMode, V3d_TEX_NONE ); +#endif } diff --git a/src/OCCViewer/OCCViewer_ViewFrame.cxx b/src/OCCViewer/OCCViewer_ViewFrame.cxx index 1b5fb4daa..222a292bc 100644 --- a/src/OCCViewer/OCCViewer_ViewFrame.cxx +++ b/src/OCCViewer/OCCViewer_ViewFrame.cxx @@ -186,7 +186,9 @@ void OCCViewer_ViewFrame::setSubViewParams( OCCViewer_ViewWindow* theView ) // set environment texture parameters aView->SetTextureEnv( aMainView->TextureEnv() ); +#if OCC_VERSION_LARGE <= 0x07000000 aView->SetSurfaceDetail( aMainView->SurfaceDetail() ); +#endif } void OCCViewer_ViewFrame::splitSubViews() diff --git a/src/OCCViewer/OCCViewer_ViewModel.cxx b/src/OCCViewer/OCCViewer_ViewModel.cxx old mode 100755 new mode 100644 index 706d2320d..2aee70481 --- a/src/OCCViewer/OCCViewer_ViewModel.cxx +++ b/src/OCCViewer/OCCViewer_ViewModel.cxx @@ -21,6 +21,7 @@ // #include "OCCViewer_ViewModel.h" +#include "OCCViewer.h" #include "OCCViewer_ViewWindow.h" #include "OCCViewer_ViewFrame.h" #include "OCCViewer_VService.h" @@ -36,8 +37,6 @@ #include "ViewerData_AISShape.hxx" -#include "CAF_Tools.h" - #include #include "QtxActionToolMgr.h" @@ -263,7 +262,9 @@ void OCCViewer_Viewer::initView( OCCViewer_ViewWindow* view ) OCCViewer_ViewPort3d* vp3d = view->getViewPort(); if ( vp3d ) { +#if OCC_VERSION_LARGE <= 0x07000000 vp3d->getView()->SetSurfaceDetail(V3d_TEX_ALL); +#endif // connect signal from viewport connect(vp3d, SIGNAL(vpClosed(OCCViewer_ViewPort3d*)), this, SLOT(onViewClosed(OCCViewer_ViewPort3d*))); connect(vp3d, SIGNAL(vpMapped(OCCViewer_ViewPort3d*)), this, SLOT(onViewMapped(OCCViewer_ViewPort3d*))); @@ -1109,7 +1110,7 @@ void OCCViewer_Viewer::setDefaultLights() 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 ); + new V3d_DirectionalLight( myV3dViewer, V3d_Zneg, OCCViewer::color( aColor ).Name(), Standard_True ); if( !( aDx == 0 && aDy == 0 && aDz == 0 ) ) aLight->SetDirection( aDx, aDy, aDz ); myV3dViewer->SetLightOn( aLight ); diff --git a/src/OCCViewer/OCCViewer_ViewWindow.cxx b/src/OCCViewer/OCCViewer_ViewWindow.cxx old mode 100755 new mode 100644 index 704fe6971..7a1ae0797 --- a/src/OCCViewer/OCCViewer_ViewWindow.cxx +++ b/src/OCCViewer/OCCViewer_ViewWindow.cxx @@ -2785,7 +2785,9 @@ void OCCViewer_ViewWindow::setVisualParameters( const QString& parameters ) aTexture = new Graphic3d_TextureEnv( TCollection_AsciiString( et_paramValue.toStdString().c_str() ) ); Handle(V3d_View) aView = this->getViewPort()->getView(); aView->SetTextureEnv( aTexture ); +#if OCC_VERSION_LARGE <= 0x07000000 aView->SetSurfaceDetail( V3d_TEX_ENVIRONMENT ); +#endif } } else if ( paramName == "lightSource" ) -- 2.39.2