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
|
|
|
|
//
|
|
|
|
// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// 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 "VTKViewer_ViewModel.h"
|
|
|
|
#include "SalomeApp_Study.h"
|
|
|
|
#include "SalomeApp_Tools.h"
|
|
|
|
//#include "SALOMEGUI_ImportOperation.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
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
EntityGUI* EntityGUI::myGUIObject = 0;
|
|
|
|
|
|
|
|
//=======================================================================
|
|
|
|
// function : GetEntityGUI()
|
|
|
|
// purpose : Get the only EntityGUI object [ static ]
|
|
|
|
//=======================================================================
|
2005-06-02 13:17:09 +06:00
|
|
|
EntityGUI* EntityGUI::GetEntityGUI( GeometryGUI* parent )
|
2004-12-01 15:39:14 +05:00
|
|
|
{
|
|
|
|
if ( myGUIObject == 0 ) {
|
|
|
|
// init EntityGUI only once
|
2005-06-02 13:17:09 +06:00
|
|
|
myGUIObject = new EntityGUI( parent );
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
|
|
|
return myGUIObject;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
{
|
|
|
|
myGeomBase = new GEOMBase();
|
2005-06-02 13:17:09 +06:00
|
|
|
myGeom = GEOM::GEOM_Gen::_duplicate( GeometryGUI::GetGeomGen() );
|
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
|
|
|
{
|
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
|
2005-06-02 13:17:09 +06:00
|
|
|
aDlg = new EntityGUI_SubShapeDlg(parent, "");
|
2004-12-01 15:39:14 +05:00
|
|
|
break;
|
2004-01-07 20:46:21 +05:00
|
|
|
default:
|
2005-06-02 13:17:09 +06:00
|
|
|
SUIT_Session::session()->activeApplication()->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID));
|
2004-12-01 15:39:14 +05:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if ( aDlg )
|
|
|
|
aDlg->show();
|
|
|
|
|
2004-01-07 20:46:21 +05:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=======================================================================
|
2004-06-16 21:24:55 +06:00
|
|
|
// function : OnSketchEnd()
|
2004-01-07 20:46:21 +05:00
|
|
|
// purpose :
|
|
|
|
//=======================================================================
|
2004-06-16 21:24:55 +06:00
|
|
|
void EntityGUI::OnSketchEnd(const char *Cmd)
|
2004-01-07 20:46:21 +05:00
|
|
|
{
|
2004-12-01 15:39:14 +05:00
|
|
|
/* QAD_Application::getDesktop()->putInfo("Create sketch functionality is NOT implemented in new GEOM kernel
|
|
|
|
(no such Corba interface method). Waiting for SRN to create it...");
|
|
|
|
|
2004-06-16 21:24:55 +06:00
|
|
|
try {
|
|
|
|
GEOM::GEOM_Shape_var result = myGeom->MakeSketcher(Cmd);
|
|
|
|
if(result->_is_nil()) {
|
|
|
|
QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_NULLSHAPE"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
result->NameType(tr("GEOM_WIRE"));
|
|
|
|
if(myGeomBase->Display(result))
|
|
|
|
QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_DONE"));
|
2004-01-07 20:46:21 +05:00
|
|
|
}
|
2004-06-16 21:24:55 +06:00
|
|
|
catch(const SALOME::SALOME_Exception& S_ex) {
|
2005-06-02 13:17:09 +06:00
|
|
|
SalomeApp_Tools::QtCatchCorbaException(S_ex);
|
2004-01-07 20:46:21 +05:00
|
|
|
}
|
2004-12-01 15:39:14 +05:00
|
|
|
*/
|
2004-01-07 20:46:21 +05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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
|
|
|
{
|
2004-06-16 21:24:55 +06:00
|
|
|
//NRI DEBUG : 14/02/2002
|
2005-06-02 13:17:09 +06:00
|
|
|
if( SUIT_Session::session()->activeApplication()->desktop()->activeWindow()->getViewManager()->getType()
|
|
|
|
!= OCCViewer_Viewer::Type() )
|
2004-06-16 21:24:55 +06:00
|
|
|
return;
|
2005-06-02 13:17:09 +06:00
|
|
|
|
|
|
|
OCCViewer_Viewer* v3d =
|
|
|
|
((OCCViewer_ViewManager*)(SUIT_Session::session()->activeApplication()->desktop()->activeWindow()->getViewManager()))->getOCCViewer();
|
2004-06-16 21:24:55 +06:00
|
|
|
Handle(AIS_InteractiveContext) ic = v3d->getAISContext();
|
|
|
|
try {
|
|
|
|
if(!S1.IsNull()) {
|
|
|
|
/* erase any previous */
|
|
|
|
ic->Erase(mySimulationShape1, Standard_True, Standard_False);
|
|
|
|
ic->ClearPrs(mySimulationShape1);
|
|
|
|
|
|
|
|
mySimulationShape1 = new AIS_Shape(TopoDS_Shape());
|
|
|
|
mySimulationShape1->Set(S1);
|
|
|
|
mySimulationShape1->SetColor(Quantity_NOC_RED);
|
|
|
|
|
|
|
|
ic->Deactivate(mySimulationShape1);
|
|
|
|
ic->Display(mySimulationShape1, Standard_False);
|
|
|
|
mySimulationShape1->UnsetColor();
|
|
|
|
}
|
|
|
|
if(!S2.IsNull()) {
|
|
|
|
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
|
|
|
{
|
2005-06-02 13:17:09 +06:00
|
|
|
// get all view windows at the desktop
|
|
|
|
QPtrList<SUIT_ViewWindow> aWndLst = SUIT_Session::session()->activeApplication()->desktop()->windows();
|
|
|
|
//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() )
|
|
|
|
if ( vw->getViewManager()->study() == SUIT_Session::session()->activeApplication()->activeStudy() )
|
|
|
|
aWndLstAS.append( vw );
|
|
|
|
|
|
|
|
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
|
|
|
{
|
2005-06-02 13:17:09 +06:00
|
|
|
SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( SUIT_Session::session()->activeApplication()->activeStudy() );
|
|
|
|
if ( !appStudy ) return false;
|
|
|
|
_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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=====================================================================================
|
|
|
|
// function : OnSubShapeGetAll()
|
|
|
|
// purpose : Explode a shape in all sub shapes with a SubShapeType
|
|
|
|
//=====================================================================================
|
|
|
|
bool EntityGUI::OnSubShapeGetAll(const TopoDS_Shape& ShapeTopo, const char* ShapeTopoIOR, const int SubShapeType)
|
|
|
|
{
|
2005-06-02 13:17:09 +06:00
|
|
|
SUIT_Session::session()->activeApplication()->putInfo("OnSubShapeGetAll method from EntityGUI should be reimplemented ...");
|
2004-12-01 15:39:14 +05:00
|
|
|
/*
|
2004-01-07 20:46:21 +05:00
|
|
|
SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
|
|
|
|
SALOMEDS::SObject_var theObj = aStudy->FindObjectIOR(ShapeTopoIOR);
|
|
|
|
if(theObj->_is_nil()) {
|
|
|
|
QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_SHAPE_IN_STUDY"));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
|
|
|
|
SALOMEDS::SObject_var fatherSF = aStudy->FindObjectID(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->entry());
|
|
|
|
SALOMEDS::GenericAttribute_var anAttr;
|
|
|
|
SALOMEDS::AttributeName_var aName;
|
|
|
|
SALOMEDS::AttributeIOR_var anIOR;
|
|
|
|
SALOMEDS::AttributePixMap_var aPixmap;
|
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
// We create a sub object for each sub shape as attribute of the main object
|
|
|
|
// Each sub object contains list (length=1) containing its index in the main shape
|
2004-01-07 20:46:21 +05:00
|
|
|
GEOM::GEOM_Shape_var aShape = myGeom->GetIORFromString(ShapeTopoIOR);
|
|
|
|
GEOM::GEOM_Gen::ListOfGeomShapes_var listGeomShapes = new GEOM::GEOM_Gen::ListOfGeomShapes;
|
|
|
|
GEOM::GEOM_Shape_var aResult;
|
|
|
|
|
|
|
|
try {
|
|
|
|
listGeomShapes = myGeom->SubShapeAll(aShape, SubShapeType);
|
|
|
|
if(listGeomShapes->length() < 1) {
|
|
|
|
QAD_Application::getDesktop()->putInfo (tr("GEOM_PRP_ABORT"));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch(const SALOME::SALOME_Exception& S_ex) {
|
2005-06-02 13:17:09 +06:00
|
|
|
SalomeApp_Tools::QtCatchCorbaException(S_ex);
|
2004-01-07 20:46:21 +05:00
|
|
|
}
|
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
// open transaction
|
2004-01-07 20:46:21 +05:00
|
|
|
QAD_Operation* op = new SALOMEGUI_ImportOperation(QAD_Application::getDesktop()->getActiveStudy());
|
|
|
|
op->start();
|
|
|
|
|
|
|
|
TopoDS_Shape mainTopo = myGeomGUI->GetShapeReader().GetShape(myGeom, aShape);
|
|
|
|
TopoDS_Shape mainShape;
|
|
|
|
bool main = false;
|
|
|
|
while(!main) {
|
|
|
|
if(aShape->IsMainShape()) {
|
|
|
|
mainShape = myGeomGUI->GetShapeReader().GetShape(myGeom, aShape);
|
|
|
|
main = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
aShape = myGeom->GetIORFromString(aShape->MainName());
|
|
|
|
}
|
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
// Loop on each sub shape created
|
|
|
|
// int i = 1 ; index for the nameType
|
2004-01-07 20:46:21 +05:00
|
|
|
for(int j=0; j<listGeomShapes->length(); j++) {
|
2004-12-01 15:39:14 +05:00
|
|
|
// Get each sub shape extracted CORBA and OCC
|
2004-01-07 20:46:21 +05:00
|
|
|
aResult = listGeomShapes[j] ;
|
|
|
|
TopoDS_Shape S = myGeomGUI->GetShapeReader().GetShape(myGeom, aResult);
|
|
|
|
|
|
|
|
if (S.IsNull()) {
|
|
|
|
QAD_Application::getDesktop()->putInfo (tr("GEOM_PRP_ABORT"));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
// Set the nameType of sub shape
|
2004-01-07 20:46:21 +05:00
|
|
|
char* nameG = (char *)malloc(20);
|
|
|
|
Standard_CString Type;
|
|
|
|
if(myGeomBase->GetShapeTypeString(S, Type)) {
|
|
|
|
aResult->NameType(Type);
|
|
|
|
sprintf(nameG, "%s_%d", Type, myGeomBase->GetIndex(S, mainShape, SubShapeType));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
aResult->NameType(tr("GEOM_SHAPE"));
|
2004-06-16 21:24:55 +06:00
|
|
|
sprintf(nameG, "%s_%d", tr("GEOM_SHAPE").latin1(), myGeomGUI->myNbGeom++);
|
2004-01-07 20:46:21 +05:00
|
|
|
}
|
|
|
|
SALOMEDS::SObject_var SO = aStudy->FindObjectIOR(aResult->Name());
|
|
|
|
|
|
|
|
bool allreadyexist = false;
|
|
|
|
|
|
|
|
if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_OCC) {
|
|
|
|
OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
|
|
|
|
Handle (AIS_InteractiveContext) ic = v3d->getAISContext();
|
|
|
|
|
|
|
|
Handle(GEOM_AISShape) result = new GEOM_AISShape(S, nameG);
|
|
|
|
Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(aResult->Name(), myGeomGUI->GetFatherior(), "GEOM");
|
|
|
|
|
|
|
|
MESSAGE ("SO->_is_nil() " << SO->_is_nil())
|
|
|
|
|
|
|
|
if(SO->_is_nil()) {
|
|
|
|
SALOMEDS::SObject_var newObj = aStudyBuilder->NewObject(theObj);
|
|
|
|
anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeName");
|
|
|
|
aName = SALOMEDS::AttributeName::_narrow(anAttr);
|
|
|
|
aName->SetValue(nameG);
|
|
|
|
anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeIOR");
|
|
|
|
anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
|
|
|
|
anIOR->SetValue(aResult->Name());
|
|
|
|
|
|
|
|
anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributePixMap");
|
|
|
|
aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
|
|
|
|
MESSAGE(" Type " << S.ShapeType())
|
|
|
|
if (S.ShapeType() == TopAbs_COMPOUND)
|
|
|
|
aPixmap->SetPixMap("ICON_OBJBROWSER_COMPOUND");
|
|
|
|
else if(S.ShapeType() == TopAbs_COMPSOLID)
|
|
|
|
aPixmap->SetPixMap("ICON_OBJBROWSER_COMPSOLID");
|
|
|
|
else if(S.ShapeType() == TopAbs_SOLID)
|
|
|
|
aPixmap->SetPixMap("ICON_OBJBROWSER_SOLID");
|
|
|
|
else if(S.ShapeType() == TopAbs_SHELL)
|
|
|
|
aPixmap->SetPixMap("ICON_OBJBROWSER_SHELL");
|
|
|
|
else if(S.ShapeType() == TopAbs_FACE)
|
|
|
|
aPixmap->SetPixMap("ICON_OBJBROWSER_FACE");
|
|
|
|
else if(S.ShapeType() == TopAbs_WIRE)
|
|
|
|
aPixmap->SetPixMap("ICON_OBJBROWSER_WIRE");
|
|
|
|
else if(S.ShapeType() == TopAbs_EDGE)
|
|
|
|
aPixmap->SetPixMap("ICON_OBJBROWSER_EDGE");
|
|
|
|
else if(S.ShapeType() == TopAbs_VERTEX)
|
|
|
|
aPixmap->SetPixMap("ICON_OBJBROWSER_VERTEX");
|
|
|
|
|
|
|
|
MESSAGE(" aPixmap->GetPixMap " << aPixmap->GetPixMap())
|
|
|
|
|
|
|
|
SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF);
|
|
|
|
aStudyBuilder->Addreference(newObj1, newObj);
|
|
|
|
IO->setEntry(newObj->GetID());
|
|
|
|
|
|
|
|
aResult->StudyShapeId(newObj->GetID());
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
allreadyexist = true;
|
|
|
|
if(!this->SObjectExist(theObj, aResult->Name())) {
|
|
|
|
SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(theObj);
|
|
|
|
aStudyBuilder->Addreference(newObj1, SO);
|
|
|
|
IO->setEntry(SO->GetID());
|
|
|
|
aResult->StudyShapeId(SO->GetID());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
result->setIO(IO);
|
|
|
|
result->setName(nameG);
|
|
|
|
if(!allreadyexist)
|
|
|
|
ic->Display(result);
|
|
|
|
|
|
|
|
}
|
|
|
|
else if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
|
|
|
|
VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
|
|
|
|
|
|
|
|
int themode = myRenderInter->GetDisplayMode();
|
|
|
|
vtkRenderer *theRenderer = ((VTKViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer();
|
|
|
|
vtkRenderWindow *renWin = theRenderer->GetRenderWindow();
|
|
|
|
|
|
|
|
Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(aResult->Name(), myGeomGUI->GetFatherior(), "GEOM");
|
|
|
|
|
|
|
|
if(SO->_is_nil()) {
|
|
|
|
SALOMEDS::SObject_var newObj = aStudyBuilder->NewObject(theObj);
|
|
|
|
anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeIOR");
|
|
|
|
anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
|
|
|
|
anIOR->SetValue(aResult->Name());
|
|
|
|
anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeName");
|
|
|
|
aName = SALOMEDS::AttributeName::_narrow(anAttr);
|
|
|
|
aName->SetValue(nameG);
|
|
|
|
|
|
|
|
anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributePixMap");
|
|
|
|
aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
|
|
|
|
if(S.ShapeType() == TopAbs_COMPOUND)
|
|
|
|
aPixmap->SetPixMap("ICON_OBJBROWSER_COMPOUND");
|
|
|
|
else if(S.ShapeType() == TopAbs_COMPSOLID)
|
|
|
|
aPixmap->SetPixMap("ICON_OBJBROWSER_COMPSOLID");
|
|
|
|
else if(S.ShapeType() == TopAbs_SOLID)
|
|
|
|
aPixmap->SetPixMap("ICON_OBJBROWSER_SOLID");
|
|
|
|
else if(S.ShapeType() == TopAbs_SHELL)
|
|
|
|
aPixmap->SetPixMap("ICON_OBJBROWSER_SHELL");
|
|
|
|
else if(S.ShapeType() == TopAbs_FACE)
|
|
|
|
aPixmap->SetPixMap("ICON_OBJBROWSER_FACE");
|
|
|
|
else if(S.ShapeType() == TopAbs_WIRE)
|
|
|
|
aPixmap->SetPixMap("ICON_OBJBROWSER_WIRE");
|
|
|
|
else if(S.ShapeType() == TopAbs_EDGE)
|
|
|
|
aPixmap->SetPixMap("ICON_OBJBROWSER_EDGE");
|
|
|
|
else if(S.ShapeType() == TopAbs_VERTEX)
|
|
|
|
aPixmap->SetPixMap("ICON_OBJBROWSER_VERTEX");
|
|
|
|
|
|
|
|
SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF);
|
|
|
|
aStudyBuilder->Addreference(newObj1, newObj);
|
|
|
|
IO->setEntry(newObj->GetID());
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
allreadyexist = true;
|
|
|
|
if(!this->SObjectExist(theObj, aResult->Name())) {
|
|
|
|
SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(theObj);
|
|
|
|
aStudyBuilder->Addreference(newObj1, SO);
|
|
|
|
IO->setEntry(SO->GetID());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!allreadyexist) {
|
|
|
|
vtkActorCollection* theActors = GEOM_AssemblyBuilder::BuildActors(S,0,themode,Standard_True);
|
|
|
|
theActors->InitTraversal();
|
|
|
|
vtkActor* anActor = (vtkActor*)theActors->GetNextActor();
|
|
|
|
while(!(anActor==NULL)) {
|
|
|
|
GEOM_Actor* GActor = GEOM_Actor::SafeDownCast(anActor);
|
|
|
|
GActor->setIO(IO);
|
|
|
|
GActor->setName(nameG);
|
|
|
|
theRenderer->AddActor(GActor);
|
|
|
|
renWin->Render();
|
|
|
|
anActor = (vtkActor*)theActors->GetNextActor();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
// commit transaction
|
2004-01-07 20:46:21 +05:00
|
|
|
op->finish();
|
|
|
|
|
|
|
|
QAD_Application::getDesktop()->getActiveStudy()->updateObjBrowser();
|
|
|
|
QAD_Application::getDesktop()->putInfo (tr("GEOM_PRP_READY"));
|
2004-12-01 15:39:14 +05:00
|
|
|
*/
|
2004-01-07 20:46:21 +05:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=====================================================================================
|
|
|
|
// function : OnSubShapeGetSelected()
|
|
|
|
// purpose :
|
|
|
|
//=====================================================================================
|
|
|
|
bool EntityGUI::OnSubShapeGetSelected(const TopoDS_Shape& ShapeTopo, const char* ShapeTopoIOR, const int SubShapeType, Standard_Integer& aLocalContextId, bool& myUseLocalContext)
|
|
|
|
{
|
2005-06-02 13:17:09 +06:00
|
|
|
SUIT_Session::session()->activeApplication()->putInfo("OnSubShapeGetSelected method from EntityGUI should be reimplemented ...");
|
2004-12-01 15:39:14 +05:00
|
|
|
// //* Test the type of viewer */
|
|
|
|
// if(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getTypeView() > VIEW_OCC)
|
|
|
|
// return false;
|
|
|
|
|
|
|
|
// SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
|
|
|
|
// SALOMEDS::SObject_var theObj = aStudy->FindObjectIOR(ShapeTopoIOR);
|
|
|
|
// if(theObj->_is_nil()) {
|
|
|
|
// QAD_Application::getDesktop()->putInfo(tr("GEOM_PRP_SHAPE_IN_STUDY"));
|
|
|
|
// return false;
|
|
|
|
// }
|
|
|
|
|
|
|
|
// OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
|
|
|
|
// Handle(AIS_InteractiveContext) ic = v3d->getAISContext();
|
2004-01-07 20:46:21 +05:00
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
// if( myUseLocalContext == false ) {
|
|
|
|
// /* local context is from DialogBox */
|
|
|
|
// MESSAGE("Error : No local context opened for sub shapes method" << endl ) ;
|
|
|
|
// return false ;
|
|
|
|
// }
|
|
|
|
|
|
|
|
// GEOM::GEOM_Shape_var aShape = myGeom->GetIORFromString( ShapeTopoIOR );
|
|
|
|
// TopoDS_Shape mainTopo = myGeomGUI->GetShapeReader().GetShape(myGeom, aShape);
|
|
|
|
|
|
|
|
// TopoDS_Shape mainShape;
|
|
|
|
// bool main = false;
|
|
|
|
// while(!main) {
|
|
|
|
// if(aShape->IsMainShape()) {
|
|
|
|
// mainShape = myGeomGUI->GetShapeReader().GetShape(myGeom, aShape);
|
|
|
|
// main = true;
|
|
|
|
// }
|
|
|
|
// else
|
|
|
|
// aShape = myGeom->GetIORFromString(aShape->MainName());
|
|
|
|
// }
|
|
|
|
|
|
|
|
// GEOM::GEOM_Shape::ListOfSubShapeID_var ListOfID = new GEOM::GEOM_Shape::ListOfSubShapeID;
|
|
|
|
// ic->InitSelected();
|
|
|
|
// int nbSelected = ic->NbSelected();
|
|
|
|
// ListOfID->length(nbSelected);
|
2004-01-07 20:46:21 +05:00
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
// TopoDS_Compound compound;
|
|
|
|
// ic->InitSelected(); /* to init again */
|
|
|
|
// BRep_Builder B;
|
|
|
|
// B.MakeCompound(compound);
|
|
|
|
|
|
|
|
// int i = 0;
|
|
|
|
// /* We create a unique compound containing all the sub shapes selected by user as attribute of the main shape */
|
|
|
|
// /* the compound is homogenous by selection */
|
|
|
|
// while(ic->MoreSelected()) {
|
|
|
|
// int index = myGeomBase->GetIndex(ic->SelectedShape(), mainShape, SubShapeType);
|
|
|
|
// ListOfID[i] = index;
|
|
|
|
// B.Add(compound, ic->SelectedShape());
|
|
|
|
// i++;
|
|
|
|
// ic->NextSelected();
|
|
|
|
// }
|
2004-01-07 20:46:21 +05:00
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
// /* Test if user has selected sub shapes */
|
|
|
|
// if(ListOfID->length() < 1)
|
|
|
|
// return false;
|
|
|
|
|
|
|
|
// GEOM::GEOM_Shape_var aResult;
|
|
|
|
// try {
|
|
|
|
// aResult = myGeom->SubShape(aShape, SubShapeType, ListOfID);
|
|
|
|
// }
|
|
|
|
// catch (const SALOME::SALOME_Exception& S_ex) {
|
2005-06-02 13:17:09 +06:00
|
|
|
// SalomeApp_Tools::QtCatchCorbaException(S_ex);
|
2004-12-01 15:39:14 +05:00
|
|
|
// }
|
|
|
|
|
|
|
|
// /* local context from DialogBox */
|
|
|
|
// ic->CloseLocalContext(aLocalContextId);
|
|
|
|
// myUseLocalContext = false ;
|
|
|
|
|
|
|
|
// char* nameG = (char *)malloc(20);
|
|
|
|
// Standard_CString Type;
|
|
|
|
|
|
|
|
// Handle(GEOM_AISShape) result;
|
|
|
|
// Handle(GEOM_InteractiveObject) IO;
|
|
|
|
|
|
|
|
// if(nbSelected == 1) {
|
|
|
|
// TopExp_Explorer Exp (compound, TopAbs_ShapeEnum(SubShapeType));
|
|
|
|
// if(Exp.More()) {
|
|
|
|
// if(myGeomBase->GetShapeTypeString(Exp.Current(),Type)) {
|
|
|
|
// aResult->NameType(Type);
|
|
|
|
// sprintf (nameG, "%s_%d", Type, myGeomBase->GetIndex( Exp.Current(), mainTopo, SubShapeType));
|
|
|
|
// }
|
|
|
|
// else {
|
|
|
|
// aResult->NameType(tr("GEOM_SHAPE"));
|
|
|
|
// sprintf (nameG, "%s_%d", tr("GEOM_SHAPE").latin1(), myGeomGUI->myNbGeom++);
|
|
|
|
// }
|
|
|
|
// result = new GEOM_AISShape(Exp.Current(), nameG);
|
|
|
|
// IO = new GEOM_InteractiveObject(aResult->Name(), myGeomGUI->GetFatherior(), "GEOM");
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// else {
|
|
|
|
// if ( myGeomBase->GetShapeTypeString(compound,Type)) {
|
|
|
|
// aResult->NameType(Type);
|
|
|
|
// sprintf (nameG, "%s_%d", Type, myGeomGUI->myNbGeom++);
|
|
|
|
// } else {
|
|
|
|
// aResult->NameType(tr("GEOM_SHAPE"));
|
|
|
|
// sprintf (nameG, "%s_%d", tr("GEOM_SHAPE").latin1(), myGeomGUI->myNbGeom++);
|
|
|
|
// }
|
|
|
|
// result = new GEOM_AISShape(compound, nameG);
|
|
|
|
// IO = new GEOM_InteractiveObject(aResult->Name(), myGeomGUI->GetFatherior(), "GEOM");
|
|
|
|
// }
|
2004-01-07 20:46:21 +05:00
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
// SALOMEDS::SObject_var SO = aStudy->FindObjectIOR(aResult->Name());
|
2004-01-07 20:46:21 +05:00
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
// /* open transaction */
|
|
|
|
// QAD_Operation* op = new SALOMEGUI_ImportOperation(QAD_Application::getDesktop()->getActiveStudy());
|
|
|
|
// op->start();
|
2004-01-07 20:46:21 +05:00
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
// SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
|
|
|
|
// SALOMEDS::SObject_var fatherSF = aStudy->FindObjectID(QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame()->entry());
|
|
|
|
// SALOMEDS::GenericAttribute_var anAttr;
|
|
|
|
// SALOMEDS::AttributeName_var aName;
|
|
|
|
// SALOMEDS::AttributeIOR_var anIOR;
|
|
|
|
// SALOMEDS::AttributePixMap_var aPixmap;
|
2004-01-07 20:46:21 +05:00
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
// bool allreadyexist = false;
|
|
|
|
|
|
|
|
// if(SO->_is_nil()) {
|
|
|
|
// SALOMEDS::SObject_var newObj = aStudyBuilder->NewObject(theObj);
|
|
|
|
// anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeIOR");
|
|
|
|
// anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
|
|
|
|
// anIOR->SetValue(aResult->Name());
|
|
|
|
// anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributeName");
|
|
|
|
// aName = SALOMEDS::AttributeName::_narrow(anAttr);
|
|
|
|
// aName->SetValue(result->getName());
|
2004-01-07 20:46:21 +05:00
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
// anAttr = aStudyBuilder->FindOrCreateAttribute(newObj, "AttributePixMap");
|
|
|
|
// aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
|
|
|
|
// if(result->Shape().ShapeType() == TopAbs_COMPOUND)
|
|
|
|
// aPixmap->SetPixMap("ICON_OBJBROWSER_COMPOUND");
|
|
|
|
// else if(result->Shape().ShapeType() == TopAbs_COMPSOLID)
|
|
|
|
// aPixmap->SetPixMap("ICON_OBJBROWSER_COMPSOLID");
|
|
|
|
// else if(result->Shape().ShapeType() == TopAbs_SOLID)
|
|
|
|
// aPixmap->SetPixMap("ICON_OBJBROWSER_SOLID");
|
|
|
|
// else if(result->Shape().ShapeType() == TopAbs_SHELL)
|
|
|
|
// aPixmap->SetPixMap("ICON_OBJBROWSER_SHELL");
|
|
|
|
// else if(result->Shape().ShapeType() == TopAbs_FACE)
|
|
|
|
// aPixmap->SetPixMap("ICON_OBJBROWSER_FACE");
|
|
|
|
// else if(result->Shape().ShapeType() == TopAbs_WIRE)
|
|
|
|
// aPixmap->SetPixMap("ICON_OBJBROWSER_WIRE");
|
|
|
|
// else if(result->Shape().ShapeType() == TopAbs_EDGE)
|
|
|
|
// aPixmap->SetPixMap("ICON_OBJBROWSER_EDGE");
|
|
|
|
// else if(result->Shape().ShapeType() == TopAbs_VERTEX)
|
|
|
|
// aPixmap->SetPixMap("ICON_OBJBROWSER_VERTEX");
|
|
|
|
|
|
|
|
// SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(fatherSF);
|
|
|
|
// aStudyBuilder->Addreference(newObj1, newObj);
|
2004-01-07 20:46:21 +05:00
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
// IO->setEntry(newObj->GetID());
|
|
|
|
// aResult->StudyShapeId(newObj->GetID());
|
|
|
|
// }
|
|
|
|
// else {
|
|
|
|
// allreadyexist = true;
|
|
|
|
// if(!this->SObjectExist(theObj, aResult->Name())) {
|
|
|
|
// SALOMEDS::SObject_var newObj1 = aStudyBuilder->NewObject(theObj);
|
|
|
|
// aStudyBuilder->Addreference(newObj1, SO);
|
2004-01-07 20:46:21 +05:00
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
// IO->setEntry(SO->GetID());
|
|
|
|
// aResult->StudyShapeId(SO->GetID());
|
|
|
|
// }
|
|
|
|
// }
|
2004-01-07 20:46:21 +05:00
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
// /* commit transaction */
|
|
|
|
// op->finish();
|
2004-01-07 20:46:21 +05:00
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
// result->setIO(IO);
|
|
|
|
// result->setName(nameG);
|
2004-01-07 20:46:21 +05:00
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
// if(!allreadyexist)
|
|
|
|
// ic->Display(result);
|
2004-01-07 20:46:21 +05:00
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
// DisplayGUI* myDisplayGUI = new DisplayGUI();
|
|
|
|
// myDisplayGUI->OnDisplayAll(true);
|
2004-01-07 20:46:21 +05:00
|
|
|
|
2004-12-01 15:39:14 +05:00
|
|
|
// QAD_Application::getDesktop()->getActiveStudy()->updateObjBrowser();
|
|
|
|
// QAD_Application::getDesktop()->putInfo (tr("GEOM_PRP_READY"));
|
2004-01-07 20:46:21 +05:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//=====================================================================================
|
|
|
|
// EXPORTED METHODS
|
|
|
|
//=====================================================================================
|
|
|
|
extern "C"
|
|
|
|
{
|
2005-08-29 12:03:08 +06:00
|
|
|
#ifdef WNT
|
|
|
|
__declspec( dllexport )
|
|
|
|
#endif
|
2005-06-02 13:17:09 +06:00
|
|
|
GEOMGUI* GetLibGUI( GeometryGUI* parent )
|
2004-12-01 15:39:14 +05:00
|
|
|
{
|
2005-06-02 13:17:09 +06:00
|
|
|
return EntityGUI::GetEntityGUI( parent );
|
2004-12-01 15:39:14 +05:00
|
|
|
}
|
2004-01-07 20:46:21 +05:00
|
|
|
}
|