SUIT_ViewManager* vman = vw->getViewManager();
if ( vman->getType() == OCCViewer_Viewer::Type() ||
vman->getType() == SVTK_Viewer::Type() ) {
- GEOM_Displayer( appStudy ).EraseAll();
+ GEOM_Displayer( appStudy ).EraseAll(true);
}
}
}
//=======================================================================
GEOM::GEOM_Object_ptr GEOMBase::GetObjectFromIOR( const QString& IOR )
{
- GEOM::GEOM_Object_var geomObj;
- if ( !IOR.isEmpty() ) {
- CORBA::Object_var corbaObj = SalomeApp_Application::orb()->string_to_object( IOR.toLatin1().constData() );
- if ( !CORBA::is_nil( corbaObj ) )
- geomObj = GEOM::GEOM_Object::_narrow( corbaObj );
- }
- return geomObj._retn();
+ return GeometryGUI::GetObjectFromIOR (IOR);
}
//=======================================================================
//=======================================================================
QString GEOMBase::GetIORFromObject( GEOM::GEOM_Object_ptr object )
{
- QString IOR;
- if ( !CORBA::is_nil( object ) ) {
- CORBA::String_var anIOR = SalomeApp_Application::orb()->object_to_string( object );
- IOR = anIOR.in();
- }
- return IOR;
+ return GeometryGUI::GetIORFromObject (object);
}
//=======================================================================
//================================================================
void GEOMBase_Helper::clearShapeBuffer( GEOM::GEOM_Object_ptr theObj )
{
- if ( CORBA::is_nil( theObj ) )
- return;
-
- CORBA::String_var IOR = SalomeApp_Application::orb()->object_to_string( theObj );
- TCollection_AsciiString asciiIOR( (char *)IOR.in() );
- GEOM_Client::get_client().RemoveShapeFromBuffer( asciiIOR );
-
- if ( !getStudy() || !getStudy()->studyDS() )
- return;
-
- _PTR(Study) aStudy = getStudy()->studyDS();
- _PTR(SObject) aSObj ( aStudy->FindObjectIOR( std::string( IOR ) ) );
- if ( !aSObj )
- return;
-
- _PTR(ChildIterator) anIt ( aStudy->NewChildIterator( aSObj ) );
- for ( anIt->InitEx( true ); anIt->More(); anIt->Next() ) {
- _PTR(GenericAttribute) anAttr;
- if ( anIt->Value()->FindAttribute(anAttr, "AttributeIOR") ) {
- _PTR(AttributeIOR) anIOR ( anAttr );
- TCollection_AsciiString asciiIOR( (char*)anIOR->Value().c_str() );
- GEOM_Client::get_client().RemoveShapeFromBuffer( asciiIOR );
- }
- }
+ GeometryGUI::ClearShapeBuffer(theObj);
}
//================================================================
return action(id);
}
+/*!
+ \brief GEOM module message handler
+
+ This method can be re-implemented in the subclasses.
+ This is a GEOM module message handler.
+
+ \param msg the message received.
+*/
+void GeometryGUI::message(const QString& msg)
+{
+ // dispatch message
+ QStringList data = msg.split("/");
+ const int nbStrings = data.count();
+
+ if (nbStrings > 0) {
+ if (data[0] == "modified") {
+ // get mesh entry
+ QString anIOR = nbStrings > 1 ? data[1] : QString();
+
+ if ( anIOR.isEmpty() ) {
+ return;
+ }
+
+ // Get the geom object.
+ GEOM::GEOM_Object_ptr anObj = GeometryGUI::GetObjectFromIOR (anIOR);
+
+ // Clear the shape buffer
+ GeometryGUI::ClearShapeBuffer (anObj);
+ }
+ }
+}
+
+/*!
+ \brief Clears the shape buffer.
+
+ This is a static method. It clears the shape buffer.
+
+ \param theObj the object
+*/
+void GeometryGUI::ClearShapeBuffer( GEOM::GEOM_Object_ptr theObj )
+{
+ if ( CORBA::is_nil( theObj ) )
+ return;
+
+ CORBA::String_var IOR = SalomeApp_Application::orb()->object_to_string( theObj );
+ TCollection_AsciiString asciiIOR( (char *)IOR.in() );
+ GEOM_Client::get_client().RemoveShapeFromBuffer( asciiIOR );
+
+ SALOMEDSClient_StudyManager *aManager = SalomeApp_Application::studyMgr();
+
+ if (!aManager)
+ return;
+
+ _PTR(Study) aStudy = aManager->GetStudyByID(theObj->GetStudyID());
+
+ if ( !aStudy )
+ return;
+
+ _PTR(SObject) aSObj ( aStudy->FindObjectIOR( std::string( IOR ) ) );
+ if ( !aSObj )
+ return;
+
+ _PTR(ChildIterator) anIt ( aStudy->NewChildIterator( aSObj ) );
+ for ( anIt->InitEx( true ); anIt->More(); anIt->Next() ) {
+ _PTR(GenericAttribute) anAttr;
+ if ( anIt->Value()->FindAttribute(anAttr, "AttributeIOR") ) {
+ _PTR(AttributeIOR) anIOR ( anAttr );
+ TCollection_AsciiString asciiIOR( (char*)anIOR->Value().c_str() );
+ GEOM_Client::get_client().RemoveShapeFromBuffer( asciiIOR );
+ }
+ }
+}
+
+/*!
+ \brief Returns the object from IOR.
+
+ This is a static method. It returns the object from its IOR.
+
+ \param IOR object IOR
+ \return GEOM object.
+*/
+GEOM::GEOM_Object_ptr GeometryGUI::GetObjectFromIOR( const QString& IOR )
+{
+ GEOM::GEOM_Object_var geomObj;
+ if ( !IOR.isEmpty() ) {
+ CORBA::Object_var corbaObj = SalomeApp_Application::orb()->string_to_object
+ ( IOR.toLatin1().constData() );
+ if ( !CORBA::is_nil( corbaObj ) )
+ geomObj = GEOM::GEOM_Object::_narrow( corbaObj );
+ }
+ return geomObj._retn();
+}
+
+/*!
+ \brief Returns IOR of the object.
+
+ This is a static method. It returns the object's IOR.
+
+ \param object the GEOM object.
+ \return object's IOR.
+*/
+QString GeometryGUI::GetIORFromObject( GEOM::GEOM_Object_ptr object )
+{
+ QString IOR;
+ if ( !CORBA::is_nil( object ) ) {
+ CORBA::String_var anIOR =
+ SalomeApp_Application::orb()->object_to_string( object );
+ IOR = anIOR.in();
+ }
+ return IOR;
+}
+
/*!
\brief Check if this object is can't be renamed in place
QAction* getAction(const int id);
+ virtual void message( const QString& msg);
+ static void ClearShapeBuffer( GEOM::GEOM_Object_ptr );
+ static GEOM::GEOM_Object_ptr
+ GetObjectFromIOR( const QString& IOR );
+
+ static QString GetIORFromObject( GEOM::GEOM_Object_ptr object );
+
+
public slots:
virtual bool deactivateModule( SUIT_Study* );
virtual bool activateModule( SUIT_Study* );
// generic method to be put in a super class
void register_name(char * name);
+ // Get ORB object
+ CORBA::ORB_ptr GetORB() { return CORBA::ORB::_duplicate(_orb); }
+
+ // Get Naming Service object
+ SALOME_NamingService* GetNS() { return name_service; }
//-----------------------------------------------------------------------//
// Inherited methods from SALOMEDS::Driver //
#include "GEOM_IOperations_i.hh"
#include "GEOM_Engine.hxx"
+#include "GEOM_Gen_i.hh"
+#include <SALOME_NamingService.hxx>
#include "utilities.h"
#include "OpUtil.hxx"
#include <TCollection_AsciiString.hxx>
#include <TDF_Tool.hxx>
+#include CORBA_SERVER_HEADER(SALOME_Session)
+
//=============================================================================
/*!
* default constructor:
}
return anImpl;
}
+
+//=============================================================================
+/*!
+ * UpdateGUIForObject
+ */
+//=============================================================================
+void GEOM_IOperations_i::UpdateGUIForObject(GEOM::GEOM_Object_ptr theObj)
+{
+ if (!CORBA::is_nil (theObj)) {
+ // Cast _engine to GEOM_Gen_i type.
+ PortableServer::Servant aServant = myPOA->reference_to_servant(_engine.in());
+ GEOM_Gen_i *anEngine = dynamic_cast<GEOM_Gen_i *>(aServant);
+
+ if (anEngine) {
+ SALOME_NamingService *aNameService = anEngine->GetNS();
+ CORBA::Object_var aSessionObj = aNameService->Resolve("/Kernel/Session");
+ SALOME::Session_var aSession = SALOME::Session::_narrow(aSessionObj);
+
+ if (!aSession->_is_nil())
+ {
+ std::string aMsg("GEOM/modified/");
+ CORBA::String_var anIOR = anEngine->GetORB()->object_to_string(theObj);
+
+ aMsg += anIOR.in();
+ aSession->emitMessageOneWay(aMsg.c_str());
+ }
+ }
+ }
+}
::GEOM_IOperations* GetImpl() { return _impl; }
+ virtual void UpdateGUIForObject(GEOM::GEOM_Object_ptr theObj);
+
private:
::GEOM_IOperations* _impl;
//Perform the translation
GetOperations()->TranslateTwoPoints(anObject, aPoint1, aPoint2);
+ // Update GUI.
+ UpdateGUIForObject(theObject);
+
return aGEOMObject._retn();
}
//Perform the translation
GetOperations()->TranslateDXDYDZ(anObject, theDX, theDY, theDZ);
+ // Update GUI.
+ UpdateGUIForObject(theObject);
+
return aGEOMObject._retn();
}
//Perform the translation
GetOperations()->TranslateVector(anObject, aVector);
+ // Update GUI.
+ UpdateGUIForObject(theObject);
+
return aGEOMObject._retn();
}
}
GetOperations()->TranslateVectorDistance(aBasicObject, aVector, theDistance, theCopy);
+
+ // Update GUI.
+ UpdateGUIForObject(theObject);
+
return aGEOMObject._retn();
}
//Perform the rotation
GetOperations()->Rotate(anObject, anAxis, theAngle);
+ // Update GUI.
+ UpdateGUIForObject(theObject);
+
return aGEOMObject._retn();
}
//Perform the mirror
GetOperations()->MirrorPlane(anObject, aPlane);
+ // Update GUI.
+ UpdateGUIForObject(theObject);
+
return aGEOMObject._retn();
}
//Perform the mirror
GetOperations()->MirrorAxis(anObject, aAxis);
+ // Update GUI.
+ UpdateGUIForObject(theObject);
+
return aGEOMObject._retn();
}
//Perform the mirror
GetOperations()->MirrorPoint(anObject, aPoint);
+ // Update GUI.
+ UpdateGUIForObject(theObject);
+
return aGEOMObject._retn();
}
//Create the offset shape
GetOperations()->OffsetShape(aBasicObject, theOffset);
+ // Update GUI.
+ UpdateGUIForObject(theObject);
+
return aGEOMObject._retn();
}
//Perform the scale
GetOperations()->ScaleShape(anObject, aPoint, theFactor);
+ // Update GUI.
+ UpdateGUIForObject(theObject);
+
return aGEOMObject._retn();
}
GetOperations()->ScaleShapeAlongAxes
(anObject, aPoint, theFactorX, theFactorY, theFactorZ, /*doCopy*/false);
+ // Update GUI.
+ UpdateGUIForObject(theObject);
+
return aGEOMObject._retn();
}
//Perform the Position
GetOperations()->PositionShape(anObject, aStartLCS, aEndLCS);
+ // Update GUI.
+ UpdateGUIForObject(theObject);
+
return aGEOMObject._retn();
}
if (!GetOperations()->IsDone() || anObject.IsNull())
return aGEOMObject._retn();
+ if (!theCopy) {
+ // Update GUI.
+ UpdateGUIForObject(theObject);
+ }
+
return GetObject(anObject);
}
//Perform the translation
GetOperations()->RotateThreePoints(anObject, aCentPoint, aPoint1, aPoint2);
+ // Update GUI.
+ UpdateGUIForObject(theObject);
+
return aGEOMObject._retn();
}