-// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2015 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 "HYDROGUI_Tool.h"
#include "HYDROGUI_UpdateFlags.h"
+#include <HYDROData_ShapesTool.h>
+
#include <LightApp_Application.h>
#include <LightApp_SelectionMgr.h>
#include <LightApp_UpdateFlags.h>
abort();
return;
}
- else if ( myEditedObject->IsMustBeUpdated() ) {
- myEditedObject->Update();
- }
// Set the edited object name to the panel
aPanel->setName( myEditedObject->GetName() );
}
bool HYDROGUI_TranslateObstacleOp::processApply( int& theUpdateFlags,
- QString& theErrorMsg )
+ QString& theErrorMsg,
+ QStringList& theBrowseObjectsEntries )
{
HYDROGUI_TranslateObstacleDlg* aPanel = ::qobject_cast<HYDROGUI_TranslateObstacleDlg*>( inputPanel() );
if ( !aPanel || myEditedObject.IsNull() ) {
return false;
}
- // Get the translated shape
- TopoDS_Shape aTranslatedShape = getTranslatedShape();
- if ( aTranslatedShape.IsNull() ) {
- return false;
- }
-
// Erase preview
erasePreview();
- // Set the translated shape to the obstacle
- myEditedObject->SetShape3D( aTranslatedShape );
+ // Get the translated shape
+ double aDx = aPanel->getDx();
+ double aDy = aPanel->getDy();
+ double aDz = aPanel->getDz();
+
+ // Translate the obstacle
+ myEditedObject->Translate( aDx, aDy, aDz );
myEditedObject->Update();
module()->setIsToUpdate( myEditedObject );
void HYDROGUI_TranslateObstacleOp::createPreview()
{
- if ( myEditedObject.IsNull() ) {
+ HYDROGUI_TranslateObstacleDlg* aPanel = (HYDROGUI_TranslateObstacleDlg*)inputPanel();
+ if ( myEditedObject.IsNull() || !aPanel )
return;
- }
// Create preview presentation if necessary
if ( !myPreviewPrs ) {
LightApp_Application* anApp = module()->getApp();
- OCCViewer_ViewManager* aViewManager = ::qobject_cast<OCCViewer_ViewManager*>(
- anApp->getViewManager( OCCViewer_Viewer::Type(), true ) );
-
+
+ if ( !getPreviewManager() )
+ setPreviewManager( ::qobject_cast<OCCViewer_ViewManager*>(
+ anApp->getViewManager( OCCViewer_Viewer::Type(), true ) ) );
+ OCCViewer_ViewManager* aViewManager = getPreviewManager();
if ( aViewManager ) {
if ( OCCViewer_Viewer* aViewer = aViewManager->getOCCViewer() ) {
Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext();
if ( !aCtx.IsNull() ) {
- myPreviewPrs = new HYDROGUI_Shape( aCtx, NULL );
+ myPreviewPrs = new HYDROGUI_Shape( aCtx, NULL, getPreviewZLayer() );
myPreviewPrs->setFillingColor( myEditedObject->GetFillingColor(), false, false );
myPreviewPrs->setBorderColor( myEditedObject->GetBorderColor(), false, false );
}
}
}
- // Get the translated shape
- TopoDS_Shape aTranslatedShape = getTranslatedShape();
-
// Set the translated shape to the preview presentation
- if ( myPreviewPrs ) {
+ if ( myPreviewPrs )
+ {
+ double aDx = aPanel->getDx();
+ double aDy = aPanel->getDy();
+ double aDz = aPanel->getDz();
+ TopoDS_Shape anOriShape = myEditedObject->GetShape3D();
+
+ TopoDS_Shape aTranslatedShape = HYDROData_ShapesTool::Translated( anOriShape, aDx, aDy, aDz );
myPreviewPrs->setShape( aTranslatedShape );
}
}
createPreview();
}
-TopoDS_Shape HYDROGUI_TranslateObstacleOp::getTranslatedShape() const
-{
- TopoDS_Shape aTranslatedShape;
-
- HYDROGUI_TranslateObstacleDlg* aPanel = (HYDROGUI_TranslateObstacleDlg*)inputPanel();
- if ( aPanel && !myEditedObject.IsNull() ) {
- double aDx = aPanel->getDx();
- double aDy = aPanel->getDy();
- double aDz = aPanel->getDz();
-
- TopoDS_Shape aShape = myEditedObject->GetShape3D();
- gp_Trsf aTrsf;
- gp_Vec aVec( aDx, aDy, aDz );
- aTrsf.SetTranslation(aVec);
- TopLoc_Location aLocOrig = aShape.Location();
- gp_Trsf aTrsfOrig = aLocOrig.Transformation();
- TopLoc_Location aLocRes( aTrsf * aTrsfOrig );
- aTranslatedShape = aShape.Located( aLocRes );
- }
-
- return aTranslatedShape;
-}
\ No newline at end of file