-// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
#include "MeasureGUI_DimensionFilter.h"
#include <GEOMGUI_DimensionProperty.h>
+#include <GEOMGUI_TextTreeWdg.h>
#include <GEOMUtils.hxx>
#include <GEOMGUI_OCCSelector.h>
#include <GEOM_AISDimension.hxx>
#include <QHBoxLayout>
#include <QPixmap>
+#include <Basics_OCCTVersion.hxx>
+
//=================================================================================
// function : Constructor
// purpose :
MeasureGUI_ManageDimensionsDlg::MeasureGUI_ManageDimensionsDlg( GeometryGUI* theGUI, QWidget* theParent )
: GEOMBase_Skeleton( theGUI, theParent ),
myOperatedViewer( NULL ),
- myCurrentSelection( Selection_None )
+ myCurrentSelection( Selection_None ),
+ myCreateDialog(0)
{
SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
connect( myGeomGUI, SIGNAL( SignalDeactivateActiveDialog() ), this, SLOT( OnDeactivateThisDialog() ) );
connect( myGeomGUI, SIGNAL( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) );
- myDimensionInteractor = new MeasureGUI_DimensionInteractor( theGUI, theParent ),
+ myDimensionInteractor = new MeasureGUI_DimensionInteractor( theGUI, this ),
SelectionIntoArgument( Selection_Object );
{
myObjectSelector->PushButton1->click();
}
-
+ myIsNeedRedisplay = false;
setHelpFileName("managing_dimensions_page.html");
}
Handle(AIS_InteractiveContext) anAISContext = myOperatedViewer->getAISContext();
- anAISContext->ClearCurrents( Standard_False );
+ anAISContext->ClearCurrents( Standard_False ); // todo: deprecated OCCT API
anAISContext->ClearSelected( Standard_False );
- anAISContext->OpenLocalContext( Standard_True, Standard_False );
-
Handle(MeasureGUI_DimensionFilter) aFilter = new MeasureGUI_DimensionFilter( myEditObject->GetStudyEntry() );
anAISContext->AddFilter( aFilter );
//=================================================================================
void MeasureGUI_ManageDimensionsDlg::StopSelection()
{
+ if( !myGeomGUI || !myGeomGUI->getApp() || !myGeomGUI->getApp()->selectionMgr() )
+ return;
+
if ( myCurrentSelection == Selection_Object )
{
/* ----------------------------------------------- *
* ------------------------------------------------ */
Handle(AIS_InteractiveContext) anAISContext = myOperatedViewer->getAISContext();
-
- anAISContext->CloseLocalContext();
+ anAISContext->Deactivate();
+ anAISContext->Activate(0);
LightApp_SelectionMgr* aSelectionMgr = myGeomGUI->getApp()->selectionMgr();
anAISContext->InitSelected();
Handle(AIS_InteractiveObject) anAIS;
-
- if ( anAISContext->HasOpenedContext() )
- {
- Handle(SelectMgr_EntityOwner) anAISOwner = anAISContext->SelectedOwner();
- anAIS = Handle(AIS_InteractiveObject)::DownCast( anAISOwner->Selectable() );
- }
- else
- {
- anAIS = anAISContext->Current();
- }
+ anAIS = anAISContext->Current(); // todo: deprecated OCCT API
int aDimensionId = IdFromPrs( anAIS );
//=================================================================================
void MeasureGUI_ManageDimensionsDlg::OnAdd()
{
- QWidget* aParent = qobject_cast<QWidget*>( this->parent() );
-
- this->Suspend();
-
- MeasureGUI_CreateDimensionDlg* aCreateDlg = new MeasureGUI_CreateDimensionDlg( myEditObject, myGeomGUI, aParent );
-
- connect( aCreateDlg, SIGNAL( finished( int ) ), this, SLOT( Resume() ) );
-
- // this is necessary as the GEOMBase_Helper switches selection mode on destruction
- connect( aCreateDlg, SIGNAL( destroyed( QObject* ) ), this, SLOT( Resume() ) );
-
- aCreateDlg->updateGeometry();
- aCreateDlg->resize( aCreateDlg->minimumSizeHint() );
- aCreateDlg->show();
+ if(!myCreateDialog) {
+ QWidget* aParent = qobject_cast<QWidget*>( this->parent() );
+ this->Suspend();
+ myCreateDialog = new MeasureGUI_CreateDimensionDlg( myEditObject, myGeomGUI, aParent );
+ connect( myCreateDialog, SIGNAL( finished( int ) ), this, SLOT( Resume() ) );
+ // this is necessary as the GEOMBase_Helper switches selection mode on destruction
+ connect( myCreateDialog, SIGNAL( destroyed( QObject* ) ), this, SLOT( Resume() ) );
+ connect( myCreateDialog, SIGNAL( applyClicked() ), this, SLOT( OnDimensionAdded() ) );
+ myCreateDialog->updateGeometry();
+ myCreateDialog->resize( myCreateDialog->minimumSizeHint() );
+ myCreateDialog->show();
+ } else {
+ myCreateDialog->activateWindow();
+ }
+ myObjectSelector->setEnabled(false);
+ myDimensionView->setEnabled(false);
}
//=================================================================================
//=================================================================================
void MeasureGUI_ManageDimensionsDlg::OnShowAll()
{
- // read propety data
+ // read property data
SalomeApp_Application* anApp = myGeomGUI->getApp();
if ( !anApp )
{
//=================================================================================
void MeasureGUI_ManageDimensionsDlg::OnHideAll()
{
- // read propety data
+ // read property data
SalomeApp_Application* anApp = myGeomGUI->getApp();
if ( !anApp )
{
// function : OnInteractionFinished
// purpose :
//=================================================================================
-void MeasureGUI_ManageDimensionsDlg::OnInteractionFinished( Handle(AIS_InteractiveObject) theIO )
+void MeasureGUI_ManageDimensionsDlg::OnInteractionFinished( Handle_AIS_InteractiveObject theIO )
{
// update property data
SalomeApp_Application* anApp = myGeomGUI->getApp();
void MeasureGUI_ManageDimensionsDlg::Suspend()
{
StopSelection();
- hide();
}
//=================================================================================
//=================================================================================
void MeasureGUI_ManageDimensionsDlg::Resume()
{
- this->show();
+ if(myCreateDialog){
+ myCreateDialog = 0;
+ myObjectSelector->setEnabled(true);
+ myDimensionView->setEnabled(true);
+ }
+
if ( !myEditObject.isNull() )
{
PopulateList();
}
}
+//=================================================================================
+// function : Suspend
+// purpose :
+//=================================================================================
+void MeasureGUI_ManageDimensionsDlg::OnDimensionAdded() {
+ if ( !myEditObject.isNull() )
+ {
+ PopulateList();
+ }
+}
+
//=================================================================================
// function : ClickOnOk
// purpose :
{
return;
}
-
+
+ if( myCreateDialog ) {
+ myCreateDialog->close();
+ myCreateDialog = 0;
+ }
+
GEOMBase_Skeleton::ClickOnCancel();
}
QVariant() )
.value<GEOMGUI_DimensionProperty>();
- mySavedPropertyState.SaveToAttribute( aStudy, myEditObject->GetStudyEntry() );
+ mySavedPropertyState.SaveToAttribute( myEditObject->GetStudyEntry() );
+
+ myGeomGUI->emitDimensionsUpdated( QString( myEditObject->GetStudyEntry() ) );
return true;
}
GEOM::propertyName( GEOM::Dimensions ),
QVariant() );
- redisplay( myEditObject.get() );
+ if ( myIsNeedRedisplay ) {
+ redisplay( myEditObject.get() );
+ }
+
+ myGeomGUI->emitDimensionsUpdated( QString( myEditObject->GetStudyEntry() ) );
}
//=================================================================================
if ( myEditObject.isNull() )
{
+ myDimensionView->TreeWidget->clear();
myDimensionView->setEnabled( false );
-
return;
}
return;
}
- mySavedPropertyState.LoadFromAttribute( getStudy(), myEditObject->GetStudyEntry() );
+ mySavedPropertyState.LoadFromAttribute( myEditObject->GetStudyEntry() );
// set property state for preview
aStudy->setObjectProperty( GEOM::sharedPropertiesId(),
myEditObject->GetStudyEntry(),
GEOM::propertyName( GEOM::Dimensions ),
QVariant() );
-
- RedisplayObject();
}
//=================================================================================
tr( "WRN_MSG_CHANGES_LOST" ),
QMessageBox::Ok,
QMessageBox::Cancel );
-
- return aResponse == QMessageBox::Ok;
+ myIsNeedRedisplay = ( aResponse == QMessageBox::Ok );
+ return myIsNeedRedisplay;
}
//=================================================================================
{
return;
}
-
- Standard_Boolean isLocal = anAISContext->HasOpenedContext();
- if ( isLocal )
- {
- anAISContext->ClearSelected( Standard_False );
- }
- else
- {
- anAISContext->ClearCurrents( Standard_False );
- }
-
+ anAISContext->ClearCurrents( Standard_False ); // todo: deprecated OCCT API
SOCC_Prs* aPrs = dynamic_cast<SOCC_Prs*>( theViewer->CreatePrs( myEditObject->GetStudyEntry() ) );
AIS_ListOfInteractive aListOfIO;
const Handle(AIS_InteractiveObject)& anIO = anIt.Value();
if ( IdFromPrs( anIO ) != theId )
{
- if ( isLocal )
- {
- anAISContext->Deactivate( anIO, AIS_DSM_Line );
- anAISContext->Deactivate( anIO, AIS_DSM_Text );
- }
+#if OCC_VERSION_LARGE >= 0x070400ff
+ anAISContext->Deactivate( anIO, PrsDim_DimensionSelectionMode_Line );
+ anAISContext->Deactivate( anIO, PrsDim_DimensionSelectionMode_Text );
+#else
+ anAISContext->Deactivate( anIO, AIS_DSM_Line );
+ anAISContext->Deactivate( anIO, AIS_DSM_Text );
+#endif
continue;
}
+ anAISContext->AddOrRemoveSelected( anIO, Standard_False );
- if ( isLocal )
- {
- anAISContext->AddOrRemoveSelected( anIO, Standard_False );
- anAISContext->Activate( anIO, AIS_DSM_Line );
- anAISContext->Activate( anIO, AIS_DSM_Text );
- }
- else
- {
- anAISContext->AddOrRemoveCurrentObject( anIO, Standard_False );
- }
+#if OCC_VERSION_LARGE >= 0x070400ff
+ anAISContext->Activate( anIO, PrsDim_DimensionSelectionMode_Line );
+ anAISContext->Activate( anIO, PrsDim_DimensionSelectionMode_Text );
+#else
+ anAISContext->Activate( anIO, AIS_DSM_Line );
+ anAISContext->Activate( anIO, AIS_DSM_Text );
+#endif
+ anAISContext->AddOrRemoveCurrentObject( anIO, Standard_False ); // todo: deprecated OCCT API
anAISContext->UpdateCurrentViewer();
}
}