From 979a4c40464cbf938be6afbc9dbdf94fcb01b1cb Mon Sep 17 00:00:00 2001 From: asl Date: Thu, 27 Apr 2006 12:51:32 +0000 Subject: [PATCH] doxygen comments --- src/OCCViewer/OCCViewer_ClippingDlg.cxx | 124 +- src/OCCViewer/OCCViewer_ClippingDlg.h | 8 +- .../OCCViewer_CreateRestoreViewDlg.cxx | 31 + src/OCCViewer/OCCViewer_VService.cxx | 22 - src/OCCViewer/OCCViewer_ViewManager.cxx | 18 +- src/OCCViewer/OCCViewer_ViewModel.cxx | 179 ++- src/OCCViewer/OCCViewer_ViewPort.cxx | 13 +- src/OCCViewer/OCCViewer_ViewPort.h | 4 + src/OCCViewer/OCCViewer_ViewPort3d.cxx | 10 +- src/OCCViewer/OCCViewer_ViewWindow.cxx | 175 ++- src/Prs/SALOME_Prs.cxx | 240 +-- src/Prs/SALOME_Prs.h | 76 +- src/SOCC/SOCC_Prs.cxx | 51 +- src/SOCC/SOCC_ViewModel.cxx | 1318 +++++++++-------- src/SOCC/SOCC_ViewWindow.cxx | 13 +- 15 files changed, 1185 insertions(+), 1097 deletions(-) diff --git a/src/OCCViewer/OCCViewer_ClippingDlg.cxx b/src/OCCViewer/OCCViewer_ClippingDlg.cxx index f529ec8d4..6b8507ae9 100644 --- a/src/OCCViewer/OCCViewer_ClippingDlg.cxx +++ b/src/OCCViewer/OCCViewer_ClippingDlg.cxx @@ -29,12 +29,17 @@ #include #include -//================================================================================= -// class : OCCViewer_ClippingDlg() -// purpose : -//================================================================================= +/*! + Constructor + \param view - view window + \param parent - parent widget + \param name - dialog name + \param modal - is this dialog modal + \param fl - flags +*/ OCCViewer_ClippingDlg::OCCViewer_ClippingDlg( OCCViewer_ViewWindow* view, QWidget* parent, const char* name, bool modal, WFlags fl ) - : QDialog( parent, "OCCViewer_ClippingDlg", modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ), myView( view ) +: QDialog( parent, "OCCViewer_ClippingDlg", modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ), + myView( view ) { setCaption( tr( "Clipping" ) ); @@ -191,20 +196,19 @@ OCCViewer_ClippingDlg::OCCViewer_ClippingDlg( OCCViewer_ViewWindow* view, QWidge myBusy = false; } -//================================================================================= -// function : ~ OCCViewer_ClippingDlg() -// purpose : Destroys the object and frees any allocated resources -//================================================================================= +/*! + Destructor + Destroys the object and frees any allocated resources +*/ OCCViewer_ClippingDlg::~ OCCViewer_ClippingDlg() { // no need to delete child widgets, Qt does it all for us } -//================================================================================= -// function : closeEvent -// purpose : -//================================================================================= +/*! + Custom handling of close event: erases preview +*/ void OCCViewer_ClippingDlg::closeEvent( QCloseEvent* e ) { erasePreview(); @@ -221,10 +225,9 @@ void OCCViewer_ClippingDlg::closeEvent( QCloseEvent* e ) } -//================================================================================= -// function : showEvent -// purpose : -//================================================================================= +/*! + Custom handling of show event: displays preview +*/ void OCCViewer_ClippingDlg::showEvent( QShowEvent* e ) { ReserveClippingPlane(); @@ -234,10 +237,9 @@ void OCCViewer_ClippingDlg::showEvent( QShowEvent* e ) } -//================================================================================= -// function : hideEvent -// purpose : -//================================================================================= +/*! + Custom handling of hide event: erases preview +*/ void OCCViewer_ClippingDlg::hideEvent( QHideEvent* e ) { erasePreview(); @@ -245,10 +247,9 @@ void OCCViewer_ClippingDlg::hideEvent( QHideEvent* e ) } -//================================================================================= -// function : ClickOnClose() -// purpose : -//================================================================================= +/*! + SLOT on close button click: erases preview and rejects dialog +*/ void OCCViewer_ClippingDlg::ClickOnClose() { erasePreview(); @@ -265,10 +266,9 @@ void OCCViewer_ClippingDlg::ClickOnClose() } -//================================================================================= -// function : ClickOnApply() -// purpose : -//================================================================================= +/*! + SLOT on apply button click: sets cutting plane +*/ void OCCViewer_ClippingDlg::ClickOnApply() { qApp->processEvents(); @@ -285,11 +285,9 @@ void OCCViewer_ClippingDlg::ClickOnApply() ReserveClippingPlane(); } - -//================================================================================= -// function : onReset() -// purpose : -//================================================================================= +/*! + SLOT on reset button click: sets default values +*/ void OCCViewer_ClippingDlg::onReset() { myBusy = true; @@ -305,11 +303,9 @@ void OCCViewer_ClippingDlg::onReset() } } - -//================================================================================= -// function : onInvert() -// purpose : -//================================================================================= +/*! + SLOT on invert button click: inverts normal of cutting plane +*/ void OCCViewer_ClippingDlg::onInvert() { double Dx = SpinBox_Dx->value(); @@ -329,11 +325,9 @@ void OCCViewer_ClippingDlg::onInvert() } } - -//================================================================================= -// function : onModeChanged() -// purpose : -//================================================================================= +/*! + SLOT: called on mode changed +*/ void OCCViewer_ClippingDlg::onModeChanged( int mode ) { bool isUserMode = (mode==0); @@ -395,10 +389,9 @@ void OCCViewer_ClippingDlg::onModeChanged( int mode ) } -//================================================================ -// Function : displayPreview -// Purpose : -//================================================================ +/*! + Displays preview of clipping plane +*/ void OCCViewer_ClippingDlg::displayPreview() { if ( myBusy || !isValid() ) @@ -473,10 +466,9 @@ void OCCViewer_ClippingDlg::displayPreview() } -//================================================================ -// Function : erasePreview -// Purpose : -//================================================================ +/*! + Erases preview of clipping plane +*/ void OCCViewer_ClippingDlg::erasePreview () { OCCViewer_Viewer* anOCCViewer = (OCCViewer_Viewer*)myView->getViewManager()->getViewModel(); @@ -496,10 +488,9 @@ void OCCViewer_ClippingDlg::erasePreview () } -//================================================================ -// Function : onValueChanged -// Purpose : -//================================================================ +/*! + SLOT: called on value changes (co-ordinates of point or normal) +*/ void OCCViewer_ClippingDlg::onValueChanged() { if ( PreviewChB->isChecked() ) @@ -510,10 +501,9 @@ void OCCViewer_ClippingDlg::onValueChanged() } -//================================================================ -// Function : onPreview -// Purpose : -//================================================================ +/*! + SLOT: called on preview check box toggled +*/ void OCCViewer_ClippingDlg::onPreview( bool on ) { erasePreview(); @@ -522,19 +512,17 @@ void OCCViewer_ClippingDlg::onPreview( bool on ) displayPreview(); } -//================================================================ -// Function : onPreview -// Purpose : -//================================================================ +/*! + \return true if plane parameters are valid +*/ bool OCCViewer_ClippingDlg::isValid() { return ( SpinBox_Dx->value()!=0 || SpinBox_Dy->value()!=0 || SpinBox_Dz->value()!=0 ); } -//================================================================ -// Function : ReserveClippingPlane -// Purpose : Remember the current clipping plane -//================================================================ +/*! + Remember the current clipping plane +*/ void OCCViewer_ClippingDlg::ReserveClippingPlane() { Handle(V3d_View) aView3d = myView->getViewPort()->getView(); diff --git a/src/OCCViewer/OCCViewer_ClippingDlg.h b/src/OCCViewer/OCCViewer_ClippingDlg.h index 44f1943b3..240048033 100644 --- a/src/OCCViewer/OCCViewer_ClippingDlg.h +++ b/src/OCCViewer/OCCViewer_ClippingDlg.h @@ -19,10 +19,10 @@ class QtxAction; class OCCViewer_ViewWindow; -//================================================================================= -// class : OCCViewer_ClippingDlg -// purpose : -//================================================================================= +/*! + \class OCCViewer_ClippingDlg + \brief Dialog allowing to assign parameters of clipping plane +*/ class OCCViewer_ClippingDlg : public QDialog { Q_OBJECT diff --git a/src/OCCViewer/OCCViewer_CreateRestoreViewDlg.cxx b/src/OCCViewer/OCCViewer_CreateRestoreViewDlg.cxx index a79d5f2c7..8e0110d33 100755 --- a/src/OCCViewer/OCCViewer_CreateRestoreViewDlg.cxx +++ b/src/OCCViewer/OCCViewer_CreateRestoreViewDlg.cxx @@ -25,6 +25,9 @@ #include #include +/*! + Constructor +*/ OCCViewer_CreateRestoreViewDlg::OCCViewer_CreateRestoreViewDlg( QWidget* aWin, OCCViewer_Viewer* curModel ) : QDialog( aWin ) { @@ -95,10 +98,17 @@ OCCViewer_CreateRestoreViewDlg::OCCViewer_CreateRestoreViewDlg( QWidget* aWin, O connect( theClearAll, SIGNAL( clicked() ), this, SLOT( clearList() ) ); } +/*! + Destructor +*/ OCCViewer_CreateRestoreViewDlg::~OCCViewer_CreateRestoreViewDlg() { } +/*! + Changes image in accordance with item + \param curItem - item contains info about view parameters +*/ void OCCViewer_CreateRestoreViewDlg::changeImage( QListBoxItem* curItem ) { if( curItem && myListBox->isEditEnabled() ) @@ -146,11 +156,17 @@ void OCCViewer_CreateRestoreViewDlg::changeImage( QListBoxItem* curItem ) } } +/*! + \return current view parameters (corresponding to current item) +*/ viewAspect OCCViewer_CreateRestoreViewDlg::currentItem() const { return myCurrentItem; } +/*! + Deletes selected items from list view +*/ void OCCViewer_CreateRestoreViewDlg::deleteSelectedItems() { if( myListBox->count() && myListBox->isEditEnabled() ) @@ -185,6 +201,9 @@ void OCCViewer_CreateRestoreViewDlg::deleteSelectedItems() } } +/*! + Clears list of view aspects +*/ void OCCViewer_CreateRestoreViewDlg::clearList() { myListBox->clear(); @@ -194,17 +213,26 @@ void OCCViewer_CreateRestoreViewDlg::clearList() myParametersMap.clear(); } +/*! + \return const reference to all view aspects const viewAspectList& OCCViewer_CreateRestoreViewDlg::parameters() const { return myParametersMap; } +/*! + Renames key of view aspect map in accordance with item name + \param anItem - item +*/ void OCCViewer_CreateRestoreViewDlg::editItemText( QListBoxItem* anItem ) { int index = anItem->listBox()->index( anItem ); myParametersMap[ index ].name = anItem->text().latin1(); } +/*! + Custom event filter +*/ bool OCCViewer_CreateRestoreViewDlg::eventFilter( QObject* anObj, QEvent* anEv ) { if( anEv->type() == QEvent::KeyPress ) @@ -234,6 +262,9 @@ bool OCCViewer_CreateRestoreViewDlg::eventFilter( QObject* anObj, QEvent* anEv ) return QWidget::eventFilter( anObj, anEv ); } +/*! + SLOT: called on OK click, emits dlgOk() and closes dialog +*/ void OCCViewer_CreateRestoreViewDlg::OKpressed() { emit dlgOk(); diff --git a/src/OCCViewer/OCCViewer_VService.cxx b/src/OCCViewer/OCCViewer_VService.cxx index 0c3deacf2..299dd6bcd 100755 --- a/src/OCCViewer/OCCViewer_VService.cxx +++ b/src/OCCViewer/OCCViewer_VService.cxx @@ -16,28 +16,6 @@ // // See http://www.salome-platform.org/ // -/*********************************************************************** - - FONCTION : - ---------- - Classe OCCViewer_VService : - - HISTORIQUE DES MODIFICATIONS : - -------------------------------- - 00-09-92 : GG ; Creation. - 25-02-98 : FMN ; PERF.27: Optimisation de la création d'une vue à partir d'une vue existante - - REMARQUES : - ----------- - -************************************************************************/ - -/*----------------------------------------------------------------------*/ -/* - * Includes - */ -//just to load the OpenGl shared library -//#include #include "OCCViewer_VService.h" #include diff --git a/src/OCCViewer/OCCViewer_ViewManager.cxx b/src/OCCViewer/OCCViewer_ViewManager.cxx index dedfc4a0d..7db1cc8a3 100755 --- a/src/OCCViewer/OCCViewer_ViewManager.cxx +++ b/src/OCCViewer/OCCViewer_ViewManager.cxx @@ -22,7 +22,9 @@ int OCCViewer_ViewManager::myMaxId = 0; -//***************************************************************/ +/*! + Constructor +*/ OCCViewer_ViewManager::OCCViewer_ViewManager( SUIT_Study* study, SUIT_Desktop* theDesktop, bool DisplayTrihedron ) : SUIT_ViewManager( study, theDesktop ) { @@ -30,19 +32,27 @@ OCCViewer_ViewManager::OCCViewer_ViewManager( SUIT_Study* study, SUIT_Desktop* t setViewModel( new OCCViewer_Viewer( DisplayTrihedron ) ); } -//***************************************************************/ +/*! + Destructor +*/ OCCViewer_ViewManager::~OCCViewer_ViewManager() { } -//***************************************************************/ +/*! + Sets view name + \param theView - view to assign name +*/ void OCCViewer_ViewManager::setViewName(SUIT_ViewWindow* theView) { int aPos = myViews.find(theView); theView->setCaption( tr( "OCC_VIEW_TITLE" ).arg( myId ).arg( aPos + 1 ) ); } -//***************************************************************/ +/*! + Fills popup menu with custom actions + \param popup - popup menu to be filled with +*/ void OCCViewer_ViewManager::contextMenuPopup( QPopupMenu* popup ) { SUIT_ViewManager::contextMenuPopup( popup ); diff --git a/src/OCCViewer/OCCViewer_ViewModel.cxx b/src/OCCViewer/OCCViewer_ViewModel.cxx index 216c9ec84..ed8f8d2ec 100755 --- a/src/OCCViewer/OCCViewer_ViewModel.cxx +++ b/src/OCCViewer/OCCViewer_ViewModel.cxx @@ -40,6 +40,10 @@ #include #include +/*! + Constructor + \param DisplayTrihedron - is trihedron displayed +*/ OCCViewer_Viewer::OCCViewer_Viewer( bool DisplayTrihedron ) : SUIT_ViewModel(), myBgColor( Qt::black ) @@ -92,22 +96,35 @@ myBgColor( Qt::black ) myMultiSelectionEnabled = true; } - +/*! + Destructor +*/ OCCViewer_Viewer::~OCCViewer_Viewer() { } +/*! + \return background color of viewer +*/ QColor OCCViewer_Viewer::backgroundColor() const { return myBgColor; } +/*! + Sets background color + \param c - new background color +*/ void OCCViewer_Viewer::setBackgroundColor( const QColor& c ) { if ( c.isValid() ) myBgColor = c; } +/*! + Start initialization of view window + \param view - view window to be initialized +*/ void OCCViewer_Viewer::initView( OCCViewer_ViewWindow* view ) { if ( view ) { @@ -119,7 +136,10 @@ void OCCViewer_Viewer::initView( OCCViewer_ViewWindow* view ) } } - +/*! + Creates new view window + \param theDesktop - main window of application +*/ SUIT_ViewWindow* OCCViewer_Viewer::createView( SUIT_Desktop* theDesktop ) { OCCViewer_ViewWindow* view = new OCCViewer_ViewWindow(theDesktop, this); @@ -127,7 +147,10 @@ SUIT_ViewWindow* OCCViewer_Viewer::createView( SUIT_Desktop* theDesktop ) return view; } -//********************************************************************* +/*! + Sets new view manager + \param theViewManager - new view manager +*/ void OCCViewer_Viewer::setViewManager(SUIT_ViewManager* theViewManager) { SUIT_ViewModel::setViewManager(theViewManager); @@ -143,15 +166,17 @@ void OCCViewer_Viewer::setViewManager(SUIT_ViewManager* theViewManager) } } - -//********************************************************************* +/*! + SLOT: called on mouse button press, stores current mouse position as start point for transformations +*/ void OCCViewer_Viewer::onMousePress(SUIT_ViewWindow* theWindow, QMouseEvent* theEvent) { myStartPnt.setX(theEvent->x()); myStartPnt.setY(theEvent->y()); } - -//********************************************************************* +/*! + SLOT: called on mouse move, processes transformation or hilighting +*/ void OCCViewer_Viewer::onMouseMove(SUIT_ViewWindow* theWindow, QMouseEvent* theEvent) { if (!mySelectionEnabled) return; @@ -163,7 +188,9 @@ void OCCViewer_Viewer::onMouseMove(SUIT_ViewWindow* theWindow, QMouseEvent* theE } -//********************************************************************* +/*! + SLOT: called on mouse button release, finishes transformation or selection +*/ void OCCViewer_Viewer::onMouseRelease(SUIT_ViewWindow* theWindow, QMouseEvent* theEvent) { if (!mySelectionEnabled) return; @@ -211,7 +238,10 @@ void OCCViewer_Viewer::onMouseRelease(SUIT_ViewWindow* theWindow, QMouseEvent* t } -//********************************************************************* +/*! + Sets selection enabled status + \param isEnabled - new status +*/ void OCCViewer_Viewer::enableSelection(bool isEnabled) { mySelectionEnabled = isEnabled; @@ -228,7 +258,10 @@ void OCCViewer_Viewer::enableSelection(bool isEnabled) } } -//********************************************************************* +/*! + Sets multiselection enabled status + \param isEnabled - new status +*/ void OCCViewer_Viewer::enableMultiselection(bool isEnable) { myMultiSelectionEnabled = isEnable; @@ -245,7 +278,9 @@ void OCCViewer_Viewer::enableMultiselection(bool isEnable) } } -//********************************************************************* +/*! + Builds popup for occ viewer +*/ void OCCViewer_Viewer::contextMenuPopup(QPopupMenu* thePopup) { thePopup->insertItem( tr( "MEN_DUMP_VIEW" ), this, SLOT( onDumpView() ) ); @@ -258,6 +293,9 @@ void OCCViewer_Viewer::contextMenuPopup(QPopupMenu* thePopup) thePopup->insertItem( tr( "MEN_SHOW_TOOLBAR" ), this, SLOT( onShowToolbar() ) ); } +/*! + SLOT: called on dump view operation is activated, stores scene to raster file +*/ void OCCViewer_Viewer::onDumpView() { OCCViewer_ViewWindow* aView = (OCCViewer_ViewWindow*)(myViewManager->getActiveView()); @@ -265,7 +303,9 @@ void OCCViewer_Viewer::onDumpView() aView->onDumpView(); } -//********************************************************************* +/*! + SLOT: called if background color is to be changed changed, passes new color to view port +*/ void OCCViewer_Viewer::onChangeBgColor() { OCCViewer_ViewWindow* aView = (OCCViewer_ViewWindow*)(myViewManager->getActiveView()); @@ -281,21 +321,28 @@ void OCCViewer_Viewer::onChangeBgColor() aViewPort3d->setBackgroundColor(selColor); } -//********************************************************************* +/*! + SLOT: called when popup item "Show toolbar" is activated, shows toolbar of active view window +*/ void OCCViewer_Viewer::onShowToolbar() { OCCViewer_ViewWindow* aView = (OCCViewer_ViewWindow*)(myViewManager->getActiveView()); if ( aView ) aView->getToolBar()->show(); } -//********************************************************************* +/*! + Updates OCC 3D viewer +*/ void OCCViewer_Viewer::update() { if (!myV3dViewer.IsNull()) myV3dViewer->Update(); } -//********************************************************************* +/*! + \return objects selected in 3D viewer + \param theList - list to be filled with selected objects +*/ void OCCViewer_Viewer::getSelectedObjects(AIS_ListOfInteractive& theList) { theList.Clear(); @@ -303,7 +350,10 @@ void OCCViewer_Viewer::getSelectedObjects(AIS_ListOfInteractive& theList) theList.Append(myAISContext->SelectedInteractive()); } -//********************************************************************* +/*! + Selects objects in 3D viewer. Other selected objects are left as selected + \param theList - list objects to be selected +*/ void OCCViewer_Viewer::setObjectsSelected(const AIS_ListOfInteractive& theList) { AIS_ListIteratorOfListOfInteractive aIt; @@ -312,47 +362,62 @@ void OCCViewer_Viewer::setObjectsSelected(const AIS_ListOfInteractive& theList) myAISContext->UpdateCurrentViewer(); } -//********************************************************************* +/*! + Auxiliary method to emit signal selectionChanged() +*/ void OCCViewer_Viewer::performSelectionChanged() { emit selectionChanged(); } -//**************************************************************** - +/*! + SLOT, clears view aspects +*/ void OCCViewer_Viewer::onClearViewAspects() { clearViewAspects(); } -//**************************************************************** - +/*! + Clears view aspects +*/ void OCCViewer_Viewer::clearViewAspects() { myViewAspects.clear(); } -//**************************************************************** - +/*! + \return const reference to list of view aspects +*/ const viewAspectList& OCCViewer_Viewer::getViewAspects() { return myViewAspects; } -//**************************************************************** - +/*! + Appends new view aspect + \param aParams - new view aspects +*/ void OCCViewer_Viewer::appendViewAspect( const viewAspect& aParams ) { myViewAspects.append( aParams ); } -//**************************************************************** - +/*! + Replaces old view aspects by new ones + \param aViewList - list of new view aspects +*/ void OCCViewer_Viewer::updateViewAspects( const viewAspectList& aViewList ) { myViewAspects = aViewList; } +/*! + Hilights/unhilights object in viewer + \param obj - object to be updated + \param hilight - if it is true, object will be hilighted, otherwise it will be unhilighted + \param update - update current viewer +*/ bool OCCViewer_Viewer::highlight( const Handle(AIS_InteractiveObject)& obj, bool hilight, bool update ) { @@ -372,6 +437,10 @@ bool OCCViewer_Viewer::highlight( const Handle(AIS_InteractiveObject)& obj, return false; } +/*! + Unhilights all object in viewer + \param updateviewer - update current viewer +*/ bool OCCViewer_Viewer::unHighlightAll( bool updateviewer ) { if ( myAISContext->HasOpenedContext() ) @@ -381,6 +450,11 @@ bool OCCViewer_Viewer::unHighlightAll( bool updateviewer ) return false; } +/*! + \return true if object is in viewer or in collector + \param obj - object to be checked + \param onlyInViewer - search object only in viewer (so object must be displayed) +*/ bool OCCViewer_Viewer::isInViewer( const Handle(AIS_InteractiveObject)& obj, bool onlyInViewer ) { @@ -402,11 +476,21 @@ bool OCCViewer_Viewer::isInViewer( const Handle(AIS_InteractiveObject)& obj, return false; } +/*! + \return true if object is displayed in viewer + \param obj - object to be checked +*/ bool OCCViewer_Viewer::isVisible( const Handle(AIS_InteractiveObject)& obj ) { return myAISContext->IsDisplayed( obj ); } +/*! + Sets color of object + \param obj - object to be updated + \param color - new color + \param update - update current viewer +*/ void OCCViewer_Viewer::setColor( const Handle(AIS_InteractiveObject)& obj, const QColor& color, bool update ) @@ -424,6 +508,12 @@ void OCCViewer_Viewer::setColor( const Handle(AIS_InteractiveObject)& obj, myV3dViewer->Update(); } +/*! + Changes display mode of object + \param obj - object to be processed + \param mode - new display mode + \param update - update current viewer +*/ void OCCViewer_Viewer::switchRepresentation( const Handle(AIS_InteractiveObject)& obj, int mode, bool update ) { @@ -432,6 +522,12 @@ void OCCViewer_Viewer::switchRepresentation( const Handle(AIS_InteractiveObject) myV3dViewer->Update(); } +/*! + Changes transparency of object + \param obj - object to be processed + \param trans - new transparency + \param update - update current viewer +*/ void OCCViewer_Viewer::setTransparency( const Handle(AIS_InteractiveObject)& obj, float trans, bool update ) { @@ -441,17 +537,27 @@ void OCCViewer_Viewer::setTransparency( const Handle(AIS_InteractiveObject)& obj myV3dViewer->Update(); } -//**************************************************************** +/*! + Changes visibility of trihedron to opposite +*/ void OCCViewer_Viewer::toggleTrihedron() { setTrihedronShown( !isTrihedronVisible() ); } +/*! + \return true if trihedron is visible +*/ bool OCCViewer_Viewer::isTrihedronVisible() const { return !myTrihedron.IsNull() && !myAISContext.IsNull() && myAISContext->IsDisplayed( myTrihedron ); } +/*! + Sets visibility state of trihedron + \param on - new state +*/ + void OCCViewer_Viewer::setTrihedronShown( const bool on ) { if ( myTrihedron.IsNull() ) @@ -463,6 +569,9 @@ void OCCViewer_Viewer::setTrihedronShown( const bool on ) myAISContext->Erase( myTrihedron ); } +/*! + \return trihedron size +*/ int OCCViewer_Viewer::trihedronSize() const { int sz = 0; @@ -471,12 +580,21 @@ int OCCViewer_Viewer::trihedronSize() const return sz; } +/*! + Changes trihedron size + \param sz - new size +*/ void OCCViewer_Viewer::setTrihedronSize( const int sz ) { if ( !myTrihedron.IsNull() ) myTrihedron->SetSize( sz ); } +/*! + Set number of isolines + \param u - u-isolines (first parametric co-ordinate) + \param v - v-isolines (second parametric co-ordinate) +*/ void OCCViewer_Viewer::setIsos( const int u, const int v ) { Handle(AIS_InteractiveContext) ic = getAISContext(); @@ -487,6 +605,11 @@ void OCCViewer_Viewer::setIsos( const int u, const int v ) ic->SetIsoNumber( v, AIS_TOI_IsoV ); } +/*! + \return number of isolines + \param u - to return u-isolines (first parametric co-ordinate) + \param v - to return v-isolines (second parametric co-ordinate) +*/ void OCCViewer_Viewer::isos( int& u, int& v ) const { Handle(AIS_InteractiveContext) ic = getAISContext(); diff --git a/src/OCCViewer/OCCViewer_ViewPort.cxx b/src/OCCViewer/OCCViewer_ViewPort.cxx index 72f2fc5f3..f3ea1e0b5 100755 --- a/src/OCCViewer/OCCViewer_ViewPort.cxx +++ b/src/OCCViewer/OCCViewer_ViewPort.cxx @@ -16,12 +16,7 @@ // // See http://www.salome-platform.org/ // -/*************************************************************************** -** Class: OCCViewer_ViewPort -** Descr: Visualisation canvas of SUIT-based application -** Module: SUIT -** Created: UI team, 05.09.00 -****************************************************************************/ + #if !defined WNT #define QT_CLEAN_NAMESPACE /* avoid definition of INT32 and INT8 */ #endif @@ -59,6 +54,9 @@ struct CMapEntry XStandardColormap scmap; }; +/*! + Constructor +*/ CMapEntry::CMapEntry() { cmap = 0; @@ -66,6 +64,9 @@ CMapEntry::CMapEntry() scmap.colormap = 0; } +/*! + Destructor +*/ CMapEntry::~CMapEntry() { if ( alloc ) diff --git a/src/OCCViewer/OCCViewer_ViewPort.h b/src/OCCViewer/OCCViewer_ViewPort.h index 5c60ad502..fb4208667 100755 --- a/src/OCCViewer/OCCViewer_ViewPort.h +++ b/src/OCCViewer/OCCViewer_ViewPort.h @@ -35,6 +35,10 @@ class QPainter; class OCCViewer_ViewSketcher; class OCCViewer_ViewTransformer; +/*! + \class OCCViewer_ViewPort + Visualisation canvas of SUIT-based application +*/ class OCCVIEWER_EXPORT OCCViewer_ViewPort : public QWidget { Q_OBJECT diff --git a/src/OCCViewer/OCCViewer_ViewPort3d.cxx b/src/OCCViewer/OCCViewer_ViewPort3d.cxx index 2ab376022..66225b69f 100755 --- a/src/OCCViewer/OCCViewer_ViewPort3d.cxx +++ b/src/OCCViewer/OCCViewer_ViewPort3d.cxx @@ -16,12 +16,6 @@ // // See http://www.salome-platform.org/ // -/*************************************************************************** -** Class: OCCViewer_ViewPort3D -** Descr: Visualisation canvas with CasCade 3D view -** Module: OCCViewer -** Created: UI team, 05.09.00 -****************************************************************************/ #include "OCCViewer_ViewPort3d.h" @@ -259,6 +253,10 @@ void OCCViewer_ViewPort3d::setBackgroundColor( const QColor& color ) } } +/*! + Set animation mode + \param theDegenerated - degenerated mode +*/ void OCCViewer_ViewPort3d::setAnimationMode(bool theDegenerated) { if ( !activeView().IsNull() ) diff --git a/src/OCCViewer/OCCViewer_ViewWindow.cxx b/src/OCCViewer/OCCViewer_ViewWindow.cxx index 98227235f..d9ca9d427 100755 --- a/src/OCCViewer/OCCViewer_ViewWindow.cxx +++ b/src/OCCViewer/OCCViewer_ViewWindow.cxx @@ -17,8 +17,7 @@ // See http://www.salome-platform.org/ // // OCCViewer_ViewWindow.cxx: implementation of the OCCViewer_ViewWindow class. -// -////////////////////////////////////////////////////////////////////// + #include "OCCViewer_ViewWindow.h" #include "OCCViewer_ViewModel.h" @@ -162,10 +161,11 @@ const char* imageCrossCursor[] = { "................................"}; -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - +/*! + Constructor + \param theDesktop - main window of application + \param theModel - OCC 3D viewer +*/ OCCViewer_ViewWindow::OCCViewer_ViewWindow(SUIT_Desktop* theDesktop, OCCViewer_Viewer* theModel) : SUIT_ViewWindow(theDesktop) { @@ -176,7 +176,9 @@ OCCViewer_ViewWindow::OCCViewer_ViewWindow(SUIT_Desktop* theDesktop, OCCViewer_V myClippingDlg = 0; } -//**************************************************************** +/*! + Initialization of view window +*/ void OCCViewer_ViewWindow::initLayout() { myViewPort = new OCCViewer_ViewPort3d( this, myModel->getViewer3d(), V3d_ORTHOGRAPHIC ); @@ -196,7 +198,10 @@ void OCCViewer_ViewWindow::initLayout() createToolBar(); } -//**************************************************************** +/*! + \return type of operation by states of mouse and keyboard buttons + \param theEvent - mouse event +*/ OCCViewer_ViewWindow::OperationType OCCViewer_ViewWindow::getButtonState(QMouseEvent* theEvent) { OperationType aOp = NOTHING; @@ -213,7 +218,9 @@ OCCViewer_ViewWindow::OperationType OCCViewer_ViewWindow::getButtonState(QMouseE return aOp; } -//**************************************************************** +/*! + Custom event handler +*/ bool OCCViewer_ViewWindow::eventFilter(QObject* watched, QEvent* e) { if ( watched == myViewPort ) { @@ -259,13 +266,18 @@ bool OCCViewer_ViewWindow::eventFilter(QObject* watched, QEvent* e) return SUIT_ViewWindow::eventFilter(watched, e); } +/*! + Updates state of enable draw mode state +*/ void OCCViewer_ViewWindow::updateEnabledDrawMode() { if ( myModel ) myEnableDrawMode = myModel->isSelectionEnabled() && myModel->isMultiSelectionEnabled(); } -//**************************************************************** +/*! + Handler of mouse press event +*/ void OCCViewer_ViewWindow::vpMousePressEvent(QMouseEvent* theEvent) { myStartX = theEvent->x(); @@ -324,7 +336,9 @@ void OCCViewer_ViewWindow::vpMousePressEvent(QMouseEvent* theEvent) } -//**************************************************************** +/*! + Starts zoom operation, sets corresponding cursor +*/ void OCCViewer_ViewWindow::activateZoom() { if ( !transformRequested() && !myCursorIsHand ) @@ -339,9 +353,8 @@ void OCCViewer_ViewWindow::activateZoom() } -//**************************************************************** /*! - Activates 'panning' transformation + Starts panning operation, sets corresponding cursor */ void OCCViewer_ViewWindow::activatePanning() { @@ -355,9 +368,8 @@ void OCCViewer_ViewWindow::activatePanning() } } -//**************************************************************** /*! - Activates 'rotation' transformation + Starts rotation operation, sets corresponding cursor */ void OCCViewer_ViewWindow::activateRotation() { @@ -372,7 +384,9 @@ void OCCViewer_ViewWindow::activateRotation() } } -//**************************************************************** +/*! + Starts global panning operation, sets corresponding cursor +*/ void OCCViewer_ViewWindow::activateGlobalPanning() { Handle(V3d_View) aView3d = myViewPort->getView(); @@ -388,9 +402,8 @@ void OCCViewer_ViewWindow::activateGlobalPanning() } } -//**************************************************************** /*! - Activates 'fit' transformation + Starts fit operation, sets corresponding cursor */ void OCCViewer_ViewWindow::activateWindowFit() { @@ -405,9 +418,8 @@ void OCCViewer_ViewWindow::activateWindowFit() } } -//**************************************************************** /*! - Sets the active operation 'op' + Stores which viewer operation is requesting */ void OCCViewer_ViewWindow::setTransformRequested ( OperationType op ) { @@ -416,7 +428,9 @@ void OCCViewer_ViewWindow::setTransformRequested ( OperationType op ) } -//****************************************************************/ +/*! + Handler of mouse move event +*/ void OCCViewer_ViewWindow::vpMouseMoveEvent(QMouseEvent* theEvent) { myCurrX = theEvent->x(); @@ -468,7 +482,9 @@ void OCCViewer_ViewWindow::vpMouseMoveEvent(QMouseEvent* theEvent) } } -//****************************************************************/ +/*! + Handler of mouse release event +*/ void OCCViewer_ViewWindow::vpMouseReleaseEvent(QMouseEvent* theEvent) { switch ( myOperation ) { @@ -524,10 +540,9 @@ void OCCViewer_ViewWindow::vpMouseReleaseEvent(QMouseEvent* theEvent) } } -//**************************************************************** /*! - Sets the viewport to its initial state - ( no transformations in process etc. ) + Sets the viewport to its initial state + ( no transformations in process etc. ) */ void OCCViewer_ViewWindow::resetState() { @@ -549,7 +564,9 @@ void OCCViewer_ViewWindow::resetState() } -//****************************************************************/ +/*! + Draws rectangle by starting and current points +*/ void OCCViewer_ViewWindow::drawRect() { QPainter aPainter(myViewPort); @@ -562,7 +579,9 @@ void OCCViewer_ViewWindow::drawRect() myRect = aRect; } -//****************************************************************/ +/*! + Creates actions of OCC view window +*/ void OCCViewer_ViewWindow::createActions() { if (!myActionsMap.isEmpty()) return; @@ -699,7 +718,9 @@ void OCCViewer_ViewWindow::createActions() } } -//**************************************************************** +/*! + Creates toolbar of OCC view window +*/ void OCCViewer_ViewWindow::createToolBar() { myActionsMap[DumpId]->addTo(myToolBar); @@ -738,13 +759,17 @@ void OCCViewer_ViewWindow::createToolBar() myActionsMap[ClippingId]->addTo(myToolBar); } -//**************************************************************** +/*! + Processes operation fit all +*/ void OCCViewer_ViewWindow::onViewFitAll() { myViewPort->fitAll(); } -//**************************************************************** +/*! + Processes transformation "front view" +*/ void OCCViewer_ViewWindow::onFrontView() { emit vpTransformationStarted ( FRONTVIEW ); @@ -753,7 +778,9 @@ void OCCViewer_ViewWindow::onFrontView() onViewFitAll(); } -//**************************************************************** +/*! + Processes transformation "back view" +*/ void OCCViewer_ViewWindow::onBackView() { emit vpTransformationStarted ( BACKVIEW ); @@ -762,7 +789,9 @@ void OCCViewer_ViewWindow::onBackView() onViewFitAll(); } -//**************************************************************** +/*! + Processes transformation "top view" +*/ void OCCViewer_ViewWindow::onTopView() { emit vpTransformationStarted ( TOPVIEW ); @@ -771,7 +800,9 @@ void OCCViewer_ViewWindow::onTopView() onViewFitAll(); } -//**************************************************************** +/*! + Processes transformation "bottom view" +*/ void OCCViewer_ViewWindow::onBottomView() { emit vpTransformationStarted ( BOTTOMVIEW ); @@ -780,7 +811,9 @@ void OCCViewer_ViewWindow::onBottomView() onViewFitAll(); } -//**************************************************************** +/*! + Processes transformation "left view" +*/ void OCCViewer_ViewWindow::onLeftView() { emit vpTransformationStarted ( LEFTVIEW ); @@ -789,7 +822,9 @@ void OCCViewer_ViewWindow::onLeftView() onViewFitAll(); } -//**************************************************************** +/*! + Processes transformation "right view" +*/ void OCCViewer_ViewWindow::onRightView() { emit vpTransformationStarted ( RIGHTVIEW ); @@ -798,7 +833,9 @@ void OCCViewer_ViewWindow::onRightView() onViewFitAll(); } -//**************************************************************** +/*! + Processes transformation "reset view": sets default orientation of viewport camera +*/ void OCCViewer_ViewWindow::onResetView() { emit vpTransformationStarted( RESETVIEW ); @@ -809,21 +846,27 @@ void OCCViewer_ViewWindow::onResetView() myViewPort->getView()->Update(); } -//**************************************************************** +/*! + Processes transformation "fit all" +*/ void OCCViewer_ViewWindow::onFitAll() { emit vpTransformationStarted( FITALLVIEW ); myViewPort->fitAll(); } -//**************************************************************** +/*! + Creates one more window with same content +*/ void OCCViewer_ViewWindow::onCloneView() { SUIT_ViewWindow* vw = myManager->createViewWindow(); vw->show(); } -//**************************************************************** +/*! + SLOT: called if clipping operation is activated, enables/disables of clipping plane +*/ void OCCViewer_ViewWindow::onClipping( bool on ) { SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr(); @@ -851,13 +894,17 @@ void OCCViewer_ViewWindow::onClipping( bool on ) } } -//**************************************************************** +/*! + Stores view parameters +*/ void OCCViewer_ViewWindow::onMemorizeView() { myModel->appendViewAspect( getViewParams() ); } -//**************************************************************** +/*! + Restores view parameters +*/ void OCCViewer_ViewWindow::onRestoreView() { OCCViewer_CreateRestoreViewDlg* aDlg = new OCCViewer_CreateRestoreViewDlg( centralWidget(), myModel ); @@ -868,8 +915,9 @@ void OCCViewer_ViewWindow::onRestoreView() performRestoring( aDlg->currentItem() ); } -//**************************************************************** - +/*! + Restores view parameters from structure viewAspect +*/ void OCCViewer_ViewWindow::performRestoring( const viewAspect& anItem ) { Handle(V3d_View) aView3d = myViewPort->getView(); @@ -886,24 +934,41 @@ void OCCViewer_ViewWindow::performRestoring( const viewAspect& anItem ) myRestoreFlag = 0; } +/*! + Sets restore flag +*/ void OCCViewer_ViewWindow::setRestoreFlag() { myRestoreFlag = 1; } -//**************************************************************** +/*! + SLOT: called when action "show/hide" trihedron is activated +*/ void OCCViewer_ViewWindow::onTrihedronShow() { myModel->toggleTrihedron(); } -//**************************************************************** +/*! + \return QImage, containing all scene rendering in window +*/ QImage OCCViewer_ViewWindow::dumpView() { QPixmap px = QPixmap::grabWindow( myViewPort->winId() ); return px.convertToImage(); } - + +/*! + Sets parameters of cutting plane + \param on - is cutting plane enabled + \param x - x-position of plane point + \param y - y-position of plane point + \param z - z-position of plane point + \param dx - x-coordinate of plane normal + \param dy - y-coordinate of plane normal + \param dz - z-coordinate of plane normal +*/ void OCCViewer_ViewWindow::setCuttingPlane( bool on, const double x, const double y, const double z, const double dx, const double dy, const double dz ) { @@ -937,6 +1002,9 @@ void OCCViewer_ViewWindow::setCuttingPlane( bool on, const double x, const dou view->Redraw(); } +/*! + \return true if there is at least one cutting plane +*/ bool OCCViewer_ViewWindow::isCuttingPlane() { Handle(V3d_View) view = myViewPort->getView(); @@ -944,8 +1012,9 @@ bool OCCViewer_ViewWindow::isCuttingPlane() return (view->MoreActivePlanes()); } -/*! The method returns the visual parameters of this view as a viewAspect object - */ +/*! + The method returns the visual parameters of this view as a viewAspect object +*/ viewAspect OCCViewer_ViewWindow::getViewParams() const { double centerX, centerY, projX, projY, projZ, twist; @@ -981,8 +1050,9 @@ viewAspect OCCViewer_ViewWindow::getViewParams() const } -/*! The method returns the visual parameters of this view as a formated string - */ +/*! + The method returns the visual parameters of this view as a formated string +*/ QString OCCViewer_ViewWindow::getVisualParameters() { viewAspect params = getViewParams(); @@ -993,8 +1063,9 @@ QString OCCViewer_ViewWindow::getVisualParameters() return retStr; } -/* The method restors visual parameters of this view from a formated string - */ +/*! + The method restors visual parameters of this view from a formated string +*/ void OCCViewer_ViewWindow::setVisualParameters( const QString& parameters ) { QStringList paramsLst = QStringList::split( '*', parameters, true ); diff --git a/src/Prs/SALOME_Prs.cxx b/src/Prs/SALOME_Prs.cxx index cb35bb80b..e23180d19 100755 --- a/src/Prs/SALOME_Prs.cxx +++ b/src/Prs/SALOME_Prs.cxx @@ -28,365 +28,245 @@ //using namespace std; -//=========================================================== /*! - * Function: SALOME_OCCPrs::DisplayIn \n - * Purpose: Dispatches display operation to proper Display() \n - * method of SALOME_View - */ -//=========================================================== + Dispatches display operation to proper Display() method of SALOME_View +*/ void SALOME_OCCPrs::DisplayIn( SALOME_View* v ) const { if ( v ) v->Display( this ); } -//=========================================================== /*! - * Function: SALOME_OCCPrs::EraseIn \n - * Purpose: Dispatches display operation to proper Erase() \n - * method of SALOME_View - */ -//=========================================================== + Dispatches display operation to proper Erase() method of SALOME_View +*/ void SALOME_OCCPrs::EraseIn( SALOME_View* v, const bool forced ) const { if ( v ) v->Erase( this, forced ); } -//=========================================================== /*! - * Function: SALOME_OCCPrs::LocalSelectionIn \n - * Purpose: Dispatches operation to proper LocalSelectionIn() \n - * method of SALOME_View - */ -//=========================================================== + Dispatches operation to proper LocalSelectionIn() method of SALOME_View +*/ void SALOME_OCCPrs::LocalSelectionIn( SALOME_View* v, const int mode ) const { if ( v ) v->LocalSelection( this, mode ); } -//=========================================================== /*! - * Function: SALOME_OCCPrs::Update \n - * Purpose: Dispatches update operation to proper Update() \n - * method of SALOME_Displayer - */ -//=========================================================== + Dispatches update operation to proper Update() method of SALOME_Displayer +*/ void SALOME_OCCPrs::Update( SALOME_Displayer* d ) { if ( d ) d->Update( this ); } -//=========================================================== /*! - * Function: SALOME_VTKPrs::DisplayIn \n - * Purpose: Dispatches display operation to proper Display() \n - * method of SALOME_View - */ -//=========================================================== + Dispatches display operation to proper Display() method of SALOME_View +*/ void SALOME_VTKPrs::DisplayIn( SALOME_View* v ) const { if ( v ) v->Display( this ); } -//=========================================================== /*! - * Function: SALOME_VTKPrs::EraseIn \n - * Purpose: Dispatches display operation to proper Erase() \n - * method of SALOME_View - */ -//=========================================================== + Dispatches display operation to proper Erase() method of SALOME_View +*/ void SALOME_VTKPrs::EraseIn( SALOME_View* v, const bool forced ) const { if ( v ) v->Erase( this, forced ); } -//=========================================================== /*! - * Function: SALOME_VTKPrs::LocalSelectionIn \n - * Purpose: Dispatches operation to proper LocalSelectionIn() \n - * method of SALOME_View - */ -//=========================================================== + Dispatches operation to proper LocalSelectionIn() method of SALOME_View +*/ void SALOME_VTKPrs::LocalSelectionIn( SALOME_View* v, const int mode ) const { if ( v ) v->LocalSelection( this, mode ); } -//=========================================================== /*! - * Function: SALOME_VTKPrs::Update \n - * Purpose: Dispatches update operation to proper Update() \n - * method of SALOME_Displayer - */ -//=========================================================== + Dispatches update operation to proper Update() method of SALOME_Displayer +*/ void SALOME_VTKPrs::Update( SALOME_Displayer* d ) { if ( d ) d->Update( this ); } -//=========================================================== /*! - * Function: SALOME_Prs2d::DisplayIn \n - * Purpose: Dispatches display operation to proper Display() \n - * method of SALOME_View - */ -//=========================================================== + Dispatches display operation to proper Display() method of SALOME_View +*/ void SALOME_Prs2d::DisplayIn( SALOME_View* v ) const { if ( v ) v->Display( this ); } -//=========================================================== /*! - * Function: SALOME_Prs2d::EraseIn \n - * Purpose: Dispatches display operation to proper Erase() \n - * method of SALOME_View - */ -//=========================================================== + Dispatches display operation to proper Erase() method of SALOME_View +*/ void SALOME_Prs2d::EraseIn( SALOME_View* v, const bool forced ) const { if ( v ) v->Erase( this, forced ); } -//=========================================================== /*! - * Function: SALOME_Prs2d::LocalSelectionIn \n - * Purpose: Dispatches operation to proper LocalSelectionIn() \n - * method of SALOME_View - */ -//=========================================================== + Dispatches operation to proper LocalSelectionIn() method of SALOME_View +*/ void SALOME_Prs2d::LocalSelectionIn( SALOME_View* v, const int mode ) const { if ( v ) v->LocalSelection( this, mode ); } -//=========================================================== /*! - * Function: SALOME_Prs2d::Update \n - * Purpose: Dispatches update operation to proper Update() \n - * method of SALOME_Displayer - */ -//=========================================================== + Dispatches update operation to proper Update() method of SALOME_Displayer +*/ void SALOME_Prs2d::Update( SALOME_Displayer* d ) { if ( d ) d->Update( this ); } -//=========================================================== /*! - * Function: SALOME_View::Display \n - * Purpose: Gives control to SALOME_Prs object, so that \n - * it could perform double dispatch - */ -//=========================================================== + Gives control to SALOME_Prs object, so that it could perform double dispatch +*/ void SALOME_View::Display( const SALOME_Prs* prs ) { prs->DisplayIn( this ); } -//=========================================================== /*! - * Function: SALOME_View::Erase \n - * Purpose: Gives control to SALOME_Prs object, so that \n - * it could perform double dispatch - */ -//=========================================================== + Gives control to SALOME_Prs object, so that it could perform double dispatch +*/ void SALOME_View::Erase( const SALOME_Prs* prs, const bool forced ) { prs->EraseIn( this, forced ); } -//=========================================================== /*! - * Function: SALOME_View::LocalSelection \n - * Purpose: Gives control to SALOME_Prs object, so that \n - * it could perform double dispatch - */ -//=========================================================== + Gives control to SALOME_Prs object, so that it could perform double dispatch +*/ void SALOME_View::LocalSelection( const SALOME_Prs* prs, const int mode ) { prs->LocalSelectionIn( this, mode ); } -//=========================================================== /*! - * Function: SALOME_View::Display \n - * Purpose: Virtual method, should be reimplemented in successors, \n - * by default issues a warning and does nothing. - */ -//=========================================================== + Virtual method, should be reimplemented in successors, by default issues a warning and does nothing. +*/ void SALOME_View::Display( const SALOME_OCCPrs* ) { // MESSAGE( "SALOME_View::Display( const SALOME_OCCPrs& ) called! Probably, presentation is being displayed in uncompatible viewframe." ); } -//=========================================================== /*! - * Function: SALOME_View::Display \n - * Purpose: Virtual method, should be reimplemented in successors, \n - * by default issues a warning and does nothing. - */ -//=========================================================== + Virtual method, should be reimplemented in successors, by default issues a warning and does nothing. +*/ void SALOME_View::Display( const SALOME_VTKPrs* ) { // MESSAGE( "SALOME_View::Display( const SALOME_VTKPrs& ) called! Probably, presentation is being displayed in uncompatible viewframe." ); } -//=========================================================== /*! - * Function: SALOME_View::Display \n - * Purpose: Virtual method, should be reimplemented in successors, \n - * by default issues a warning and does nothing. - */ -//=========================================================== + Virtual method, should be reimplemented in successors, by default issues a warning and does nothing. +*/ void SALOME_View::Display( const SALOME_Prs2d* ) { // MESSAGE( "SALOME_View::Display( const SALOME_Prs2d& ) called! Probably, presentation is being displayed in uncompatible viewframe." ); } -//=========================================================== /*! - * Function: SALOME_View::Erase \n - * Purpose: Virtual method, should be reimplemented in successors, \n - * by default issues a warning and does nothing. - */ -//=========================================================== + Virtual method, should be reimplemented in successors, by default issues a warning and does nothing. +*/ void SALOME_View::Erase( const SALOME_OCCPrs*, const bool ) { // MESSAGE( "SALOME_View::Erase( const SALOME_OCCPrs& ) called! Probably, presentation is being erased in uncompatible viewframe." ); } -//=========================================================== /*! - * Function: SALOME_View::Erase \n - * Purpose: Virtual method, should be reimplemented in successors, \n - * by default issues a warning and does nothing. - */ -//=========================================================== + Virtual method, should be reimplemented in successors, by default issues a warning and does nothing. +*/ void SALOME_View::Erase( const SALOME_VTKPrs*, const bool ) { // MESSAGE( "SALOME_View::Erase( const SALOME_VTKPrs& ) called! Probably, presentation is being erased in uncompatible viewframe." ); } -//=========================================================== /*! - * Function: SALOME_View::Erase \n - * Purpose: Virtual method, should be reimplemented in successors, \n - * by default issues a warning and does nothing. - */ -//=========================================================== + Virtual method, should be reimplemented in successors, by default issues a warning and does nothing. +*/ void SALOME_View::Erase( const SALOME_Prs2d*, const bool ) { // MESSAGE( "SALOME_View::Erase( const SALOME_Prs2d& ) called! Probably, presentation is being erased in uncompatible viewframe." ); } -//=========================================================== /*! - * Function: SALOME_View::EraseAll \n - * Purpose: Virtual method, should be reimplemented in successors, \n - * by default issues a warning and does nothing. - */ -//=========================================================== + Virtual method, should be reimplemented in successors, by default issues a warning and does nothing. +*/ void SALOME_View::EraseAll( const bool ) { // MESSAGE( "SALOME_View::EraseAll() called!" ); } -//=========================================================== /*! - * Function: SALOME_View::LocalSelection \n - * Purpose: Virtual method, should be reimplemented in successors, \n - * by default issues a warning and does nothing. - */ -//=========================================================== + Virtual method, should be reimplemented in successors, by default issues a warning and does nothing. +*/ void SALOME_View::LocalSelection( const SALOME_OCCPrs*, const int ) { // MESSAGE( "SALOME_View::LocalSelection( const SALOME_OCCPrs* ) called! \ // Probably, selection is being activated in uncompatible viewframe." ); } -//=========================================================== /*! - * Function: SALOME_View::LocalSelection \n - * Purpose: Virtual method, should be reimplemented in successors, \n - * by default issues a warning and does nothing. - */ -//=========================================================== + Virtual method, should be reimplemented in successors, by default issues a warning and does nothing. +*/ void SALOME_View::LocalSelection( const SALOME_VTKPrs*, const int ) { // MESSAGE( "SALOME_View::LocalSelection( const SALOME_VTKPrs* ) called! \ // Probably, selection is being activated in uncompatible viewframe." ); } -//=========================================================== /*! - * Function: SALOME_View::LocalSelection \n - * Purpose: Virtual method, should be reimplemented in successors, \n - * by default issues a warning and does nothing. - */ -//=========================================================== + Virtual method, should be reimplemented in successors, by default issues a warning and does nothing. +*/ void SALOME_View::LocalSelection( const SALOME_Prs2d*, const int ) { // MESSAGE( "SALOME_View::LocalSelection( const SALOME_Prs2d* ) called! \ // Probably, selection is being activated in uncompatible viewframe." ); } -//=========================================================== /*! - * Function: SALOME_View::GlobalSelection \n - * Purpose: Virtual method, should be reimplemented in successors, \n - * by default issues a warning and does nothing. - */ -//=========================================================== + Virtual method, should be reimplemented in successors, by default issues a warning and does nothing. +*/ void SALOME_View::GlobalSelection( const bool ) const { // MESSAGE( "SALOME_View::GlobalSelection() called! \ // Probably, selection is being activated in uncompatible viewframe." ); } -//=========================================================== /*! - * Function: SALOME_Displayer::UpdatePrs \n - * Purpose: Gives control to SALOME_Prs object, so that \n - * it could perform double dispatch - */ -//=========================================================== + Gives control to SALOME_Prs object, so that it could perform double dispatch +*/ void SALOME_Displayer::UpdatePrs( SALOME_Prs* prs ) { prs->Update( this ); } -//=========================================================== /*! - * Function: SALOME_Displayer::Update \n - * Purpose: Virtual method, should be reimplemented in successors, \n - * by default issues a warning and does nothing. - */ -//=========================================================== + Virtual method, should be reimplemented in successors, by default issues a warning and does nothing. +*/ void SALOME_Displayer::Update( SALOME_OCCPrs* ) { // MESSAGE( "SALOME_Displayer::Update( SALOME_OCCPrs* ) called! Probably, presentation is being updated in uncompatible viewframe." ); } -//=========================================================== /*! - * Function: SALOME_Displayer::Update \n - * Purpose: Virtual method, should be reimplemented in successors, \n - * by default issues a warning and does nothing. - */ -//=========================================================== + Virtual method, should be reimplemented in successors, by default issues a warning and does nothing. +*/ void SALOME_Displayer::Update( SALOME_VTKPrs* ) { // MESSAGE( "SALOME_Displayer::Update( SALOME_VTKPrs* ) called! Probably, presentation is being updated in uncompatible viewframe." ); } -//=========================================================== /*! - * Function: SALOME_Displayer::Update \n - * Purpose: Virtual method, should be reimplemented in successors, \n - * by default issues a warning and does nothing. - */ -//=========================================================== + Virtual method, should be reimplemented in successors, by default issues a warning and does nothing. +*/ void SALOME_Displayer::Update( SALOME_Prs2d* ) { // MESSAGE( "SALOME_Displayer::Update( SALOME_Prs2d* ) called! Probably, presentation is being updated in uncompatible viewframe." ); diff --git a/src/Prs/SALOME_Prs.h b/src/Prs/SALOME_Prs.h index eec2a6055..6d21c79f9 100755 --- a/src/Prs/SALOME_Prs.h +++ b/src/Prs/SALOME_Prs.h @@ -33,13 +33,11 @@ class SALOME_View; class SALOME_Displayer; class Handle_SALOME_InteractiveObject; -//=========================================================== /*! - * Class: SALOME_Prs \n - * Description: Base class for SALOME graphic object wrappers - presentations.\n - * Presentations are temporary objects, so they can be created on the stack. - */ -//=========================================================== + \class SALOME_Prs + Base class for SALOME graphic object wrappers - presentations. + Presentations are temporary objects, so they can be created on the stack. +*/ class PRS_EXPORT SALOME_Prs { @@ -63,13 +61,11 @@ public: virtual void LocalSelectionIn( SALOME_View*, const int ) const = 0; }; -//=========================================================== /*! - * Class: SALOME_OCCPrs \n - * Description: Base class for OpenCASCADE graphic object (AIS_InteractiveObject) wrappers.\n - * This intermediate class is necessary to avoid dependencies from OCC libs. - */ -//=========================================================== + \class SALOME_OCCPrs + Base class for OpenCASCADE graphic object (AIS_InteractiveObject) wrappers. + This intermediate class is necessary to avoid dependencies from OCC libs. +*/ class PRS_EXPORT SALOME_OCCPrs : public SALOME_Prs { @@ -90,13 +86,11 @@ public: virtual void LocalSelectionIn( SALOME_View*, const int ) const; }; -//=========================================================== /*! - * Class: SALOME_VTKPrs \n - * Description: Base class for VTK graphic object (vtkActor) wrappers \n - * This intermediate class is necessary to avoid dependencies from VTK libs. - */ -//=========================================================== + \class SALOME_VTKPrs + Base class for VTK graphic object (vtkActor) wrappers. + This intermediate class is necessary to avoid dependencies from VTK libs. +*/ class PRS_EXPORT SALOME_VTKPrs : public SALOME_Prs { public: @@ -116,13 +110,10 @@ public: virtual void LocalSelectionIn( SALOME_View*, const int ) const; }; -//=========================================================== /*! - * Class: SALOME_Prs2d \n - * Description: Base class for Plot2d graphic object (Plot2d_Curve) wrappers. - */ -//=========================================================== - + \class SALOME_Prs2d + Base class for Plot2d graphic object (Plot2d_Curve) wrappers. +*/ class PRS_EXPORT SALOME_Prs2d : public SALOME_Prs { public: @@ -142,18 +133,13 @@ public: virtual void LocalSelectionIn( SALOME_View*, const int ) const; }; -///////////////////////////////////////////////////////////////////////// -// Base classes for object wrappers for any other visualization libraries -// should be added here! -///////////////////////////////////////////////////////////////////////// - -//=========================================================== /*! - * Class: SALOME_View \n - * Description: Base class for SALOME views (or view frames) - */ -//=========================================================== - + Base classes for object wrappers for any other visualization libraries should be added here! +*/ +/*! + \class SALOME_View + Base class for SALOME views (or view frames) +*/ class PRS_EXPORT SALOME_View { public: @@ -211,24 +197,18 @@ public: virtual void Repaint() {} //!< Null body here. }; -//=========================================================== -/* - * Classes: SALOME_Displayer - * Description: These classes are used to specify type of view - * VTK, OCC or Plot2d - */ -//=========================================================== +/*! + \class SALOME_Displayer + These classes are used to specify type of view VTK, OCC or Plot2d +*/ class PRS_EXPORT SALOME_OCCViewType {}; class PRS_EXPORT SALOME_VTKViewType {}; class PRS_EXPORT SALOME_Plot2dViewType {}; -//=========================================================== /*! - * Class: SALOME_Displayer \n - * Description: Base class for SALOME displayers - */ -//=========================================================== - + \class SALOME_Displayer + Base class for SALOME displayers +*/ class PRS_EXPORT SALOME_Displayer { public: diff --git a/src/SOCC/SOCC_Prs.cxx b/src/SOCC/SOCC_Prs.cxx index a751570c4..a7867e388 100644 --- a/src/SOCC/SOCC_Prs.cxx +++ b/src/SOCC/SOCC_Prs.cxx @@ -29,84 +29,63 @@ #include "SOCC_Prs.h" using namespace std; -//========================================================== /*! - * SOCC_Prs::SOCC_Prs - * Default constructor - */ -//========================================================== + Default constructor +*/ SOCC_Prs::SOCC_Prs() { myToActivate = true; } -//========================================================== /*! - * SOCC_Prs::SOCC_Prs - * Standard constructor - */ -//========================================================== + Standard constructor +*/ SOCC_Prs::SOCC_Prs( const Handle(AIS_InteractiveObject)& obj ) { AddObject( obj ); } -//========================================================== /*! - * SOCC_Prs::~SOCC_Prs - * Destructor - */ -//========================================================== + Destructor +*/ SOCC_Prs::~SOCC_Prs() { myObjects.Clear(); } -//========================================================== /*! - * SOCC_Prs::GetObjects - * Get interactive objects list - */ -//========================================================== + Get interactive objects list +*/ void SOCC_Prs::GetObjects( AIS_ListOfInteractive& list ) const { list = myObjects; } -//========================================================== /*! - * SOCC_Prs::AddObject - * Add interactive object - */ -//========================================================== + Add interactive object +*/ void SOCC_Prs::AddObject( const Handle(AIS_InteractiveObject)& obj ) { myObjects.Append( obj ); } -//========================================================== /*! - * SOCC_Prs::IsNull - * Return 0 if list of the interactive objects is empty - * [ Reimplemented from SALOME_Prs ] - */ -//========================================================== + \return 0 if list of the interactive objects is empty [ Reimplemented from SALOME_Prs ] +*/ bool SOCC_Prs::IsNull() const { return myObjects.IsEmpty(); } -//================================================================= /*! - * GEOM_Displayer::SetToActivate - * This method is used for activisation/deactivisation of - * objects in the moment of displaying + This method is used for activisation/deactivisation of + objects in the moment of displaying */ -//================================================================= void SOCC_Prs::SetToActivate( const bool toActivate ) { myToActivate = toActivate; } + bool SOCC_Prs::ToActivate() const { return myToActivate; diff --git a/src/SOCC/SOCC_ViewModel.cxx b/src/SOCC/SOCC_ViewModel.cxx index 60c0a880e..ba47d8424 100755 --- a/src/SOCC/SOCC_ViewModel.cxx +++ b/src/SOCC/SOCC_ViewModel.cxx @@ -16,643 +16,681 @@ // // See http://www.salome-platform.org/ // -#include "SOCC_ViewModel.h" - -#include "SOCC_Prs.h" -#include "SOCC_ViewWindow.h" - -#include "SUIT_Session.h" -#include "SUIT_Application.h" - -//#include "ToolsGUI.h" - -// Temporarily commented to avoid awful dependecy on SALOMEDS -// TODO: better mechanism of storing display/erse status in a study -// should be provided... -//#include -//#include CORBA_CLIENT_HEADER(SALOMEDS) - -#include -#include - -#include -#include - -// Temporarily commented to avoid awful dependecy on SALOMEDS -// TODO: better mechanism of storing display/erse status in a study -// should be provided... -//#include -//#include -//#include -//#include - -//#include "SALOMEDSClient.hxx" -//#include "SALOMEDS_StudyManager.hxx" - -#include - -// in order NOT TO link with SalomeApp, here the code returns SALOMEDS_Study. -// SalomeApp_Study::studyDS() does it as well, but -- here it is retrieved from -// SALOMEDS::StudyManager - no linkage with SalomeApp. - -// Temporarily commented to avoid awful dependecy on SALOMEDS -// TODO: better mechanism of storing display/erse status in a study -// should be provided... -//static _PTR(Study) getStudyDS() -//{ -// SALOMEDSClient_Study* aStudy = NULL; -// _PTR(StudyManager) aMgr( new SALOMEDS_StudyManager() ); - - // get id of SUIT_Study, if it's a SalomeApp_Study, it will return - // id of its underlying SALOMEDS::Study -// SUIT_Application* app = SUIT_Session::session()->activeApplication(); -// if ( !app ) return _PTR(Study)(aStudy); -// SUIT_Study* stud = app->activeStudy(); -// if ( !stud ) return _PTR(Study)(aStudy); -// const int id = stud->id(); // virtual method, must return SALOMEDS_Study id - // get SALOMEDS_Study with this id from StudyMgr -// return aMgr->GetStudyByID( id ); -//} - -SOCC_Viewer::SOCC_Viewer( bool DisplayTrihedron ) -: OCCViewer_Viewer( DisplayTrihedron ) -{ -} - -SOCC_Viewer::~SOCC_Viewer() -{ -} - -bool SOCC_Viewer::highlight( const Handle(SALOME_InteractiveObject)& obj, - bool hilight, bool upd ) -{ - bool isInLocal = getAISContext()->HasOpenedContext(); - //SUIT_Study* ActiveStudy = SUIT_Application::getDesktop()->getActiveStudy(); - //SALOME_Selection* Sel = SALOME_Selection::Selection( ActiveStudy->getSelection() ); - - AIS_ListOfInteractive List; - getAISContext()->DisplayedObjects(List); - - AIS_ListIteratorOfListOfInteractive ite(List); - for ( ; ite.More(); ite.Next() ) - { - Handle(SALOME_InteractiveObject) anObj = - Handle(SALOME_InteractiveObject)::DownCast( ite.Value()->GetOwner() ); - - if ( !anObj.IsNull() && anObj->hasEntry() && anObj->isSame( obj ) ) - { - if ( !isInLocal ) - OCCViewer_Viewer::highlight( ite.Value(), hilight, false ); - // highlight subshapes only when local selection is active - else - { - /*if ( ite.Value()->IsKind( STANDARD_TYPE( SALOME_AISShape ) ) ) - { - Handle(SALOME_AISShape) aSh = Handle(SALOME_AISShape)::DownCast( ite.Value() ); - TColStd_IndexedMapOfInteger MapIndex; - Sel->GetIndex( IObject, MapIndex ); - aSh->highlightSubShapes( MapIndex, highlight ); - }*/ - } - break; - } - } - - if( upd ) - update(); - - return false; -} - -bool SOCC_Viewer::isInViewer( const Handle(SALOME_InteractiveObject)& obj, - bool onlyInViewer ) -{ - AIS_ListOfInteractive List; - getAISContext()->DisplayedObjects(List); - - if( !onlyInViewer ) { - AIS_ListOfInteractive List1; - getAISContext()->ObjectsInCollector(List1); - List.Append(List1); - } - - AIS_ListIteratorOfListOfInteractive ite(List); - for ( ; ite.More(); ite.Next() ) - { - Handle(SALOME_InteractiveObject) anObj = - Handle(SALOME_InteractiveObject)::DownCast( ite.Value()->GetOwner() ); - - if ( !anObj.IsNull() && anObj->hasEntry() && anObj->isSame( obj ) ) - return true; - } - return false; -} - -bool SOCC_Viewer::isVisible( const Handle(SALOME_InteractiveObject)& obj ) -{ - AIS_ListOfInteractive List; - getAISContext()->DisplayedObjects( List ); - - AIS_ListIteratorOfListOfInteractive ite( List ); - for ( ; ite.More(); ite.Next() ) - { - Handle(SALOME_InteractiveObject) anObj = - Handle(SALOME_InteractiveObject)::DownCast( ite.Value()->GetOwner() ); - - if ( !anObj.IsNull() && anObj->hasEntry() && anObj->isSame( obj ) ) - return getAISContext()->IsDisplayed( ite.Value() ); - } - - return false; -} - -void SOCC_Viewer::setColor( const Handle(SALOME_InteractiveObject)& obj, - const QColor& color, bool update ) -{ - AIS_ListOfInteractive List; - getAISContext()->DisplayedObjects(List); - - AIS_ListIteratorOfListOfInteractive ite(List); - for ( ; ite.More(); ite.Next() ) - { - Handle(SALOME_InteractiveObject) anObj = - Handle(SALOME_InteractiveObject)::DownCast( ite.Value()->GetOwner() ); - - if ( !anObj.IsNull() && anObj->hasEntry() && anObj->isSame( obj ) ) - { - OCCViewer_Viewer::setColor( ite.Value(), color, update ); - return; - } - } -} - -void SOCC_Viewer::switchRepresentation( const Handle(SALOME_InteractiveObject)& obj, - int mode, bool update ) -{ - AIS_ListOfInteractive List; - getAISContext()->DisplayedObjects(List); - - AIS_ListIteratorOfListOfInteractive ite(List); - for ( ; ite.More(); ite.Next() ) - { - Handle(SALOME_InteractiveObject) anObj = - Handle(SALOME_InteractiveObject)::DownCast( ite.Value()->GetOwner() ); - - if ( !anObj.IsNull() && anObj->hasEntry() && anObj->isSame( obj ) ) - { - OCCViewer_Viewer::switchRepresentation( ite.Value(), mode, update ); - return; - } - } -} - -void SOCC_Viewer::setTransparency( const Handle(SALOME_InteractiveObject)& obj, - float trans, bool update ) -{ - AIS_ListOfInteractive List; - getAISContext()->DisplayedObjects( List ); - - AIS_ListIteratorOfListOfInteractive ite( List ); - for ( ; ite.More(); ite.Next() ) - { - Handle(SALOME_InteractiveObject) anObj = - Handle(SALOME_InteractiveObject)::DownCast( ite.Value()->GetOwner() ); - - if ( !anObj.IsNull() && anObj->hasEntry() && anObj->isSame( obj ) ) - { - OCCViewer_Viewer::setTransparency( ite.Value(), trans, update ); - return; - } - } -} - -void SOCC_Viewer::rename( const Handle(SALOME_InteractiveObject)& obj, - const QString& name ) -{ - AIS_ListOfInteractive List; - getAISContext()->DisplayedObjects(List); - - AIS_ListIteratorOfListOfInteractive ite(List); - while (ite.More()) - { - if (ite.Value()->IsKind(STANDARD_TYPE(SALOME_AISShape))) - { - Handle(SALOME_AISShape) aSh = Handle(SALOME_AISShape)::DownCast(ite.Value()); - - if ( aSh->hasIO() ) - { - Handle(SALOME_InteractiveObject) IO = aSh->getIO(); - if ( IO->isSame( obj ) ) - { - aSh->setName( (char*)name.latin1() ); - break; - } - } - } - else if ( ite.Value()->IsKind( STANDARD_TYPE( SALOME_AISObject ) ) ) - { - Handle(SALOME_AISObject) aSh = Handle(SALOME_AISObject)::DownCast( ite.Value() ); - - // Add code here, if someone create a MODULE_AISObject. - } - ite.Next(); - } -} - -//======================================================================= -// name : Display -// Purpose : Display presentation -//======================================================================= -void SOCC_Viewer::Display( const SALOME_OCCPrs* prs ) -{ - // try do downcast object - const SOCC_Prs* anOCCPrs = dynamic_cast( prs ); - if ( !anOCCPrs || anOCCPrs->IsNull() ) - return; - - // get SALOMEDS Study - // Temporarily commented to avoid awful dependecy on SALOMEDS - // TODO: better mechanism of storing display/erse status in a study - // should be provided... - // _PTR(Study) study(getStudyDS()); - - // get context - Handle (AIS_InteractiveContext) ic = getAISContext(); - - // get all displayed objects - AIS_ListOfInteractive List; - ic->DisplayedObjects( List ); - // get objects in the collector - AIS_ListOfInteractive ListCollector; - ic->ObjectsInCollector( ListCollector ); - - // get objects to be displayed - AIS_ListOfInteractive anAISObjects; - anOCCPrs->GetObjects( anAISObjects ); - - AIS_ListIteratorOfListOfInteractive aIter( anAISObjects ); - for ( ; aIter.More(); aIter.Next() ) - { - Handle(AIS_InteractiveObject) anAIS = aIter.Value(); - if ( !anAIS.IsNull() ) - { - // try to find presentation in the viewer - bool bDisplayed = false; - AIS_ListIteratorOfListOfInteractive ite( List ); - for ( ; ite.More(); ite.Next() ) - { - // compare presentations by handles - // if the object is already displayed - nothing to do more - if ( ite.Value() == anAIS ) - { - // Deactivate object if necessary - if ( !anOCCPrs->ToActivate() ) - ic->Deactivate( anAIS ); - bDisplayed = true; - break; - } - } - - if ( bDisplayed ) - continue; - - // then try to find presentation in the collector - bDisplayed = false; - ite.Initialize( ListCollector ); - for ( ; ite.More(); ite.Next() ) - { - // compare presentations by handles - // if the object is in collector - display it - if ( ite.Value() == anAIS ) - { - ic->DisplayFromCollector( anAIS, false ); - - // Deactivate object if necessary - if ( !anOCCPrs->ToActivate() ) - ic->Deactivate( anAIS ); - bDisplayed = true; - - // Set visibility flag - // Temporarily commented to avoid awful dependecy on SALOMEDS - // TODO: better mechanism of storing display/erse status in a study - // should be provided... - //Handle(SALOME_InteractiveObject) anObj = - // Handle(SALOME_InteractiveObject)::DownCast( anAIS->GetOwner() ); - //if ( !anObj.IsNull() && anObj->hasEntry() ) - //{ - // if ( study ) - // ToolsGUI::SetVisibility( study, anObj->getEntry(), true, this ); - //} - break; - } - } - if ( bDisplayed ) - continue; - - // if object is not displayed and not found in the collector - display it - if ( anAIS->IsKind( STANDARD_TYPE(AIS_Trihedron) ) ) - { - Handle(AIS_Trihedron) aTrh = Handle(AIS_Trihedron)::DownCast( anAIS ); - double aNewSize = 100, aSize = 100; - getTrihedronSize( aNewSize, aSize ); - aTrh->SetSize( aTrh == getTrihedron() ? aNewSize : 0.5 * aNewSize ); - } - - ic->Display( anAIS, false ); - - // Set visibility flag - // Temporarily commented to avoid awful dependecy on SALOMEDS - // TODO: better mechanism of storing display/erse status in a study - // should be provided... - //Handle(SALOME_InteractiveObject) anObj = - // Handle(SALOME_InteractiveObject)::DownCast( anAIS->GetOwner() ); - //if ( !anObj.IsNull() && anObj->hasEntry() ) - //{ - // if ( study ) - // ToolsGUI::SetVisibility( study, anObj->getEntry(), true, this ); - //} - - // Deactivate object if necessary - if ( !anOCCPrs->ToActivate() ) - ic->Deactivate( anAIS ); - } - } -} - -//======================================================================= -// name : Erase -// Purpose : Erase presentation -//======================================================================= -void SOCC_Viewer::Erase( const SALOME_OCCPrs* prs, const bool forced ) -{ - // try do downcast object - const SOCC_Prs* anOCCPrs = dynamic_cast( prs ); - if ( !anOCCPrs || anOCCPrs->IsNull() ) - return; - - // get SALOMEDS Study - // Temporarily commented to avoid awful dependecy on SALOMEDS - // TODO: better mechanism of storing display/erse status in a study - // should be provided... - // _PTR(Study) study(getStudyDS()); - - // get context - Handle(AIS_InteractiveContext) ic = getAISContext(); - - // get objects to be erased - AIS_ListOfInteractive anAISObjects; - anOCCPrs->GetObjects( anAISObjects ); - - AIS_ListIteratorOfListOfInteractive aIter( anAISObjects ); - for ( ; aIter.More(); aIter.Next() ) { - Handle(AIS_InteractiveObject) anAIS = aIter.Value(); - if ( !anAIS.IsNull() ) { - // erase the object from context : move it to collector - ic->Erase( anAIS, false, forced ? false : true ); - - // Set visibility flag if necessary - // Temporarily commented to avoid awful dependecy on SALOMEDS - // TODO: better mechanism of storing display/erse status in a study - // should be provided... - //if ( !forced ) - //{ - // Handle(SALOME_InteractiveObject) anObj = - // Handle(SALOME_InteractiveObject)::DownCast( anAIS->GetOwner() ); - // if ( !anObj.IsNull() && anObj->hasEntry() ) - // { - // if ( study ) - // ToolsGUI::SetVisibility( study, anObj->getEntry(), true, this ); - // } - //} - } - } -} - -//======================================================================= -// name : EraseAll -// Purpose : Erase all presentations -//======================================================================= -void SOCC_Viewer::EraseAll( const bool forced ) -{ - // get SALOMEDS Study - // Temporarily commented to avoid awful dependecy on SALOMEDS - // TODO: better mechanism of storing display/erse status in a study - // should be provided... - // _PTR(Study) study(getStudyDS()); - - // get context - Handle(AIS_InteractiveContext) ic = getAISContext(); - - // check if trihedron is displayed - Standard_Boolean isTrihedronDisplayed = ic->IsDisplayed( getTrihedron() ); - - // get objects to be erased (all currently displayed objects) - AIS_ListOfInteractive aList; - ic->DisplayedObjects( aList ); - AIS_ListIteratorOfListOfInteractive anIter( aList ); - for ( ; anIter.More(); anIter.Next() ) { - if ( isTrihedronDisplayed && anIter.Value()->DynamicType() == STANDARD_TYPE( AIS_Trihedron ) ) - continue; - - // erase an object - Handle(AIS_InteractiveObject) anIO = anIter.Value(); - ic->Erase( anIO, false, forced ? false : true ); - - // Set visibility flag if necessary - // Temporarily commented to avoid awful dependecy on SALOMEDS - // TODO: better mechanism of storing display/erse status in a study - // should be provided... - //if ( !forced ) { - // Handle(SALOME_InteractiveObject) anObj = - // Handle(SALOME_InteractiveObject)::DownCast( anIO->GetOwner() ); - - // if ( !anObj.IsNull() && anObj->hasEntry() ) { - // if ( study ) - // ToolsGUI::SetVisibility( study, anObj->getEntry(), true, this ); - // } - //} - } - - // display trihedron if necessary - if ( isTrihedronDisplayed ) - getAISContext()->Display( getTrihedron() ); - else - Repaint(); -} - -//======================================================================= -// name : CreatePrs -// Purpose : Create presentation corresponding to the entry -//======================================================================= -SALOME_Prs* SOCC_Viewer::CreatePrs( const char* entry ) -{ - SOCC_Prs* prs = new SOCC_Prs(); - if ( entry ) - { - // get context - Handle(AIS_InteractiveContext) ic = getAISContext(); - - // get displayed objects - AIS_ListOfInteractive List; - ic->DisplayedObjects( List ); - // get objects in the collector - AIS_ListOfInteractive ListCollector; - ic->ObjectsInCollector( ListCollector ); - List.Append( ListCollector ); - - AIS_ListIteratorOfListOfInteractive ite( List ); - for ( ; ite.More(); ite.Next() ) - { - Handle(SALOME_InteractiveObject) anObj = - Handle(SALOME_InteractiveObject)::DownCast( ite.Value()->GetOwner() ); - - if ( !anObj.IsNull() && anObj->hasEntry() && strcmp( anObj->getEntry(), entry ) == 0 ) - prs->AddObject( ite.Value() ); - } - } - return prs; -} - -//======================================================================= -// name : LocalSelection -// Purpose : Activates selection of sub shapes -//======================================================================= -void SOCC_Viewer::LocalSelection( const SALOME_OCCPrs* thePrs, const int theMode ) -{ - Handle(AIS_InteractiveContext) ic = getAISContext(); - - const SOCC_Prs* anOCCPrs = dynamic_cast( thePrs ); - if ( ic.IsNull() ) - return; - - // Open local context if there is no one - bool allObjects = thePrs == 0 || thePrs->IsNull(); - if ( !ic->HasOpenedContext() ) { - ic->ClearCurrents( false ); - ic->OpenLocalContext( allObjects, true, true ); - } - - AIS_ListOfInteractive anObjs; - // Get objects to be activated - if ( allObjects ) - ic->DisplayedObjects( anObjs ); - else - anOCCPrs->GetObjects( anObjs ); - - // Activate selection of objects from prs - AIS_ListIteratorOfListOfInteractive aIter( anObjs ); - for ( ; aIter.More(); aIter.Next() ) { - Handle(AIS_InteractiveObject) anAIS = aIter.Value(); - if ( !anAIS.IsNull() ) - { - if ( anAIS->IsKind( STANDARD_TYPE( AIS_Shape ) ) ) - { - ic->Load( anAIS, -1, false ); - ic->Activate( anAIS, AIS_Shape::SelectionMode( (TopAbs_ShapeEnum)theMode ) ); - } - else if ( anAIS->DynamicType() != STANDARD_TYPE(AIS_Trihedron) ) - { - ic->Load( anAIS, -1, false ); - ic->Activate( anAIS, theMode ); - } - } - } -} - -//======================================================================= -// name : GlobalSelection -// Purpose : Deactivates selection of sub shapes -//======================================================================= -void SOCC_Viewer::GlobalSelection( const bool update ) const -{ - Handle(AIS_InteractiveContext) ic = getAISContext(); - if ( !ic.IsNull() ) - { - ic->CloseAllContexts( false ); - if ( update ) - ic->CurrentViewer()->Redraw(); - } -} - -//======================================================================= -// name : BeforeDisplay -// Purpose : Axiluary method called before displaying of objects -//======================================================================= -void SOCC_Viewer::BeforeDisplay( SALOME_Displayer* d ) -{ - d->BeforeDisplay( this, SALOME_OCCViewType() ); -} - -//======================================================================= -// name : AfterDisplay -// Purpose : Axiluary method called after displaying of objects -//======================================================================= -void SOCC_Viewer::AfterDisplay( SALOME_Displayer* d ) -{ - d->AfterDisplay( this, SALOME_OCCViewType() ); -} - -//======================================================================= -// name : getTrihedronSize -// Purpose : Get new and current trihedron size corresponding to the -// current model size -//======================================================================= -bool SOCC_Viewer::getTrihedronSize( double& theNewSize, double& theSize ) -{ - theNewSize = 100; - theSize = 100; - - //SRN: BUG IPAL8996, a usage of method ActiveView without an initialization - Handle(V3d_Viewer) viewer = getViewer3d(); - viewer->InitActiveViews(); - if(!viewer->MoreActiveViews()) return false; - - Handle(V3d_View) view3d = viewer->ActiveView(); - //SRN: END of fix - - if ( view3d.IsNull() ) - return false; - - double Xmin = 0, Ymin = 0, Zmin = 0, Xmax = 0, Ymax = 0, Zmax = 0; - double aMaxSide; - - view3d->View()->MinMaxValues( Xmin, Ymin, Zmin, Xmax, Ymax, Zmax ); - - if ( Xmin == RealFirst() || Ymin == RealFirst() || Zmin == RealFirst() || - Xmax == RealLast() || Ymax == RealLast() || Zmax == RealLast() ) - return false; - - aMaxSide = Xmax - Xmin; - if ( aMaxSide < Ymax -Ymin ) aMaxSide = Ymax -Ymin; - if ( aMaxSide < Zmax -Zmin ) aMaxSide = Zmax -Zmin; - - float aSizeInPercents = SUIT_Session::session()->resourceMgr()->doubleValue("Viewer","TrihedronSize", 105.); - - static float EPS = 5.0E-3; - theSize = getTrihedron()->Size(); - theNewSize = aMaxSide*aSizeInPercents / 100.0; - - return fabs( theNewSize - theSize ) > theSize * EPS || - fabs( theNewSize - theSize) > theNewSize * EPS; -} - -//======================================================================= -// name : Repaint -// Purpose : -//======================================================================= -void SOCC_Viewer::Repaint() -{ -// onAdjustTrihedron(); - getViewer3d()->Update(); -} - -//======================================================================= -// name : createView -// Purpose : create SOCC_ViewWindow -//======================================================================= -SUIT_ViewWindow* SOCC_Viewer::createView( SUIT_Desktop* theDesktop ) -{ - SOCC_ViewWindow* view = new SOCC_ViewWindow(theDesktop, this); - initView( view ); - return view; -} +#include "SOCC_ViewModel.h" + +#include "SOCC_Prs.h" +#include "SOCC_ViewWindow.h" + +#include "SUIT_Session.h" +#include "SUIT_Application.h" + +//#include "ToolsGUI.h" + +// Temporarily commented to avoid awful dependecy on SALOMEDS +// TODO: better mechanism of storing display/erse status in a study +// should be provided... +//#include +//#include CORBA_CLIENT_HEADER(SALOMEDS) + +#include +#include + +#include +#include + +// Temporarily commented to avoid awful dependecy on SALOMEDS +// TODO: better mechanism of storing display/erse status in a study +// should be provided... +//#include +//#include +//#include +//#include + +//#include "SALOMEDSClient.hxx" +//#include "SALOMEDS_StudyManager.hxx" + +#include + +// in order NOT TO link with SalomeApp, here the code returns SALOMEDS_Study. +// SalomeApp_Study::studyDS() does it as well, but -- here it is retrieved from +// SALOMEDS::StudyManager - no linkage with SalomeApp. + +// Temporarily commented to avoid awful dependecy on SALOMEDS +// TODO: better mechanism of storing display/erse status in a study +// should be provided... +//static _PTR(Study) getStudyDS() +//{ +// SALOMEDSClient_Study* aStudy = NULL; +// _PTR(StudyManager) aMgr( new SALOMEDS_StudyManager() ); + + // get id of SUIT_Study, if it's a SalomeApp_Study, it will return + // id of its underlying SALOMEDS::Study +// SUIT_Application* app = SUIT_Session::session()->activeApplication(); +// if ( !app ) return _PTR(Study)(aStudy); +// SUIT_Study* stud = app->activeStudy(); +// if ( !stud ) return _PTR(Study)(aStudy); +// const int id = stud->id(); // virtual method, must return SALOMEDS_Study id + // get SALOMEDS_Study with this id from StudyMgr +// return aMgr->GetStudyByID( id ); +//} + +/*! + Constructor + \param DisplayTrihedron - is trihedron displayed +*/ +SOCC_Viewer::SOCC_Viewer( bool DisplayTrihedron ) +: OCCViewer_Viewer( DisplayTrihedron ) +{ +} + +/*! + Destructor +*/ +SOCC_Viewer::~SOCC_Viewer() +{ +} + +/*! + Hilights/unhilights object in viewer + \param obj - object to be updated + \param hilight - if it is true, object will be hilighted, otherwise it will be unhilighted + \param update - update current viewer +*/ +bool SOCC_Viewer::highlight( const Handle(SALOME_InteractiveObject)& obj, + bool hilight, bool upd ) +{ + bool isInLocal = getAISContext()->HasOpenedContext(); + //SUIT_Study* ActiveStudy = SUIT_Application::getDesktop()->getActiveStudy(); + //SALOME_Selection* Sel = SALOME_Selection::Selection( ActiveStudy->getSelection() ); + + AIS_ListOfInteractive List; + getAISContext()->DisplayedObjects(List); + + AIS_ListIteratorOfListOfInteractive ite(List); + for ( ; ite.More(); ite.Next() ) + { + Handle(SALOME_InteractiveObject) anObj = + Handle(SALOME_InteractiveObject)::DownCast( ite.Value()->GetOwner() ); + + if ( !anObj.IsNull() && anObj->hasEntry() && anObj->isSame( obj ) ) + { + if ( !isInLocal ) + OCCViewer_Viewer::highlight( ite.Value(), hilight, false ); + // highlight subshapes only when local selection is active + else + { + /*if ( ite.Value()->IsKind( STANDARD_TYPE( SALOME_AISShape ) ) ) + { + Handle(SALOME_AISShape) aSh = Handle(SALOME_AISShape)::DownCast( ite.Value() ); + TColStd_IndexedMapOfInteger MapIndex; + Sel->GetIndex( IObject, MapIndex ); + aSh->highlightSubShapes( MapIndex, highlight ); + }*/ + } + break; + } + } + + if( upd ) + update(); + + return false; +} + +/*! + \return true if object is in viewer or in collector + \param obj - object to be checked + \param onlyInViewer - search object only in viewer (so object must be displayed) +*/ +bool SOCC_Viewer::isInViewer( const Handle(SALOME_InteractiveObject)& obj, + bool onlyInViewer ) +{ + AIS_ListOfInteractive List; + getAISContext()->DisplayedObjects(List); + + if( !onlyInViewer ) { + AIS_ListOfInteractive List1; + getAISContext()->ObjectsInCollector(List1); + List.Append(List1); + } + + AIS_ListIteratorOfListOfInteractive ite(List); + for ( ; ite.More(); ite.Next() ) + { + Handle(SALOME_InteractiveObject) anObj = + Handle(SALOME_InteractiveObject)::DownCast( ite.Value()->GetOwner() ); + + if ( !anObj.IsNull() && anObj->hasEntry() && anObj->isSame( obj ) ) + return true; + } + return false; +} + +/*! + \return true if object is displayed in viewer + \param obj - object to be checked +*/ +bool SOCC_Viewer::isVisible( const Handle(SALOME_InteractiveObject)& obj ) +{ + AIS_ListOfInteractive List; + getAISContext()->DisplayedObjects( List ); + + AIS_ListIteratorOfListOfInteractive ite( List ); + for ( ; ite.More(); ite.Next() ) + { + Handle(SALOME_InteractiveObject) anObj = + Handle(SALOME_InteractiveObject)::DownCast( ite.Value()->GetOwner() ); + + if ( !anObj.IsNull() && anObj->hasEntry() && anObj->isSame( obj ) ) + return getAISContext()->IsDisplayed( ite.Value() ); + } + + return false; +} + +/*! + Sets color of object + \param obj - object to be updated + \param color - new color + \param update - update current viewer +*/ +void SOCC_Viewer::setColor( const Handle(SALOME_InteractiveObject)& obj, + const QColor& color, bool update ) +{ + AIS_ListOfInteractive List; + getAISContext()->DisplayedObjects(List); + + AIS_ListIteratorOfListOfInteractive ite(List); + for ( ; ite.More(); ite.Next() ) + { + Handle(SALOME_InteractiveObject) anObj = + Handle(SALOME_InteractiveObject)::DownCast( ite.Value()->GetOwner() ); + + if ( !anObj.IsNull() && anObj->hasEntry() && anObj->isSame( obj ) ) + { + OCCViewer_Viewer::setColor( ite.Value(), color, update ); + return; + } + } +} + +/*! + Changes display mode of object + \param obj - object to be processed + \param mode - new display mode + \param update - update current viewer +*/ +void SOCC_Viewer::switchRepresentation( const Handle(SALOME_InteractiveObject)& obj, + int mode, bool update ) +{ + AIS_ListOfInteractive List; + getAISContext()->DisplayedObjects(List); + + AIS_ListIteratorOfListOfInteractive ite(List); + for ( ; ite.More(); ite.Next() ) + { + Handle(SALOME_InteractiveObject) anObj = + Handle(SALOME_InteractiveObject)::DownCast( ite.Value()->GetOwner() ); + + if ( !anObj.IsNull() && anObj->hasEntry() && anObj->isSame( obj ) ) + { + OCCViewer_Viewer::switchRepresentation( ite.Value(), mode, update ); + return; + } + } +} + +/*! + Changes transparency of object + \param obj - object to be processed + \param trans - new transparency + \param update - update current viewer +*/ +void SOCC_Viewer::setTransparency( const Handle(SALOME_InteractiveObject)& obj, + float trans, bool update ) +{ + AIS_ListOfInteractive List; + getAISContext()->DisplayedObjects( List ); + + AIS_ListIteratorOfListOfInteractive ite( List ); + for ( ; ite.More(); ite.Next() ) + { + Handle(SALOME_InteractiveObject) anObj = + Handle(SALOME_InteractiveObject)::DownCast( ite.Value()->GetOwner() ); + + if ( !anObj.IsNull() && anObj->hasEntry() && anObj->isSame( obj ) ) + { + OCCViewer_Viewer::setTransparency( ite.Value(), trans, update ); + return; + } + } +} + +/*! + Changes name of object + \param obj - object to be renamed + \param name - new name +*/ +void SOCC_Viewer::rename( const Handle(SALOME_InteractiveObject)& obj, + const QString& name ) +{ + AIS_ListOfInteractive List; + getAISContext()->DisplayedObjects(List); + + AIS_ListIteratorOfListOfInteractive ite(List); + while (ite.More()) + { + if (ite.Value()->IsKind(STANDARD_TYPE(SALOME_AISShape))) + { + Handle(SALOME_AISShape) aSh = Handle(SALOME_AISShape)::DownCast(ite.Value()); + + if ( aSh->hasIO() ) + { + Handle(SALOME_InteractiveObject) IO = aSh->getIO(); + if ( IO->isSame( obj ) ) + { + aSh->setName( (char*)name.latin1() ); + break; + } + } + } + else if ( ite.Value()->IsKind( STANDARD_TYPE( SALOME_AISObject ) ) ) + { + Handle(SALOME_AISObject) aSh = Handle(SALOME_AISObject)::DownCast( ite.Value() ); + + // Add code here, if someone create a MODULE_AISObject. + } + ite.Next(); + } +} + + +/*! + Display presentation +*/ +void SOCC_Viewer::Display( const SALOME_OCCPrs* prs ) +{ + // try do downcast object + const SOCC_Prs* anOCCPrs = dynamic_cast( prs ); + if ( !anOCCPrs || anOCCPrs->IsNull() ) + return; + + // get SALOMEDS Study + // Temporarily commented to avoid awful dependecy on SALOMEDS + // TODO: better mechanism of storing display/erse status in a study + // should be provided... + // _PTR(Study) study(getStudyDS()); + + // get context + Handle (AIS_InteractiveContext) ic = getAISContext(); + + // get all displayed objects + AIS_ListOfInteractive List; + ic->DisplayedObjects( List ); + // get objects in the collector + AIS_ListOfInteractive ListCollector; + ic->ObjectsInCollector( ListCollector ); + + // get objects to be displayed + AIS_ListOfInteractive anAISObjects; + anOCCPrs->GetObjects( anAISObjects ); + + AIS_ListIteratorOfListOfInteractive aIter( anAISObjects ); + for ( ; aIter.More(); aIter.Next() ) + { + Handle(AIS_InteractiveObject) anAIS = aIter.Value(); + if ( !anAIS.IsNull() ) + { + // try to find presentation in the viewer + bool bDisplayed = false; + AIS_ListIteratorOfListOfInteractive ite( List ); + for ( ; ite.More(); ite.Next() ) + { + // compare presentations by handles + // if the object is already displayed - nothing to do more + if ( ite.Value() == anAIS ) + { + // Deactivate object if necessary + if ( !anOCCPrs->ToActivate() ) + ic->Deactivate( anAIS ); + bDisplayed = true; + break; + } + } + + if ( bDisplayed ) + continue; + + // then try to find presentation in the collector + bDisplayed = false; + ite.Initialize( ListCollector ); + for ( ; ite.More(); ite.Next() ) + { + // compare presentations by handles + // if the object is in collector - display it + if ( ite.Value() == anAIS ) + { + ic->DisplayFromCollector( anAIS, false ); + + // Deactivate object if necessary + if ( !anOCCPrs->ToActivate() ) + ic->Deactivate( anAIS ); + bDisplayed = true; + + // Set visibility flag + // Temporarily commented to avoid awful dependecy on SALOMEDS + // TODO: better mechanism of storing display/erse status in a study + // should be provided... + //Handle(SALOME_InteractiveObject) anObj = + // Handle(SALOME_InteractiveObject)::DownCast( anAIS->GetOwner() ); + //if ( !anObj.IsNull() && anObj->hasEntry() ) + //{ + // if ( study ) + // ToolsGUI::SetVisibility( study, anObj->getEntry(), true, this ); + //} + break; + } + } + if ( bDisplayed ) + continue; + + // if object is not displayed and not found in the collector - display it + if ( anAIS->IsKind( STANDARD_TYPE(AIS_Trihedron) ) ) + { + Handle(AIS_Trihedron) aTrh = Handle(AIS_Trihedron)::DownCast( anAIS ); + double aNewSize = 100, aSize = 100; + getTrihedronSize( aNewSize, aSize ); + aTrh->SetSize( aTrh == getTrihedron() ? aNewSize : 0.5 * aNewSize ); + } + + ic->Display( anAIS, false ); + + // Set visibility flag + // Temporarily commented to avoid awful dependecy on SALOMEDS + // TODO: better mechanism of storing display/erse status in a study + // should be provided... + //Handle(SALOME_InteractiveObject) anObj = + // Handle(SALOME_InteractiveObject)::DownCast( anAIS->GetOwner() ); + //if ( !anObj.IsNull() && anObj->hasEntry() ) + //{ + // if ( study ) + // ToolsGUI::SetVisibility( study, anObj->getEntry(), true, this ); + //} + + // Deactivate object if necessary + if ( !anOCCPrs->ToActivate() ) + ic->Deactivate( anAIS ); + } + } +} + + +/*! + Erase presentation +*/ +void SOCC_Viewer::Erase( const SALOME_OCCPrs* prs, const bool forced ) +{ + // try do downcast object + const SOCC_Prs* anOCCPrs = dynamic_cast( prs ); + if ( !anOCCPrs || anOCCPrs->IsNull() ) + return; + + // get SALOMEDS Study + // Temporarily commented to avoid awful dependecy on SALOMEDS + // TODO: better mechanism of storing display/erse status in a study + // should be provided... + // _PTR(Study) study(getStudyDS()); + + // get context + Handle(AIS_InteractiveContext) ic = getAISContext(); + + // get objects to be erased + AIS_ListOfInteractive anAISObjects; + anOCCPrs->GetObjects( anAISObjects ); + + AIS_ListIteratorOfListOfInteractive aIter( anAISObjects ); + for ( ; aIter.More(); aIter.Next() ) { + Handle(AIS_InteractiveObject) anAIS = aIter.Value(); + if ( !anAIS.IsNull() ) { + // erase the object from context : move it to collector + ic->Erase( anAIS, false, forced ? false : true ); + + // Set visibility flag if necessary + // Temporarily commented to avoid awful dependecy on SALOMEDS + // TODO: better mechanism of storing display/erse status in a study + // should be provided... + //if ( !forced ) + //{ + // Handle(SALOME_InteractiveObject) anObj = + // Handle(SALOME_InteractiveObject)::DownCast( anAIS->GetOwner() ); + // if ( !anObj.IsNull() && anObj->hasEntry() ) + // { + // if ( study ) + // ToolsGUI::SetVisibility( study, anObj->getEntry(), true, this ); + // } + //} + } + } +} + + +/*! + Erase all presentations +*/ +void SOCC_Viewer::EraseAll( const bool forced ) +{ + // get SALOMEDS Study + // Temporarily commented to avoid awful dependecy on SALOMEDS + // TODO: better mechanism of storing display/erse status in a study + // should be provided... + // _PTR(Study) study(getStudyDS()); + + // get context + Handle(AIS_InteractiveContext) ic = getAISContext(); + + // check if trihedron is displayed + Standard_Boolean isTrihedronDisplayed = ic->IsDisplayed( getTrihedron() ); + + // get objects to be erased (all currently displayed objects) + AIS_ListOfInteractive aList; + ic->DisplayedObjects( aList ); + AIS_ListIteratorOfListOfInteractive anIter( aList ); + for ( ; anIter.More(); anIter.Next() ) { + if ( isTrihedronDisplayed && anIter.Value()->DynamicType() == STANDARD_TYPE( AIS_Trihedron ) ) + continue; + + // erase an object + Handle(AIS_InteractiveObject) anIO = anIter.Value(); + ic->Erase( anIO, false, forced ? false : true ); + + // Set visibility flag if necessary + // Temporarily commented to avoid awful dependecy on SALOMEDS + // TODO: better mechanism of storing display/erse status in a study + // should be provided... + //if ( !forced ) { + // Handle(SALOME_InteractiveObject) anObj = + // Handle(SALOME_InteractiveObject)::DownCast( anIO->GetOwner() ); + + // if ( !anObj.IsNull() && anObj->hasEntry() ) { + // if ( study ) + // ToolsGUI::SetVisibility( study, anObj->getEntry(), true, this ); + // } + //} + } + + // display trihedron if necessary + if ( isTrihedronDisplayed ) + getAISContext()->Display( getTrihedron() ); + else + Repaint(); +} + +/*! + Create presentation corresponding to the entry +*/ +SALOME_Prs* SOCC_Viewer::CreatePrs( const char* entry ) +{ + SOCC_Prs* prs = new SOCC_Prs(); + if ( entry ) + { + // get context + Handle(AIS_InteractiveContext) ic = getAISContext(); + + // get displayed objects + AIS_ListOfInteractive List; + ic->DisplayedObjects( List ); + // get objects in the collector + AIS_ListOfInteractive ListCollector; + ic->ObjectsInCollector( ListCollector ); + List.Append( ListCollector ); + + AIS_ListIteratorOfListOfInteractive ite( List ); + for ( ; ite.More(); ite.Next() ) + { + Handle(SALOME_InteractiveObject) anObj = + Handle(SALOME_InteractiveObject)::DownCast( ite.Value()->GetOwner() ); + + if ( !anObj.IsNull() && anObj->hasEntry() && strcmp( anObj->getEntry(), entry ) == 0 ) + prs->AddObject( ite.Value() ); + } + } + return prs; +} + +/*! + Activates selection of sub shapes +*/ +void SOCC_Viewer::LocalSelection( const SALOME_OCCPrs* thePrs, const int theMode ) +{ + Handle(AIS_InteractiveContext) ic = getAISContext(); + + const SOCC_Prs* anOCCPrs = dynamic_cast( thePrs ); + if ( ic.IsNull() ) + return; + + // Open local context if there is no one + bool allObjects = thePrs == 0 || thePrs->IsNull(); + if ( !ic->HasOpenedContext() ) { + ic->ClearCurrents( false ); + ic->OpenLocalContext( allObjects, true, true ); + } + + AIS_ListOfInteractive anObjs; + // Get objects to be activated + if ( allObjects ) + ic->DisplayedObjects( anObjs ); + else + anOCCPrs->GetObjects( anObjs ); + + // Activate selection of objects from prs + AIS_ListIteratorOfListOfInteractive aIter( anObjs ); + for ( ; aIter.More(); aIter.Next() ) { + Handle(AIS_InteractiveObject) anAIS = aIter.Value(); + if ( !anAIS.IsNull() ) + { + if ( anAIS->IsKind( STANDARD_TYPE( AIS_Shape ) ) ) + { + ic->Load( anAIS, -1, false ); + ic->Activate( anAIS, AIS_Shape::SelectionMode( (TopAbs_ShapeEnum)theMode ) ); + } + else if ( anAIS->DynamicType() != STANDARD_TYPE(AIS_Trihedron) ) + { + ic->Load( anAIS, -1, false ); + ic->Activate( anAIS, theMode ); + } + } + } +} + +/*! + Deactivates selection of sub shapes +*/ +void SOCC_Viewer::GlobalSelection( const bool update ) const +{ + Handle(AIS_InteractiveContext) ic = getAISContext(); + if ( !ic.IsNull() ) + { + ic->CloseAllContexts( false ); + if ( update ) + ic->CurrentViewer()->Redraw(); + } +} + +/*! + Auxiliary method called before displaying of objects +*/ +void SOCC_Viewer::BeforeDisplay( SALOME_Displayer* d ) +{ + d->BeforeDisplay( this, SALOME_OCCViewType() ); +} + +/*! + Auxiliary method called after displaying of objects +*/ +void SOCC_Viewer::AfterDisplay( SALOME_Displayer* d ) +{ + d->AfterDisplay( this, SALOME_OCCViewType() ); +} + +/*! + Get new and current trihedron size corresponding to the current model size +*/ +bool SOCC_Viewer::getTrihedronSize( double& theNewSize, double& theSize ) +{ + theNewSize = 100; + theSize = 100; + + //SRN: BUG IPAL8996, a usage of method ActiveView without an initialization + Handle(V3d_Viewer) viewer = getViewer3d(); + viewer->InitActiveViews(); + if(!viewer->MoreActiveViews()) return false; + + Handle(V3d_View) view3d = viewer->ActiveView(); + //SRN: END of fix + + if ( view3d.IsNull() ) + return false; + + double Xmin = 0, Ymin = 0, Zmin = 0, Xmax = 0, Ymax = 0, Zmax = 0; + double aMaxSide; + + view3d->View()->MinMaxValues( Xmin, Ymin, Zmin, Xmax, Ymax, Zmax ); + + if ( Xmin == RealFirst() || Ymin == RealFirst() || Zmin == RealFirst() || + Xmax == RealLast() || Ymax == RealLast() || Zmax == RealLast() ) + return false; + + aMaxSide = Xmax - Xmin; + if ( aMaxSide < Ymax -Ymin ) aMaxSide = Ymax -Ymin; + if ( aMaxSide < Zmax -Zmin ) aMaxSide = Zmax -Zmin; + + float aSizeInPercents = SUIT_Session::session()->resourceMgr()->doubleValue("Viewer","TrihedronSize", 105.); + + static float EPS = 5.0E-3; + theSize = getTrihedron()->Size(); + theNewSize = aMaxSide*aSizeInPercents / 100.0; + + return fabs( theNewSize - theSize ) > theSize * EPS || + fabs( theNewSize - theSize) > theNewSize * EPS; +} + + +/*! + Updates current viewer +*/ +void SOCC_Viewer::Repaint() +{ +// onAdjustTrihedron(); + getViewer3d()->Update(); +} + + +/*! + create SOCC_ViewWindow +*/ +SUIT_ViewWindow* SOCC_Viewer::createView( SUIT_Desktop* theDesktop ) +{ + SOCC_ViewWindow* view = new SOCC_ViewWindow(theDesktop, this); + initView( view ); + return view; +} diff --git a/src/SOCC/SOCC_ViewWindow.cxx b/src/SOCC/SOCC_ViewWindow.cxx index ce28624a0..56616e8ce 100644 --- a/src/SOCC/SOCC_ViewWindow.cxx +++ b/src/SOCC/SOCC_ViewWindow.cxx @@ -22,7 +22,9 @@ #include "SUIT_Accel.h" -//---------------------------------------------------------------------------- +/*! + Constructor +*/ SOCC_ViewWindow ::SOCC_ViewWindow( SUIT_Desktop* theDesktop, OCCViewer_Viewer* theModel) @@ -30,13 +32,18 @@ SOCC_ViewWindow { } -//---------------------------------------------------------------------------- +/*! + Destructor +*/ SOCC_ViewWindow ::~SOCC_ViewWindow() { } -//---------------------------------------------------------------------------- +/*! + Performs action + \param theAction - type of action +*/ void SOCC_ViewWindow ::action( const int theAction ) -- 2.39.2