2004-01-07 20:46:21 +05:00
|
|
|
// GEOM GEOMGUI : GUI for Geometry component
|
|
|
|
//
|
|
|
|
// Copyright (C) 2003 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.
|
|
|
|
//
|
|
|
|
// This library is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
// Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public
|
|
|
|
// License along with this library; if not, write to the Free Software
|
|
|
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
//
|
2008-03-07 12:45:34 +05:00
|
|
|
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
2004-01-07 20:46:21 +05:00
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// File : EntityGUI.cxx
|
|
|
|
// Author : Damien COQUERET
|
|
|
|
// Module : GEOM
|
2004-12-01 15:39:14 +05:00
|
|
|
// $Header$
|
2004-01-07 20:46:21 +05:00
|
|
|
|
|
|
|
#include "EntityGUI.h"
|
2004-12-01 15:39:14 +05:00
|
|
|
#include "GeometryGUI.h"
|
2004-01-07 20:46:21 +05:00
|
|
|
#include "GEOM_AssemblyBuilder.h"
|
2005-06-02 13:17:09 +06:00
|
|
|
|
|
|
|
#include "SUIT_Desktop.h"
|
|
|
|
#include "SUIT_Session.h"
|
|
|
|
#include "SUIT_ViewWindow.h"
|
|
|
|
#include "OCCViewer_ViewModel.h"
|
|
|
|
#include "OCCViewer_ViewManager.h"
|
|
|
|
#include "SalomeApp_Study.h"
|
|
|
|
#include "SalomeApp_Tools.h"
|
2008-03-07 12:45:34 +05:00
|
|
|
#include "SalomeApp_Application.h"
|
2004-01-07 20:46:21 +05:00
|
|
|
|
|
|
|
#include <TopoDS_Compound.hxx>
|
|
|
|
#include <BRep_Builder.hxx>
|
|
|
|
#include <TopExp_Explorer.hxx>
|
|
|
|
|
2004-06-16 21:24:55 +06:00
|
|
|
#include "EntityGUI_SketcherDlg.h" // Sketcher
|
|
|
|
#include "EntityGUI_SubShapeDlg.h" // Method SUBSHAPE
|
|
|
|
|
|
|
|
#include "utilities.h"
|
|
|
|
|
2005-06-02 13:17:09 +06:00
|
|
|
using namespace boost;
|
2004-06-16 21:24:55 +06:00
|
|
|
using namespace std;
|
2004-01-07 20:46:21 +05:00
|
|
|
|
|
|
|
//=======================================================================
|
|
|
|
// function : EntityGUI()
|
|
|
|
// purpose : Constructor
|
|
|
|
//=======================================================================
|
2005-06-02 13:17:09 +06:00
|
|
|
EntityGUI::EntityGUI( GeometryGUI* parent ) : GEOMGUI( parent )
|
2004-01-07 20:46:21 +05:00
|
|
|
{
|
2004-06-16 21:24:55 +06:00
|
|
|
mySimulationShape1 = new AIS_Shape(TopoDS_Shape());
|
|
|
|
mySimulationShape2 = new AIS_Shape(TopoDS_Shape());
|
2004-01-07 20:46:21 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
//=======================================================================
|
|
|
|
// function : ~EntityGUI()
|
|
|
|
// purpose : Destructor
|
|
|
|
//=======================================================================
|
|
|
|
EntityGUI::~EntityGUI()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=======================================================================
|
|
|
|
// function : OnGUIEvent()
|
|
|
|
// purpose :
|
|
|
|
//=======================================================================
|
2005-06-02 13:17:09 +06:00
|
|
|
bool EntityGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent)
|
2004-01-07 20:46:21 +05:00
|
|
|
{
|
2008-03-07 12:45:34 +05:00
|
|
|
SalomeApp_Application* app = getGeometryGUI()->getApp();
|
|
|
|
if ( !app ) return false;
|
|
|
|
|
2005-06-02 13:17:09 +06:00
|
|
|
getGeometryGUI()->EmitSignalDeactivateDialog();
|
2004-12-01 15:39:14 +05:00
|
|
|
QDialog* aDlg = NULL;
|
2004-01-07 20:46:21 +05:00
|
|
|
|
|
|
|
switch (theCommandID)
|
2004-12-01 15:39:14 +05:00
|
|
|
{
|
2004-01-07 20:46:21 +05:00
|
|
|
case 404: // SKETCHER
|
2005-06-02 13:17:09 +06:00
|
|
|
getGeometryGUI()->ActiveWorkingPlane();
|
|
|
|
aDlg = new EntityGUI_SketcherDlg(getGeometryGUI(), parent, "");
|
2004-12-01 15:39:14 +05:00
|
|
|
break;
|
2004-01-07 20:46:21 +05:00
|
|
|
case 407: // EXPLODE : use ic
|
2006-05-06 14:44:32 +06:00
|
|
|
aDlg = new EntityGUI_SubShapeDlg(getGeometryGUI(), parent, "");
|
2004-12-01 15:39:14 +05:00
|
|
|
break;
|
2004-01-07 20:46:21 +05:00
|
|
|
default:
|
2008-03-07 12:45:34 +05:00
|
|
|
app->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID));
|
2004-12-01 15:39:14 +05:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if ( aDlg )
|
|
|
|
aDlg->show();
|
|
|
|
|
2006-05-06 14:44:32 +06:00
|
|
|
return true;
|
2004-01-07 20:46:21 +05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-06-16 21:24:55 +06:00
|
|
|
//=====================================================================================
|
|
|
|
// function : DisplaySimulationShape()
|
|
|
|
// purpose : Displays 'this->mySimulationShape' a pure graphical shape from a TopoDS_Shape
|
|
|
|
//=====================================================================================
|
|
|
|
void EntityGUI::DisplaySimulationShape(const TopoDS_Shape& S1, const TopoDS_Shape& S2)
|
2004-01-07 20:46:21 +05:00
|
|
|
{
|
2008-03-07 12:45:34 +05:00
|
|
|
SalomeApp_Application* app = getGeometryGUI()->getApp();
|
|
|
|
if ( !app ) return;
|
|
|
|
|
|
|
|
SUIT_ViewManager* aVM = app->desktop()->activeWindow()->getViewManager();
|
2006-05-06 14:44:32 +06:00
|
|
|
if (aVM->getType() != OCCViewer_Viewer::Type())
|
2004-06-16 21:24:55 +06:00
|
|
|
return;
|
2005-06-02 13:17:09 +06:00
|
|
|
|
2006-05-06 14:44:32 +06:00
|
|
|
OCCViewer_Viewer* v3d = ((OCCViewer_ViewManager*)aVM)->getOCCViewer();
|
2004-06-16 21:24:55 +06:00
|
|
|
Handle(AIS_InteractiveContext) ic = v3d->getAISContext();
|
|
|
|
try {
|
2006-05-06 14:44:32 +06:00
|
|
|
if (!S1.IsNull()) {
|
2004-06-16 21:24:55 +06:00
|
|
|
/* erase any previous */
|
|
|
|
ic->Erase(mySimulationShape1, Standard_True, Standard_False);
|
|
|
|
ic->ClearPrs(mySimulationShape1);
|
2006-05-06 14:44:32 +06:00
|
|
|
|
2004-06-16 21:24:55 +06:00
|
|
|
mySimulationShape1 = new AIS_Shape(TopoDS_Shape());
|
|
|
|
mySimulationShape1->Set(S1);
|
|
|
|
mySimulationShape1->SetColor(Quantity_NOC_RED);
|
2008-03-07 12:45:34 +05:00
|
|
|
|
2004-06-16 21:24:55 +06:00
|
|
|
ic->Deactivate(mySimulationShape1);
|
|
|
|
ic->Display(mySimulationShape1, Standard_False);
|
|
|
|
mySimulationShape1->UnsetColor();
|
|
|
|
}
|
2006-05-06 14:44:32 +06:00
|
|
|
if (!S2.IsNull()) {
|
2004-06-16 21:24:55 +06:00
|
|
|
ic->Erase(mySimulationShape2, Standard_True, Standard_False);
|
|
|
|
ic->ClearPrs(mySimulationShape2);
|
2004-01-07 20:46:21 +05:00
|
|
|
|
2004-06-16 21:24:55 +06:00
|
|
|
mySimulationShape2 = new AIS_Shape(TopoDS_Shape());
|
|
|
|
mySimulationShape2->Set(S2);
|
|
|
|
mySimulationShape2->SetColor(Quantity_NOC_VIOLET);
|
2004-01-07 20:46:21 +05:00
|
|
|
|
2004-06-16 21:24:55 +06:00
|
|
|
ic->Deactivate(mySimulationShape2);
|
|
|
|
ic->Display(mySimulationShape2, Standard_False);
|
|
|
|
mySimulationShape2->UnsetColor();
|
2004-01-07 20:46:21 +05:00
|
|
|
}
|
2004-06-16 21:24:55 +06:00
|
|
|
ic->UpdateCurrentViewer();
|
2004-01-07 20:46:21 +05:00
|
|
|
}
|
2004-06-16 21:24:55 +06:00
|
|
|
catch(Standard_Failure) {
|
|
|
|
MESSAGE("Exception catched in EntityGUI::DisplaySimulationShape ");
|
|
|
|
}
|
2004-01-07 20:46:21 +05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2004-06-16 21:24:55 +06:00
|
|
|
//==================================================================================
|
|
|
|
// function : EraseSimulationShape()
|
|
|
|
// purpose : Clears the display of 'mySimulationShape' a pure graphical shape
|
|
|
|
//==================================================================================
|
2004-12-01 15:39:14 +05:00
|
|
|
void EntityGUI::EraseSimulationShape()
|
2004-01-07 20:46:21 +05:00
|
|
|
{
|
2008-03-07 12:45:34 +05:00
|
|
|
SalomeApp_Application* app = getGeometryGUI()->getApp();
|
|
|
|
if ( !app ) return;
|
|
|
|
|
2005-06-02 13:17:09 +06:00
|
|
|
// get all view windows at the desktop
|
2008-03-07 12:45:34 +05:00
|
|
|
QPtrList<SUIT_ViewWindow> aWndLst = app->desktop()->windows();
|
2005-06-02 13:17:09 +06:00
|
|
|
//get all view windows, which belong to the active study
|
|
|
|
QPtrList<SUIT_ViewWindow> aWndLstAS;
|
|
|
|
SUIT_ViewWindow* vw;
|
|
|
|
for ( vw = aWndLst.first(); vw; vw = aWndLst.next() )
|
2008-03-07 12:45:34 +05:00
|
|
|
if ( vw->getViewManager()->study() == app->activeStudy() )
|
2005-06-02 13:17:09 +06:00
|
|
|
aWndLstAS.append( vw );
|
2008-03-07 12:45:34 +05:00
|
|
|
|
2005-06-02 13:17:09 +06:00
|
|
|
for ( vw = aWndLstAS.first(); vw; vw = aWndLstAS.next() ) {
|
|
|
|
if ( vw->getViewManager()->getType() == OCCViewer_Viewer::Type() ) {
|
|
|
|
OCCViewer_Viewer* v3d = ((OCCViewer_ViewManager*)(vw->getViewManager()))->getOCCViewer();
|
2004-06-16 21:24:55 +06:00
|
|
|
Handle(AIS_InteractiveContext) ic = v3d->getAISContext();
|
2004-12-01 15:39:14 +05:00
|
|
|
ic->Erase(mySimulationShape1, Standard_True, Standard_False);
|
|
|
|
ic->ClearPrs(mySimulationShape1);
|
|
|
|
ic->Erase(mySimulationShape2, Standard_True, Standard_False);
|
|
|
|
ic->ClearPrs(mySimulationShape2);
|
2004-06-16 21:24:55 +06:00
|
|
|
ic->UpdateCurrentViewer();
|
|
|
|
}
|
2004-01-07 20:46:21 +05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//=====================================================================================
|
|
|
|
// function : SObjectExist()
|
|
|
|
// purpose :
|
|
|
|
//=====================================================================================
|
2005-06-02 13:17:09 +06:00
|
|
|
bool EntityGUI::SObjectExist(const _PTR(SObject)& theFatherObject, const char* IOR)
|
2004-01-07 20:46:21 +05:00
|
|
|
{
|
2008-03-07 12:45:34 +05:00
|
|
|
SalomeApp_Application* app = getGeometryGUI()->getApp();
|
|
|
|
if ( !app ) return false;
|
|
|
|
SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
|
2005-06-02 13:17:09 +06:00
|
|
|
if ( !appStudy ) return false;
|
2008-03-07 12:45:34 +05:00
|
|
|
|
2005-06-02 13:17:09 +06:00
|
|
|
_PTR(Study) aStudy = appStudy->studyDS();
|
|
|
|
_PTR(ChildIterator) it ( aStudy->NewChildIterator(theFatherObject) );
|
|
|
|
_PTR(SObject) RefSO;
|
|
|
|
_PTR(GenericAttribute) anAttr;
|
2004-01-07 20:46:21 +05:00
|
|
|
for(; it->More();it->Next()) {
|
2005-06-02 13:17:09 +06:00
|
|
|
_PTR(SObject) SO ( it->Value() );
|
2004-01-07 20:46:21 +05:00
|
|
|
if(SO->FindAttribute(anAttr, "AttributeIOR")) {
|
2005-06-02 13:17:09 +06:00
|
|
|
_PTR(AttributeIOR) anIOR ( anAttr );
|
|
|
|
if(strcmp( anIOR->Value().c_str(), IOR ) == 0)
|
2004-01-07 20:46:21 +05:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if(SO->ReferencedObject(RefSO)) {
|
|
|
|
if(RefSO->FindAttribute(anAttr, "AttributeIOR")) {
|
2005-06-02 13:17:09 +06:00
|
|
|
_PTR(AttributeIOR) anIOR ( anAttr );
|
|
|
|
if(strcmp(anIOR->Value().c_str(), IOR) == 0)
|
2004-01-07 20:46:21 +05:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=====================================================================================
|
|
|
|
// EXPORTED METHODS
|
|
|
|
//=====================================================================================
|
|
|
|
extern "C"
|
|
|
|
{
|
2008-03-07 12:45:34 +05:00
|
|
|
GEOM_ENTITYGUI_EXPORT
|
2005-06-02 13:17:09 +06:00
|
|
|
GEOMGUI* GetLibGUI( GeometryGUI* parent )
|
2004-12-01 15:39:14 +05:00
|
|
|
{
|
2008-03-07 12:45:34 +05:00
|
|
|
return new EntityGUI( parent );
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
2004-01-07 20:46:21 +05:00
|
|
|
}
|