-// 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 <GEOMUtils.hxx>
#include <GEOMGUI_DimensionProperty.h>
+#include <OCCViewer_ViewManager.h>
+#include <OCCViewer_ViewWindow.h>
+#include <OCCViewer_ViewPort3d.h>
#include <LightApp_SelectionMgr.h>
#include <SalomeApp_Application.h>
#include <SalomeApp_DataObject.h>
#include <SUIT_Session.h>
#include <SUIT_Desktop.h>
+#include <QButtonGroup>
+
#include <Aspect_PolygonOffsetMode.hxx>
+#include <Basics_OCCTVersion.hxx>
+
+#include <QButtonGroup>
+
//=================================================================================
// function : Constructor
// purpose :
SLOT( OnStartSelection( const QList<TopAbs_ShapeEnum>& ) ) );
connect( myDiameterArgs, SIGNAL( StartSelection( const QList<TopAbs_ShapeEnum>& ) ),
SLOT( OnStartSelection( const QList<TopAbs_ShapeEnum>& ) ) );
- connect( myAngleArgs, SIGNAL( StartSelection( const QList<TopAbs_ShapeEnum>& ) ),
+ connect( myAngleArgs, SIGNAL( StartSelection( const QList<TopAbs_ShapeEnum>& ) ),
SLOT( OnStartSelection( const QList<TopAbs_ShapeEnum>& ) ) );
connect( myLengthArgs, SIGNAL( StopSelection() ), SLOT( OnStopSelection() ) );
// construct main layout
QVBoxLayout* aCustomWidLayout = new QVBoxLayout( centralWidget() );
- aCustomWidLayout->setMargin( 0 );
+ aCustomWidLayout->setMargin( 0 );
aCustomWidLayout->setSpacing( 6 );
aCustomWidLayout->addWidget( aGroupArgs );
myDimensionInteractor = new MeasureGUI_DimensionInteractor( theGUI, theParent );
+ myDiameterArgs->setVisible( false );
+ myAngleArgs ->setVisible( false );
+ myLengthArgs ->setVisible( true );
+
+ myRBGroup->button( TypeButtonID_Length )->click();
+
Init();
+
+ setHelpFileName("add_dimension_page.html");
}
//=================================================================================
//=================================================================================
// function : ActiveArgs
-// purpose :
+// purpose :
//=================================================================================
MeasureGUI_CreateDimensionDlg::BaseSelectorPane* MeasureGUI_CreateDimensionDlg::ActiveArgs()
{
//=================================================================================
// function : GenerateName
-// purpose :
+// purpose :
//=================================================================================
QString MeasureGUI_CreateDimensionDlg::GenerateName( const QString& thePrefix )
{
//=================================================================================
// function : ConstructTypeChanged
-// purpose :
+// purpose :
//=================================================================================
void MeasureGUI_CreateDimensionDlg::ConstructTypeChanged( int theType )
{
//=================================================================================
// function : OnArgumentTabChanged
-// purpose :
+// purpose :
//=================================================================================
void MeasureGUI_CreateDimensionDlg::OnArgumentTabChanged()
{
return;
}
+ GEOM::GeomObjPtr aSelected = getSelected( mySelectionModes );
+ if ( aSelected.isNull() )
+ {
+ ActiveArgs()->SelectionIntoArguments( GEOM::GeomObjPtr() );
+ return;
+ }
+
+ GEOM::GeomObjPtr aSelectedMain =
+ !aSelected->IsMainShape()
+ ? aSelected->GetMainShape()
+ : GEOM::GeomObjPtr();
+
+ if ( myParentObj != aSelected && myParentObj != aSelectedMain )
+ {
+ ActiveArgs()->SelectionIntoArguments( GEOM::GeomObjPtr() );
+ return;
+ }
+
StopLocalEditing();
erasePreview();
- ActiveArgs()->SelectionIntoArguments( getSelected( mySelectionModes ) );
+ ActiveArgs()->SelectionIntoArguments( aSelected );
}
//=================================================================================
//=================================================================================
// function : ClickOnOk
-// purpose :
+// purpose :
//=================================================================================
void MeasureGUI_CreateDimensionDlg::ClickOnOk()
{
//=================================================================================
// function : ClickOnApply
-// purpose :
+// purpose :
//=================================================================================
bool MeasureGUI_CreateDimensionDlg::ClickOnApply()
{
StopLocalEditing();
+ if ( myDimension.IsNull() )
+ {
+ return true;
+ }
+
if ( !AddDimensionToOwner() )
{
return false;
if ( !isApplyAndClose() )
{
+ emit applyClicked();
Init();
+ ConstructTypeChanged( getConstructorId() );
}
return true;
//=================================================================================
// function : StartLocalEditing
-// purpose :
+// purpose :
//=================================================================================
void MeasureGUI_CreateDimensionDlg::StartLocalEditing()
{
aViewer3d->AddZLayer( myEditingLayer );
- anAISContext->OpenLocalContext( Standard_False, Standard_False );
+#if OCC_VERSION_LARGE >= 0x070400ff
+ anAISContext->Load( myDimension, PrsDim_DimensionSelectionMode_All );
+ anAISContext->SetZLayer( myDimension, myEditingLayer );
+ anAISContext->Activate( myDimension, PrsDim_DimensionSelectionMode_Line );
+ anAISContext->Activate( myDimension, PrsDim_DimensionSelectionMode_Text );
+#else
anAISContext->Load( myDimension, AIS_DSM_All );
anAISContext->SetZLayer( myDimension, myEditingLayer );
anAISContext->Activate( myDimension, AIS_DSM_Line );
anAISContext->Activate( myDimension, AIS_DSM_Text );
+#endif
+ anAISContext->Redisplay( myDimension , Standard_True );
}
//=================================================================================
// function : StopLocalEditing
-// purpose :
+// purpose :
//=================================================================================
void MeasureGUI_CreateDimensionDlg::StopLocalEditing()
{
Handle(V3d_Viewer) aViewer3d = myEditingViewer->getViewer3d();
aViewer3d->RemoveZLayer( myEditingLayer );
- anAISContext->CloseLocalContext();
+ anAISContext->Deactivate();
+ anAISContext->Activate(0);
myEditingViewer = NULL;
}
//=================================================================================
// function : Init
-// purpose :
+// purpose :
//=================================================================================
void MeasureGUI_CreateDimensionDlg::Init()
{
+ myDimension = NULL;
+
StopLocalEditing();
erasePreview();
- myDiameterArgs->setVisible( false );
- myAngleArgs ->setVisible( false );
- myLengthArgs ->setVisible( true );
+ myDiameterArgs->Reset();
myLengthArgs->Reset();
-
- myRBGroup->button( TypeButtonID_Length )->click();
+ myAngleArgs->Reset();
}
//=================================================================================
// function : CreateDimensionPrs
-// purpose :
+// purpose :
//=================================================================================
Handle(AIS_Dimension) MeasureGUI_CreateDimensionDlg::CreateDimension()
{
QColor aQColor = aResMgr->colorValue ( "Geometry", "dimensions_color", QColor( 0, 255, 0 ) );
int aLineWidth = aResMgr->integerValue( "Geometry", "dimensions_line_width", 1 );
- double aFontHeight = aResMgr->doubleValue ( "Geometry", "dimensions_font_height", 10 );
+ QFont aFont = aResMgr->fontValue ( "Geometry", "dimensions_font", QFont("Y14.5M-2009", 14) );
double anArrowLength = aResMgr->doubleValue ( "Geometry", "dimensions_arrow_length", 5 );
+ double aDefFlyout = aResMgr->doubleValue ( "Geometry", "dimensions_default_flyout", 20 );
bool isUnitsShown = aResMgr->booleanValue( "Geometry", "dimensions_show_units", false );
QString aUnitsLength = aResMgr->stringValue ( "Geometry", "dimensions_length_units", "m" );
QString aUnitsAngle = aResMgr->stringValue ( "Geometry", "dimensions_angle_units", "deg" );
+ bool aUseText3d = aResMgr->booleanValue( "Geometry", "dimensions_use_text3d", false );
- MeasureGUI_DimensionCreateTool aTool( myGeomGUI );
+ OCCViewer_ViewWindow* anActiveView = NULL;
+
+ SalomeApp_Application* anApp = myGeomGUI->getApp();
+
+ if ( anApp )
+ {
+ OCCViewer_ViewManager* aViewMgr = (OCCViewer_ViewManager*) anApp->getViewManager( OCCViewer_Viewer::Type(), false );
+ if ( aViewMgr )
+ {
+ anActiveView = (OCCViewer_ViewWindow*) aViewMgr->getActiveView();
+ }
+ }
+
+ MeasureGUI_DimensionCreateTool aTool;
+
+ aTool.Settings.DefaultFlyout = aDefFlyout;
+ aTool.Settings.ActiveView = anActiveView ? anActiveView->getViewPort()->getView() : NULL;
switch ( getConstructorId() )
{
aStyle->SetCommonColor( aColor );
aStyle->MakeUnitsDisplayed( (Standard_Boolean) isUnitsShown );
- aStyle->MakeText3d( Standard_True );
+ aStyle->MakeText3d( aUseText3d );
aStyle->MakeTextShaded( Standard_True );
- aStyle->TextAspect()->SetHeight( aFontHeight );
+ int fsize = aFont.pixelSize() != -1 ? aFont.pixelSize() : aFont.pointSize();
+ aStyle->SetExtensionSize( fsize * 0.5 );
+ aStyle->TextAspect()->SetFont( aFont.family().toLatin1().data() );
+ aStyle->TextAspect()->SetHeight( fsize );
aStyle->ArrowAspect()->SetLength( anArrowLength );
aStyle->LineAspect()->SetWidth( aLineWidth );
+
+ if ( aDimensionIO->IsKind( STANDARD_TYPE(AIS_AngleDimension) ) )
+ {
+ // show degree symbol for dimension instead of label "deg"
+ if ( aUnitsAngle == "deg" )
+ {
+ aDimensionIO->SetSpecialSymbol(0xB0);
+#if OCC_VERSION_LARGE >= 0x070400ff
+ aDimensionIO->SetDisplaySpecialSymbol( isUnitsShown ? PrsDim_DisplaySpecialSymbol_After :
+ PrsDim_DisplaySpecialSymbol_No );
+#else
+ aDimensionIO->SetDisplaySpecialSymbol( isUnitsShown ? AIS_DSS_After : AIS_DSS_No );
+#endif
+ aStyle->MakeUnitsDisplayed(Standard_False);
+ }
+ else
+ {
+#if OCC_VERSION_LARGE >= 0x070400ff
+ aDimensionIO->SetDisplaySpecialSymbol(PrsDim_DisplaySpecialSymbol_No);
+#else
+ aDimensionIO->SetDisplaySpecialSymbol(AIS_DSS_No);
+#endif
+ aStyle->MakeUnitsDisplayed( (Standard_Boolean) isUnitsShown );
+ }
+ }
+ else
+ {
+ aStyle->MakeUnitsDisplayed( (Standard_Boolean) isUnitsShown );
+ }
+
+ aDimensionIO->Attributes()->SetDimLengthDisplayUnits( aUnitsLength.toLatin1().data() );
+ aDimensionIO->Attributes()->SetDimAngleDisplayUnits( aUnitsAngle.toLatin1().data() );
aDimensionIO->SetDimensionAspect( aStyle );
aDimensionIO->SetPolygonOffsets( Aspect_POM_Fill, -1.0, -1.0 );
//=================================================================================
// class : AddDimensionToOwner
-// purpose :
+// purpose :
//=================================================================================
bool MeasureGUI_CreateDimensionDlg::AddDimensionToOwner()
{
TopoDS_Shape anParentSh;
if ( GEOMBase::GetShape( myParentObj.get(), anParentSh ) )
{
- aLCS = GEOMUtils::GetPosition( anParentSh );
+ aLCS = gp_Ax3().Transformed( anParentSh.Location().Transformation() );
}
QString aName = getNewObjectName();
//=================================================================================
// function : BaseSelectorPane::GetSelection
-// purpose :
+// purpose :
//=================================================================================
GEOM::GeomObjPtr MeasureGUI_CreateDimensionDlg::BaseSelectorPane::GetSelection( QLineEdit* theSelector ) const
{