-//=================================================================================
-// function : GeometryGUI::DefinePopup()
-// purpose : Called from desktop to define popup menu [static]
-//=================================================================================
-/*
-void GeometryGUI::DefinePopup(QString& theContext, QString& theParent, QString& theObject)
-{
- QAD_Study* ActiveStudy = QAD_Application::getDesktop()->getActiveStudy();
- SALOME_Selection* Sel = SALOME_Selection::Selection(ActiveStudy->getSelection());
-
- theObject = "";
- theContext = "";
-
- if ( theParent == "Viewer" ) {
- if ( Sel->IObjectCount() == 0 )
- theContext = "NothingSelected";
- }
-
- if ( Sel->IObjectCount() == 1 ) {
- Handle(SALOME_InteractiveObject) IO = Sel->firstIObject();
- if( IO->hasEntry() ) {
- SALOMEDS::SObject_var sobj = ActiveStudy->getStudyDocument()->FindObjectID( IO->getEntry() );
- if ( !sobj->_is_nil() ) {
- SALOMEDS::SComponent_var scomp = sobj->GetFatherComponent();
- if ( !strcmp(scomp->GetID(), IO->getEntry() ) ) {
- // component is selected
- theObject = "Component";
- }
- else {
- GEOM::GEOM_Object_var aGObj = GEOM::GEOM_Object::_narrow( sobj->GetObject() );
- if ( !CORBA::is_nil( aGObj ) ) {
- switch( aGObj->GetType() ) {
- case GEOM_GROUP:
- theObject = "Group";
- break;
- default:
- theObject = "Shape";
- break;
- }
- }
- }
- }
- }
- }
-}
-
-//=================================================================================
-// function : GeometryGUI::CustomPopup()
-// purpose : Called from desktop to create popup menu [static]
-//=================================================================================
-bool GeometryGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* popup, const QString& theContext,
- const QString& theParent, const QString& theObject)
-{
- GeometryGUI* geomGUI = GetGeomGUI();
-
- // Deactivate any non modal dialog box to get the neutral point
- geomGUI->EmitSignalDeactivateDialog();
- QAD_Study* anActiveStudy = parent->getActiveStudy();
- QAD_StudyFrame* aStudyFrame = anActiveStudy->getActiveStudyFrame();
- QAD_ViewFrame* aViewFrame = aStudyFrame->getRightFrame()->getViewFrame();
- SALOME_Selection* Sel = SALOME_Selection::Selection(anActiveStudy->getSelection());
- QString parentComponent = ((SALOMEGUI_Desktop*)parent)->getComponentFromSelection();
- bool isOCCViewer = aViewFrame->getTypeView() == VIEW_OCC;
- bool isVTKViewer = aViewFrame->getTypeView() == VIEW_VTK;
- int aDisplayMode = 0;
- QString objectName;
-
- if ( aViewFrame->getTypeView() == VIEW_OCC )
- aDisplayMode = ((OCCViewer_ViewFrame*)aViewFrame)->getViewer()->getAISContext()->DisplayMode();
- else if ( aViewFrame->getTypeView() == VIEW_VTK )
- aDisplayMode = (dynamic_cast<SVTK_ViewFrame*>( aViewFrame )->getRWInteractor()->GetDisplayMode();
-
- int nbSel = Sel->IObjectCount();
-
- if( nbSel == 0 ) {
- ////// NOTHING SELECTED
- popup->clear();
- }
- else if ( nbSel == 1 ) {
- ////// SINGLE OBJECT SELECTION
- if ( parentComponent != parent->getActiveComponent() ) {
- ////// selected object does not belong to GEOM module:
- // remove all commands except Display/Erase...
- while ( 1 ) {
- int id = popup->idAt( 0 );
- if ( id <= QAD_TopLabel_Popup_ID )
- popup->removeItemAt( 0 );
- else
- break;
- }
- }
- else {
- ////// selected object belong to the GEOM module
- // get interactive object
- Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject();
- objectName = IObject->getName();
- // if object has entry get SObject
- SALOMEDS::SObject_var SO;
- if ( IObject->hasEntry() )
- SO = anActiveStudy->getStudyDocument()->FindObjectID( IObject->getEntry() );
-
- if ( theObject == "Component" ) {
- ////// menu for component
- if ( !isOCCViewer && !isVTKViewer ) {
- popup->removeItem( QAD_DisplayOnly_Popup_ID );
- popup->removeItem( QAD_Display_Popup_ID );
- popup->removeItem( QAD_Erase_Popup_ID );
- }
- }
- else {
- ////// not component (should be shape)
- if ( IObject->hasEntry() ) /////// VSR : TO BE REMOVED
- popup->removeItem( 804 ); // "Add in Study"
-
- // Here could be analysis of the geom shape's type
- // ... //
-
- SALOMEDS::GenericAttribute_var aTmpAttr;
- if( SO->_is_nil() || SO->GetFatherComponent()->FindAttribute( aTmpAttr, "AttributeIOR") )
- popup->removeItem( 9024 ); // "Open" /////// VSR : TO BE REMOVED
-
- if ( !isOCCViewer && theParent == "ObjectBrowser" ) {
- if ( theObject == "Shape" )
- popup->removeItem( 800 ); // Create Group
- else if ( theObject == "Group" )
- popup->removeItem( 801 ); // Edit Group
- }
-
- if ( isOCCViewer || isVTKViewer ) {
- ////// current viewer is OCC or VTK
- SALOME_Prs* prs = aViewFrame->CreatePrs( IObject->getEntry() );
- if ( aViewFrame->isVisible( IObject ) ) {
- ////// object is already displayed in the viewer
- popup->removeItem( QAD_Display_Popup_ID );
- if ( isOCCViewer ) {
- ////// OCC viewer only
- OCCViewer_Prs* occPrs = dynamic_cast<OCCViewer_Prs*>( prs );
- if ( occPrs && !occPrs->IsNull() ) {
- AIS_ListOfInteractive ioList;
- occPrs->GetObjects( ioList );
- QMenuItem* mi = popup->findItem( 803 );
- if ( mi && mi->popup() ) {
- if ( ioList.First()->DisplayMode() == 0 )
- mi->popup()->setItemChecked( 80311, true ); // "Wireframe"
- else if ( ioList.First()->DisplayMode() == 1 )
- mi->popup()->setItemChecked( 80312, true ); // "Shading"
- else if ( ioList.First()->DisplayMode() < 0 )
- mi->popup()->setItemChecked( aDisplayMode == 0 ? 80311 : 80312 , true ); // "Wireframe" or "Shading"
- }
- }
- }
- else {
- ////// VTK viewer only
- popup->removeItem( 8034 ); // "Isos"
- SVTK_Prs* vtkPrs = dynamic_cast<SVTK_Prs*>( prs );
- if ( vtkPrs && !vtkPrs->IsNull() ) {
- vtkActorCollection* actorList = vtkPrs->GetObjects();
- actorList->InitTraversal();
- SALOME_Actor* ac = SALOME_Actor::SafeDownCast( actorList->GetNextActor() );
- QMenuItem* mi = popup->findItem( 803 );
- if ( ac && mi && mi->popup() ) {
- if ( ac->getDisplayMode() == 0 )
- mi->popup()->setItemChecked( 80311, true ); // "Wireframe"
- else if ( ac->getDisplayMode() == 1 )
- mi->popup()->setItemChecked( 80312, true ); // "Shading"
- else
- mi->popup()->setItemChecked( aDisplayMode == 0 ? 80311 : 80312 , true ); // "Wireframe" or "Shading"
- }
- }
- }
- }
- else {
- ////// object is not yet displayed in the viewer
- popup->removeItem( 803 ); // "Display Mode"
- popup->removeItem( 8032 ); // "Color"
- popup->removeItem( 8033 ); // "Transparency"
- popup->removeItem( 8034 ); // "Isos"
- popup->removeItem( QAD_Erase_Popup_ID );
- }
- delete prs;
- }
- else {
- ////// other viewer type (neither OCC nor VTK)
- popup->removeItem( 803 ); // "Display Mode"
- popup->removeItem( 8032 ); // "Color"
- popup->removeItem( 8033 ); // "Transparency"
- popup->removeItem( 8034 ); // "Isos"
- popup->removeItem( QAD_Display_Popup_ID );
- popup->removeItem( QAD_DisplayOnly_Popup_ID );
- popup->removeItem( QAD_Erase_Popup_ID );
- }
- }
- }
- }
- else {
- ////// MULTIPLE SELECTION
- if ( parentComponent != parent->getActiveComponent() ) {
- ////// not GEOM module objects or objects belong to different modules
- // remove all commands except Display/Erase...
- while ( 1 ) {
- int id = popup->idAt( 0 );
- if ( id <= QAD_TopLabel_Popup_ID )
- popup->removeItemAt( 0 );
- else
- break;
- }
- if ( parentComponent.isNull() ) {
- ////// objects belong to different modules
- popup->removeItem(QAD_Display_Popup_ID);
- popup->removeItem(QAD_DisplayOnly_Popup_ID);
- popup->removeItem(QAD_Erase_Popup_ID);
- }
- else {
- objectName = tr( "GEOM_MEN_POPUP_NAME" ).arg( nbSel );
- }
- }
- else {
- ////// all selected objects belong to GEOM module
- popup->removeItem( 901 ); // "Rename"
-
- SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
- bool isComponent = false;
- bool needOpen = false;
- bool needDisplay = false;
- bool needErase = false;
- int needToPublish = 0;
-
- for( ;It.More();It.Next() ) {
- Handle(SALOME_InteractiveObject) anIObject = It.Value();
-
- if ( aViewFrame->isVisible( anIObject ) )
- needErase = true;
- else
- needDisplay = true;
-
- if( anIObject->hasEntry() ) {
- needToPublish = -1; /////// VSR : TO BE REMOVED
- SALOMEDS::SObject_var obj = anActiveStudy->getStudyDocument()->FindObjectID( anIObject->getEntry() );
- SALOMEDS::GenericAttribute_var aTmpAttr;
- if ( !obj->_is_nil() && !obj->GetFatherComponent()->FindAttribute( aTmpAttr, "AttributeIOR" ) )
- needOpen = true; /////// VSR : TO BE REMOVED
- if ( !obj->_is_nil() && QString( obj->GetID() ) == QString( obj->GetFatherComponent()->GetID() ) )
- isComponent = true;
- }
- else {
- if ( needToPublish != -1 ) needToPublish = 1;
- }
- }
- if( needOpen || ( !isOCCViewer && !isVTKViewer ) ) {
- ////// Data is not loaded yet or current viewer is neither OCC nor VTK
- popup->removeItem( 803 ); // "Display Mode"
- popup->removeItem( 8032 ); // "Color"
- popup->removeItem( 8033 ); // "Transparency"
- popup->removeItem( 8034 ); // "Isos"
- popup->removeItem( 804 ); // "Add in Study"
- popup->removeItem( QAD_DisplayOnly_Popup_ID );
- popup->removeItem( QAD_Display_Popup_ID );
- popup->removeItem( QAD_Erase_Popup_ID );
- }
- else {
- popup->removeItem( 9024 ); // "Open"
- if ( needToPublish <= 0 )
- popup->removeItem( 804 ); // "Add in Study"
-
- if( isComponent ) {
- popup->removeItem( 803 ); // "Display Mode"
- popup->removeItem( 8032 ); // "Color"
- popup->removeItem( 8033 ); // "Transparency"
- popup->removeItem( 8034 ); // "Isos"
- popup->removeItem( QAD_DisplayOnly_Popup_ID );
- }
-
- if ( !needDisplay )
- popup->removeItem( QAD_Display_Popup_ID );
- if ( !needErase )
- popup->removeItem( QAD_Erase_Popup_ID );
- if ( !isOCCViewer )
- popup->removeItem( 8034 ); // "Isos"
- }
- }
- }
-
- // check popup for unnecessary separators
- QAD_Tools::checkPopup( popup );
- // find popup menu's TopLabel item (with title)
- int topItem = popup->indexOf( QAD_TopLabel_Popup_ID );
- if ( topItem >= 0 ) {
- // remove popup menu's title item
- popup->removeItem( QAD_TopLabel_Popup_ID );
- if ( theParent == "Viewer" && !objectName.isEmpty() && popup->count() > 0 ) {
- // set bold font for popup menu's title
- QFont f = popup->font(); f.setBold( TRUE );
- popup->removeItem( QAD_TopLabel_Popup_ID );
- popup->insertItem( new CustomItem( objectName, f ), QAD_TopLabel_Popup_ID, topItem );
- }
- }
-
- return false;
-}
-
-*/
-