mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-03-26 09:07:55 +05:00
Fix on Bug GEOM6047
Script GEOM_example3.py freeze IAPP
This commit is contained in:
parent
82738c83d4
commit
ee886c6810
@ -26,9 +26,8 @@
|
|||||||
// Module : GEOM
|
// Module : GEOM
|
||||||
// $Header$
|
// $Header$
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
#include "GeometryGUI_Swig.hxx"
|
#include "GeometryGUI_Swig.hxx"
|
||||||
#include "utilities.h"
|
#include "SALOMEGUI_Swig.hxx"
|
||||||
|
|
||||||
#include "QAD_Application.h"
|
#include "QAD_Application.h"
|
||||||
#include "QAD_Desktop.h"
|
#include "QAD_Desktop.h"
|
||||||
@ -51,6 +50,8 @@ using namespace std;
|
|||||||
#include <TopoDS_Face.hxx>
|
#include <TopoDS_Face.hxx>
|
||||||
#include <TopoDS_Iterator.hxx>
|
#include <TopoDS_Iterator.hxx>
|
||||||
|
|
||||||
|
#include "SALOME_Event.hxx"
|
||||||
|
|
||||||
#include "VTKViewer_RenderWindowInteractor.h"
|
#include "VTKViewer_RenderWindowInteractor.h"
|
||||||
#include "VTKViewer_ViewFrame.h"
|
#include "VTKViewer_ViewFrame.h"
|
||||||
|
|
||||||
@ -60,8 +61,18 @@ using namespace std;
|
|||||||
#include "GEOM_AssemblyBuilder.h"
|
#include "GEOM_AssemblyBuilder.h"
|
||||||
#include "GEOM_InteractiveObject.hxx"
|
#include "GEOM_InteractiveObject.hxx"
|
||||||
|
|
||||||
|
#include "utilities.h"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
static GEOM_Client ShapeReader;
|
static GEOM_Client ShapeReader;
|
||||||
|
|
||||||
|
|
||||||
|
template<class TViewFrame> inline TViewFrame* GetFrame(QAD_Study* theStudy){
|
||||||
|
return dynamic_cast<TViewFrame*>(SALOME::GetViewFrame(theStudy));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
GEOM_Swig::GEOM_Swig()
|
GEOM_Swig::GEOM_Swig()
|
||||||
{
|
{
|
||||||
// MESSAGE("Constructeur");
|
// MESSAGE("Constructeur");
|
||||||
@ -82,27 +93,29 @@ void GEOM_Swig::createAndDisplayGO(const char* Entry)
|
|||||||
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);
|
||||||
|
|
||||||
Standard_CString Fatherior = "";
|
CORBA::String_var aFatherIOR;
|
||||||
SALOMEDS::SComponent_var father = aStudy->FindComponent("GEOM");
|
SALOMEDS::SComponent_var father = aStudy->FindComponent("GEOM");
|
||||||
aStudyBuilder->DefineComponentInstance( father, Geom );
|
aStudyBuilder->DefineComponentInstance( father, Geom );
|
||||||
father->ComponentIOR( Fatherior );
|
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(Entry);
|
||||||
SALOMEDS::GenericAttribute_var anAttr;
|
SALOMEDS::GenericAttribute_var anAttr;
|
||||||
SALOMEDS::AttributeName_var aName;
|
|
||||||
SALOMEDS::AttributeIOR_var anIOR;
|
SALOMEDS::AttributeIOR_var anIOR;
|
||||||
// Create new actor
|
// Create new actor
|
||||||
if ( !obj->FindAttribute(anAttr, "AttributeIOR"))
|
if ( !obj->FindAttribute(anAttr, "AttributeIOR"))
|
||||||
return;
|
return;
|
||||||
anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
|
anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
|
||||||
GEOM::GEOM_Shape_var aShape = Geom->GetIORFromString(anIOR->Value());
|
CORBA::String_var anIORValue = anIOR->Value();
|
||||||
|
|
||||||
|
GEOM::GEOM_Shape_var aShape = Geom->GetIORFromString(anIORValue);
|
||||||
TopoDS_Shape Shape = ShapeReader.GetShape(Geom,aShape);
|
TopoDS_Shape Shape = ShapeReader.GetShape(Geom,aShape);
|
||||||
|
|
||||||
if ( !obj->_is_nil() ) {
|
if ( !obj->_is_nil() ) {
|
||||||
if (obj->FindAttribute(anAttr, "AttributeName")) {
|
if (obj->FindAttribute(anAttr, "AttributeName")) {
|
||||||
aName = SALOMEDS::AttributeName::_narrow(anAttr);
|
SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
|
||||||
|
CORBA::String_var aNameValue = aName->Value();
|
||||||
// open transaction
|
// open transaction
|
||||||
QAD_Operation* op = new SALOMEGUI_ImportOperation( ActiveStudy );
|
QAD_Operation* op = new SALOMEGUI_ImportOperation( ActiveStudy );
|
||||||
op->start();
|
op->start();
|
||||||
@ -112,50 +125,55 @@ void GEOM_Swig::createAndDisplayGO(const char* Entry)
|
|||||||
// commit transaction
|
// commit transaction
|
||||||
op->finish();
|
op->finish();
|
||||||
|
|
||||||
if ( ActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { // VTK
|
Handle(GEOM_InteractiveObject) anIO = new GEOM_InteractiveObject(const_cast<char*>(anIORValue.in()),
|
||||||
//vtkQGLRenderWindowInteractor* myRenderInter = ActiveStudy->getActiveStudyFrame()->getRightFrame()->getVTKView()->getRWInteractor();
|
const_cast<char*>(aFatherIOR.in()),
|
||||||
VTKViewer_RenderWindowInteractor* myRenderInter= ((VTKViewer_ViewFrame*)ActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
|
"GEOM",
|
||||||
int themode = myRenderInter->GetDisplayMode();
|
const_cast<char*>(obj->GetID()));
|
||||||
|
|
||||||
vtkActorCollection* theActors =
|
class TEvent: public SALOME_Event{
|
||||||
GEOM_AssemblyBuilder::BuildActors(Shape,0,themode,Standard_True);
|
QAD_Study* myStudy;
|
||||||
theActors->InitTraversal();
|
TopoDS_Shape myShape;
|
||||||
vtkActor* anActor = (vtkActor*)theActors->GetNextActor();
|
Handle(SALOME_InteractiveObject) myIO;
|
||||||
while(!(anActor==NULL)) {
|
const char* myName;
|
||||||
GEOM_Actor* GActor = GEOM_Actor::SafeDownCast( anActor );
|
public:
|
||||||
Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(anIOR->Value(),
|
TEvent(QAD_Study* theStudy, TopoDS_Shape theShape,
|
||||||
Fatherior,
|
const Handle(SALOME_InteractiveObject)& theIO,
|
||||||
"GEOM");
|
const char* theName):
|
||||||
IO->setEntry(obj->GetID());
|
myStudy(theStudy), myShape(theShape),
|
||||||
GActor->setIO( IO );
|
myIO(theIO), myName(theName)
|
||||||
GActor->setName( aName->Value() );
|
{}
|
||||||
|
virtual void Execute(){
|
||||||
myRenderInter->Display(GActor);
|
if(VTKViewer_ViewFrame* aViewFrame = GetFrame<VTKViewer_ViewFrame>(myStudy)){
|
||||||
anActor = (vtkActor*)theActors->GetNextActor();
|
VTKViewer_RenderWindowInteractor* myRenderInter= aViewFrame->getRWInteractor();
|
||||||
}
|
int aMode = myRenderInter->GetDisplayMode();
|
||||||
myRenderInter->Update();
|
|
||||||
}
|
vtkActorCollection* theActors = GEOM_AssemblyBuilder::BuildActors(myShape,0,aMode,true);
|
||||||
else if ( ActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) // OCC
|
theActors->InitTraversal();
|
||||||
{
|
while(vtkActor* anActor = theActors->GetNextActor()){
|
||||||
OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)ActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
|
GEOM_Actor* GActor = GEOM_Actor::SafeDownCast(anActor);
|
||||||
// QAD_Viewer3d* v3d = ActiveStudy->getActiveStudyFrame()->getViewerOCC();
|
GActor->setName(const_cast<char*>(myName));
|
||||||
Handle(AIS_InteractiveContext) ic = v3d->getAISContext();
|
GActor->setIO(myIO);
|
||||||
Handle(GEOM_AISShape) aSh = new GEOM_AISShape(Shape, aName->Value());
|
myRenderInter->Display(GActor);
|
||||||
Handle(GEOM_InteractiveObject) IO = new GEOM_InteractiveObject(anIOR->Value(),
|
}
|
||||||
Fatherior,
|
myRenderInter->Update();
|
||||||
"GEOM");
|
}else if(OCCViewer_ViewFrame* aViewFrame = GetFrame<OCCViewer_ViewFrame>(myStudy)){
|
||||||
|
Handle(AIS_InteractiveContext) ic = aViewFrame->getViewer()->getAISContext();
|
||||||
IO->setEntry(obj->GetID());
|
Handle(GEOM_AISShape) aSh = new GEOM_AISShape(myShape,const_cast<char*>(myName));
|
||||||
aSh->setIO( IO );
|
aSh->setName(const_cast<char*>(myName));
|
||||||
aSh->setName( aName->Value() );
|
aSh->setIO(myIO);
|
||||||
ic->Display (aSh);
|
|
||||||
ic->AddOrRemoveCurrentObject(aSh, true);
|
ic->Display(aSh);
|
||||||
}
|
ic->AddOrRemoveCurrentObject(aSh,true);
|
||||||
|
}
|
||||||
|
myStudy->updateObjBrowser(true);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
ProcessVoidEvent(new TEvent(ActiveStudy,Shape,anIO,aNameValue.in()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ActiveStudy->updateObjBrowser( true );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int GEOM_Swig::getIndexTopology(const char* SubIOR, const char* IOR)
|
int GEOM_Swig::getIndexTopology(const char* SubIOR, const char* IOR)
|
||||||
{
|
{
|
||||||
Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "GEOM");
|
Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "GEOM");
|
||||||
@ -301,61 +319,87 @@ const char* GEOM_Swig::getShapeTypeIcon(const char* IOR)
|
|||||||
return "None";
|
return "None";
|
||||||
}
|
}
|
||||||
|
|
||||||
void GEOM_Swig::setDisplayMode(const char* Entry, int mode)
|
void GEOM_Swig::setDisplayMode(const char* theEntry, int theMode)
|
||||||
{
|
{
|
||||||
QAD_Study* myStudy = QAD_Application::getDesktop()->getActiveStudy();
|
QAD_Study* aStudy = QAD_Application::getDesktop()->getActiveStudy();
|
||||||
Handle(SALOME_InteractiveObject) IO =
|
Handle(SALOME_InteractiveObject) anIO = SALOME::FindIObject(aStudy,theEntry);
|
||||||
myStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame()->FindIObject( Entry );
|
|
||||||
|
|
||||||
if ( myStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { // VTK
|
class TEvent: public SALOME_Event{
|
||||||
VTKViewer_RenderWindowInteractor* myRenderInter =
|
QAD_Study* myStudy;
|
||||||
((VTKViewer_ViewFrame*)myStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
|
Handle(SALOME_InteractiveObject) myIO;
|
||||||
|
int myParam;
|
||||||
myRenderInter->SwitchRepresentation(IO, mode);
|
public:
|
||||||
myRenderInter->Update();
|
TEvent(QAD_Study* theStudy, const Handle(SALOME_InteractiveObject)& theIO, int theParam):
|
||||||
}
|
myStudy(theStudy), myIO(theIO), myParam(theParam)
|
||||||
else if ( myStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) // OCC
|
{}
|
||||||
{
|
virtual void Execute(){
|
||||||
OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
|
if(VTKViewer_ViewFrame* aViewFrame = GetFrame<VTKViewer_ViewFrame>(myStudy)){
|
||||||
v3d->SwitchRepresentation(IO, mode);
|
VTKViewer_RenderWindowInteractor* myRenderInter= aViewFrame->getRWInteractor();
|
||||||
|
myRenderInter->SwitchRepresentation(myIO,myParam);
|
||||||
|
myRenderInter->Update();
|
||||||
|
}else if(OCCViewer_ViewFrame* aViewFrame = GetFrame<OCCViewer_ViewFrame>(myStudy)){
|
||||||
|
OCCViewer_Viewer3d* v3d = aViewFrame->getViewer();
|
||||||
|
v3d->SwitchRepresentation(myIO,myParam);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
ProcessVoidEvent(new TEvent(aStudy,anIO,theMode));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GEOM_Swig::setColor(const char* Entry, int red, int green, int blue)
|
void GEOM_Swig::setColor(const char* theEntry, int red, int green, int blue)
|
||||||
{
|
{
|
||||||
QAD_Study* myStudy = QAD_Application::getDesktop()->getActiveStudy();
|
QAD_Study* aStudy = QAD_Application::getDesktop()->getActiveStudy();
|
||||||
QColor c = QColor (red, green, blue);
|
Handle(SALOME_InteractiveObject) anIO = SALOME::FindIObject(aStudy,theEntry);
|
||||||
Handle(SALOME_InteractiveObject) IO =
|
QColor aColor(red,green,blue);
|
||||||
myStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame()->FindIObject( Entry );
|
|
||||||
|
class TEvent: public SALOME_Event{
|
||||||
if ( myStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { // VTK
|
QAD_Study* myStudy;
|
||||||
VTKViewer_RenderWindowInteractor* myRenderInter =
|
Handle(SALOME_InteractiveObject) myIO;
|
||||||
((VTKViewer_ViewFrame*)myStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
|
QColor myParam;
|
||||||
myRenderInter->SetColor(IO,c);
|
public:
|
||||||
myRenderInter->Update();
|
TEvent(QAD_Study* theStudy, const Handle(SALOME_InteractiveObject)& theIO, const QColor& theParam):
|
||||||
}
|
myStudy(theStudy), myIO(theIO), myParam(theParam)
|
||||||
else if ( myStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) // OCC
|
{}
|
||||||
{
|
virtual void Execute(){
|
||||||
OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
|
if(VTKViewer_ViewFrame* aViewFrame = GetFrame<VTKViewer_ViewFrame>(myStudy)){
|
||||||
v3d->SetColor(IO,c);
|
VTKViewer_RenderWindowInteractor* myRenderInter= aViewFrame->getRWInteractor();
|
||||||
|
myRenderInter->SetColor(myIO,myParam);
|
||||||
|
myRenderInter->Update();
|
||||||
|
}else if(OCCViewer_ViewFrame* aViewFrame = GetFrame<OCCViewer_ViewFrame>(myStudy)){
|
||||||
|
OCCViewer_Viewer3d* v3d = aViewFrame->getViewer();
|
||||||
|
v3d->SetColor(myIO,myParam);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
ProcessVoidEvent(new TEvent(aStudy,anIO,aColor));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GEOM_Swig::setTransparency(const char* Entry, float transp)
|
void GEOM_Swig::setTransparency(const char* theEntry, float transp)
|
||||||
{
|
{
|
||||||
QAD_Study* myStudy = QAD_Application::getDesktop()->getActiveStudy();
|
QAD_Study* aStudy = QAD_Application::getDesktop()->getActiveStudy();
|
||||||
Handle(SALOME_InteractiveObject) IO =
|
Handle(SALOME_InteractiveObject) anIO = SALOME::FindIObject(aStudy,theEntry);
|
||||||
myStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame()->FindIObject( Entry );
|
|
||||||
|
class TEvent: public SALOME_Event{
|
||||||
if ( myStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { // VTK
|
QAD_Study* myStudy;
|
||||||
VTKViewer_RenderWindowInteractor* myRenderInter =
|
Handle(SALOME_InteractiveObject) myIO;
|
||||||
((VTKViewer_ViewFrame*)myStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor();
|
float myParam;
|
||||||
myRenderInter->SetTransparency(IO,transp);
|
public:
|
||||||
myRenderInter->Update();
|
TEvent(QAD_Study* theStudy, const Handle(SALOME_InteractiveObject)& theIO, float theParam):
|
||||||
}
|
myStudy(theStudy), myIO(theIO), myParam(theParam)
|
||||||
else if ( myStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC ) // OCC
|
{}
|
||||||
{
|
virtual void Execute(){
|
||||||
OCCViewer_Viewer3d* v3d = ((OCCViewer_ViewFrame*)myStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer();
|
if(VTKViewer_ViewFrame* aViewFrame = GetFrame<VTKViewer_ViewFrame>(myStudy)){
|
||||||
v3d->SetTransparency(IO,transp);
|
VTKViewer_RenderWindowInteractor* myRenderInter= aViewFrame->getRWInteractor();
|
||||||
|
myRenderInter->SetTransparency(myIO,myParam);
|
||||||
|
myRenderInter->Update();
|
||||||
|
}else if(OCCViewer_ViewFrame* aViewFrame = GetFrame<OCCViewer_ViewFrame>(myStudy)){
|
||||||
|
OCCViewer_Viewer3d* v3d = aViewFrame->getViewer();
|
||||||
|
v3d->SetTransparency(myIO,myParam);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
ProcessVoidEvent(new TEvent(aStudy,anIO,transp));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user