-// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2016 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>
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");
}
//=================================================================================
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 );
}
//=================================================================================
{
StopLocalEditing();
+ if ( myDimension.IsNull() )
+ {
+ return true;
+ }
+
if ( !AddDimensionToOwner() )
{
return false;
if ( !isApplyAndClose() )
{
+ emit applyClicked();
Init();
+ ConstructTypeChanged( getConstructorId() );
}
return true;
anAISContext->SetZLayer( myDimension, myEditingLayer );
anAISContext->Activate( myDimension, AIS_DSM_Line );
anAISContext->Activate( myDimension, AIS_DSM_Text );
+ anAISContext->Redisplay( myDimension , Standard_True );
}
//=================================================================================
Handle(V3d_Viewer) aViewer3d = myEditingViewer->getViewer3d();
aViewer3d->RemoveZLayer( myEditingLayer );
- anAISContext->CloseLocalContext();
+ anAISContext->CloseLocalContext( Standard_True );
myEditingViewer = NULL;
}
//=================================================================================
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();
}
//=================================================================================
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 );
+
+ 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( myGeomGUI );
+ 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);
+ aDimensionIO->SetDisplaySpecialSymbol( isUnitsShown ? AIS_DSS_After : AIS_DSS_No );
+ aStyle->MakeUnitsDisplayed(Standard_False);
+ }
+ else
+ {
+ aDimensionIO->SetDisplaySpecialSymbol(AIS_DSS_No);
+ 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 );
TopoDS_Shape anParentSh;
if ( GEOMBase::GetShape( myParentObj.get(), anParentSh ) )
{
- aLCS = GEOMUtils::GetPosition( anParentSh );
+ aLCS = gp_Ax3().Transformed( anParentSh.Location().Transformation() );
}
QString aName = getNewObjectName();