Fix crash of BugRevolution.py import

This commit is contained in:
jfa 2005-08-02 06:55:46 +00:00
parent bfd83343c8
commit 1127be211a

View File

@ -27,6 +27,13 @@
// $Header$ // $Header$
#include "GeometryGUI_Swig.hxx" #include "GeometryGUI_Swig.hxx"
#include "GEOM_Actor.h"
#include "GEOM_Client.hxx"
#include "GEOM_AISShape.hxx"
#include "GEOM_AssemblyBuilder.h"
#include "GEOM_InteractiveObject.hxx"
#include "SALOMEGUI_Swig.hxx" #include "SALOMEGUI_Swig.hxx"
#include "QAD_Application.h" #include "QAD_Application.h"
@ -36,8 +43,17 @@
#include "QAD_RightFrame.h" #include "QAD_RightFrame.h"
#include "SALOMEGUI_ImportOperation.h" #include "SALOMEGUI_ImportOperation.h"
#include "SALOME_Event.hxx"
#include "OCCViewer_Viewer3d.h" #include "OCCViewer_Viewer3d.h"
#include "OCCViewer_ViewFrame.h" #include "OCCViewer_ViewFrame.h"
#include "VTKViewer_RenderWindowInteractor.h"
#include "VTKViewer_ViewFrame.h"
#include "utilities.h"
// OCCT Includes
#include <TopExp_Explorer.hxx> #include <TopExp_Explorer.hxx>
#include <TopTools_MapOfShape.hxx> #include <TopTools_MapOfShape.hxx>
#include <TopTools_ListOfShape.hxx> #include <TopTools_ListOfShape.hxx>
@ -54,19 +70,6 @@
#include <AIS_ListIteratorOfListOfInteractive.hxx> #include <AIS_ListIteratorOfListOfInteractive.hxx>
#include <V3d_Viewer.hxx> #include <V3d_Viewer.hxx>
#include "SALOME_Event.hxx"
#include "VTKViewer_RenderWindowInteractor.h"
#include "VTKViewer_ViewFrame.h"
#include "GEOM_Actor.h"
#include "GEOM_Client.hxx"
#include "GEOM_AISShape.hxx"
#include "GEOM_AssemblyBuilder.h"
#include "GEOM_InteractiveObject.hxx"
#include "utilities.h"
using namespace std; using namespace std;
static GEOM_Client ShapeReader; static GEOM_Client ShapeReader;
@ -89,12 +92,21 @@ GEOM_Swig::~GEOM_Swig()
void GEOM_Swig::createAndDisplayGO (const char* Entry) void GEOM_Swig::createAndDisplayGO (const char* Entry)
{ {
// MESSAGE("createAndDisplayGO"); class TEvent: public SALOME_Event
{
std::string myEntry;
public:
TEvent(const char* theEntry):
myEntry(theEntry)
{}
virtual void Execute()
{
QAD_Study* ActiveStudy = QAD_Application::getDesktop()->getActiveStudy(); QAD_Study* ActiveStudy = QAD_Application::getDesktop()->getActiveStudy();
SALOMEDS::Study_var aStudy = ActiveStudy->getStudyDocument(); SALOMEDS::Study_var aStudy = ActiveStudy->getStudyDocument();
SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "GEOM"); Engines::Component_var comp =
QAD_Application::getDesktop()->getEngine("FactoryServer", "GEOM");
GEOM::GEOM_Gen_var Geom = GEOM::GEOM_Gen::_narrow(comp); GEOM::GEOM_Gen_var Geom = GEOM::GEOM_Gen::_narrow(comp);
CORBA::String_var aFatherIOR; CORBA::String_var aFatherIOR;
@ -102,9 +114,10 @@ void GEOM_Swig::createAndDisplayGO(const char* Entry)
aStudyBuilder->DefineComponentInstance(father, Geom); aStudyBuilder->DefineComponentInstance(father, Geom);
father->ComponentIOR(aFatherIOR); father->ComponentIOR(aFatherIOR);
SALOMEDS::SObject_var fatherSF = aStudy->FindObjectID(ActiveStudy->getActiveStudyFrame()->entry()); SALOMEDS::SObject_var fatherSF =
aStudy->FindObjectID(ActiveStudy->getActiveStudyFrame()->entry());
SALOMEDS::SObject_var obj = aStudy->FindObjectID(Entry); SALOMEDS::SObject_var obj = aStudy->FindObjectID(myEntry.c_str());
SALOMEDS::GenericAttribute_var anAttr; SALOMEDS::GenericAttribute_var anAttr;
SALOMEDS::AttributeIOR_var anIOR; SALOMEDS::AttributeIOR_var anIOR;
// Create new actor // Create new actor
@ -129,51 +142,41 @@ void GEOM_Swig::createAndDisplayGO(const char* Entry)
// commit transaction // commit transaction
op->finish(); op->finish();
Handle(GEOM_InteractiveObject) anIO = new GEOM_InteractiveObject(const_cast<char*>(anIORValue.in()), Handle(GEOM_InteractiveObject) anIO =
new GEOM_InteractiveObject(const_cast<char*>(anIORValue.in()),
const_cast<char*>(aFatherIOR.in()), const_cast<char*>(aFatherIOR.in()),
"GEOM", "GEOM",
const_cast<char*>(obj->GetID())); const_cast<char*>(obj->GetID()));
class TEvent: public SALOME_Event{ if (VTKViewer_ViewFrame* aViewFrame = GetFrame<VTKViewer_ViewFrame>(ActiveStudy)) {
QAD_Study* myStudy; VTKViewer_RenderWindowInteractor* aRenderInter= aViewFrame->getRWInteractor();
TopoDS_Shape myShape; int aMode = aRenderInter->GetDisplayMode();
Handle(SALOME_InteractiveObject) myIO;
const char* myName;
public:
TEvent(QAD_Study* theStudy, TopoDS_Shape theShape,
const Handle(SALOME_InteractiveObject)& theIO,
const char* theName):
myStudy(theStudy), myShape(theShape),
myIO(theIO), myName(theName)
{}
virtual void Execute(){
if(VTKViewer_ViewFrame* aViewFrame = GetFrame<VTKViewer_ViewFrame>(myStudy)){
VTKViewer_RenderWindowInteractor* myRenderInter= aViewFrame->getRWInteractor();
int aMode = myRenderInter->GetDisplayMode();
vtkActorCollection* theActors = GEOM_AssemblyBuilder::BuildActors(myShape,0,aMode,true); vtkActorCollection* theActors = GEOM_AssemblyBuilder::BuildActors(Shape,0,aMode,true);
theActors->InitTraversal(); theActors->InitTraversal();
while (vtkActor* anActor = theActors->GetNextActor()) { while (vtkActor* anActor = theActors->GetNextActor()) {
GEOM_Actor* GActor = GEOM_Actor::SafeDownCast(anActor); GEOM_Actor* GActor = GEOM_Actor::SafeDownCast(anActor);
GActor->setName(const_cast<char*>(myName)); GActor->setName(const_cast<char*>(aNameValue.in()));
GActor->setIO(myIO); GActor->setIO(anIO);
myRenderInter->Display(GActor); aRenderInter->Display(GActor);
} }
myRenderInter->Update(); aRenderInter->Update();
}else if(OCCViewer_ViewFrame* aViewFrame = GetFrame<OCCViewer_ViewFrame>(myStudy)){ } else if (OCCViewer_ViewFrame* aViewFrame = GetFrame<OCCViewer_ViewFrame>(ActiveStudy)) {
Handle(AIS_InteractiveContext) ic = aViewFrame->getViewer()->getAISContext(); Handle(AIS_InteractiveContext) ic = aViewFrame->getViewer()->getAISContext();
Handle(GEOM_AISShape) aSh = new GEOM_AISShape(myShape,const_cast<char*>(myName)); Handle(GEOM_AISShape) aSh = new GEOM_AISShape(Shape,const_cast<char*>(aNameValue.in()));
aSh->setName(const_cast<char*>(myName)); aSh->setName(const_cast<char*>(aNameValue.in()));
aSh->setIO(myIO); aSh->setIO(anIO);
ic->Display(aSh); ic->Display(aSh);
ic->AddOrRemoveCurrentObject(aSh,true); ic->AddOrRemoveCurrentObject(aSh,true);
} }
myStudy->updateObjBrowser(true); ActiveStudy->updateObjBrowser(true);
}
}
} }
}; };
ProcessVoidEvent(new TEvent(ActiveStudy,Shape,anIO,aNameValue.in()));
} //MESSAGE("createAndDisplayGO");
} ProcessVoidEvent(new TEvent (Entry));
} }