return true;
}
+//=====================================================================================
+// function : DisplayPrsObject()
+// purpose : is used by slots DisplayPrs() and DisplayManyPrs()
+//=====================================================================================
+inline void DisplayPrsObject (CORBA::Object_ptr theObject,
+ Handle(SALOME_InteractiveObject)& theIO)
+{
+ if (CORBA::is_nil(theObject)) return;
+
+ // is it Prs3d object ?
+ VISU::Prs3d_i* aPrsObject =
+ dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(theObject).in());
+ if (aPrsObject) {
+ if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Prs3d object");
+ VisuGUI::UpdateViewer(aPrsObject);
+ if (VTKViewer_ViewFrame* vf = VisuGUI::GetVtkViewFrame()) {
+ vf->getRenderer()->ResetCameraClippingRange();
+ vf->Repaint();
+ vf->highlight(theIO, 1);
+ }
+ return;
+ }
+ // is it Curve ?
+ VISU::Curve_i* aCurve =
+ dynamic_cast<VISU::Curve_i*>(VISU::GetServant(theObject).in());
+ if (aCurve) {
+ if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Curve object");
+ VisuGUI::PlotCurve(aCurve, VISU::eDisplay);
+ return;
+ }
+ // is it Container ?
+ VISU::Container_i* aContainer =
+ dynamic_cast<VISU::Container_i*>(VISU::GetServant(theObject).in());
+ if (aContainer) {
+ if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Container object");
+ VisuGUI::PlotContainer(aContainer, VISU::eDisplay);
+ return;
+ }
+ // is it Table ?
+ VISU::Table_i* aTable =
+ dynamic_cast<VISU::Table_i*>(VISU::GetServant(theObject).in());
+ if (aTable) {
+ if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Table object");
+ VisuGUI::PlotTable(aTable, VISU::eDisplay);
+ return;
+ }
+}
+
//=====================================================================================
// function : DisplayPrs()
// purpose :
//=====================================================================================
-void VisuGUI::DisplayPrs() {
+void VisuGUI::DisplayPrs()
+{
if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs");
Handle(SALOME_InteractiveObject) anIO;
CORBA::Object_var anObject = GetSelectedObj(&anIO);
- if ( !CORBA::is_nil( anObject ) ) {
- // is it Prs3d object ?
- VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(anObject).in());
- if(aPrsObject){
- if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Prs3d object");
- UpdateViewer(aPrsObject);
- if (VTKViewer_ViewFrame* vf = GetVtkViewFrame()) {
- vf->getRenderer()->ResetCameraClippingRange();
- vf->Repaint();
- vf->highlight(anIO, 1);
- }
- return;
- }
- // is it Curve ?
- VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(anObject).in());
- if(aCurve){
- if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Curve object");
- PlotCurve(aCurve, VISU::eDisplay );
- return;
- }
- // is it Container ?
- VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(anObject).in());
- if(aContainer){
- if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Container object");
- PlotContainer(aContainer, VISU::eDisplay );
- return;
- }
- // is it Table ?
- VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(anObject).in());
- if(aTable){
- if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Table object");
- PlotTable(aTable, VISU::eDisplay );
- return;
- }
- }
+ DisplayPrsObject(anObject, anIO);
}
//=====================================================================================
void VisuGUI::DisplayManyPrs()
{
if(MYDEBUG) MESSAGE("VisuGUI::DisplayManyPrs");
- SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection());
- SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() );
+ SALOME_Selection* Sel = SALOME_Selection::Selection
+ (QAD_Application::getDesktop()->getActiveStudy()->getSelection());
+ SALOME_ListIteratorOfListIO It ( Sel->StoredIObjects() );
for ( ; It.More(); It.Next() ) {
Handle(SALOME_InteractiveObject)& anIO = It.Value();
if ( anIO->hasEntry() ) {
SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument();
SALOMEDS::SObject_var aSObject = aStudy->FindObjectID( anIO->getEntry() );
- VISU::Storable::TRestoringMap pMap;
- if( !aSObject->_is_nil() ) {
+ if ( !aSObject->_is_nil() ) {
CORBA::Object_var aCORBAObject = VISU::SObjectToObject(aSObject);
- if ( !CORBA::is_nil( aCORBAObject ) ) {
- // is it Prs3d object ?
- VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(aCORBAObject).in());
- if(aPrsObject){
- if(MYDEBUG) MESSAGE("VisuGUI::DisplayManyPrs : Prs3d object");
- UpdateViewer(aPrsObject);
- VTKViewer_ViewFrame* vf = GetVtkViewFrame();
- if (vf) {
- vf->getRenderer()->ResetCameraClippingRange();
- vf->Repaint();
- vf->highlight(anIO, 1);
- }
- continue;
- }
- // is it Curve ?
- VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCORBAObject).in());
- if(aCurve){
- if(MYDEBUG) MESSAGE("VisuGUI::DisplayManyPrs: Curve object");
- PlotCurve(aCurve, VISU::eDisplay );
- continue;
- }
- // is it Container ?
- VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aCORBAObject).in());
- if(aContainer){
- if(MYDEBUG) MESSAGE("VisuGUI::DisplayManyPrs : Container object");
- PlotContainer(aContainer, VISU::eDisplay );
- continue;
- }
- // is it Table ?
- VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aCORBAObject).in());
- if(aTable){
- if(MYDEBUG) MESSAGE("VisuGUI::DisplayManyPrs : Table object");
- PlotTable(aTable, VISU::eDisplay );
- continue;
- }
- }
+ DisplayPrsObject(aCORBAObject, anIO);
}
}
}
void VisuGUI::EraseManyPrs()
{
if(MYDEBUG) MESSAGE("VisuGUI::EraseManyPrs");
- SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection());
+ SALOME_Selection* Sel = SALOME_Selection::Selection
+ (QAD_Application::getDesktop()->getActiveStudy()->getSelection());
SALOME_ListIO LIO; LIO = Sel->StoredIObjects();
- SALOME_ListIteratorOfListIO It( LIO );
+ SALOME_ListIteratorOfListIO It ( LIO );
for ( ; It.More(); It.Next() ) {
Handle(SALOME_InteractiveObject)& anIO = It.Value();
if ( anIO->hasEntry() ) {
VISU::Storable::TRestoringMap pMap;
if( !aSObject->_is_nil() ) {
CORBA::Object_var aCORBAObject = VISU::SObjectToObject(aSObject);
- if ( !CORBA::is_nil( aCORBAObject ) ) {
- // is it Prs3d object ?
- VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(aCORBAObject).in());
- if(aPrsObject){
- if(MYDEBUG) MESSAGE("VisuGUI::EraseManyPrs : Prs3d object");
- ErasePrs(aPrsObject);
- VTKViewer_ViewFrame* vf = GetVtkViewFrame();
- if (vf) {
- vf->Repaint();
- }
- continue;
- }
- // is it Curve ?
- VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>(VISU::GetServant(aCORBAObject).in());
- if(aCurve){
- if(MYDEBUG) MESSAGE("VisuGUI::EraseManyPrs : Curve object");
- PlotCurve(aCurve, VISU::eErase );
- continue;
- }
- // is it Container ?
- VISU::Container_i* aContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aCORBAObject).in());
- if(aContainer){
- if(MYDEBUG) MESSAGE("VisuGUI::EraseManyPrs : Container object");
- PlotContainer(aContainer, VISU::eErase );
- continue;
- }
- // is it Table ?
- VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aCORBAObject).in());
- if(aTable){
- if(MYDEBUG) MESSAGE("VisuGUI::EraseManyPrs : Table object");
- PlotTable(aTable, VISU::eErase );
- continue;
- }
- }
+ ::ErasePrs(aCORBAObject);
}
}
}
}
}
-
-/*!
- * Slot : deletes SObject with all subobjects
- */
-void VisuGUI::DeleteObject() {
- MESSAGE("VisuGUI::DeleteObject()");
-
- SALOMEDS::Study_var aStudy = GetStudyDocument();
- if (checkLock(aStudy)) return;
-
- SALOME_Selection* aSel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
- if (aSel->IObjectCount() != 1) return;
-
- Handle(SALOME_InteractiveObject) anIO = aSel->firstIObject();
- if (!anIO->hasEntry()) return;
-
- SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry());
- if (aSObject->_is_nil()) return;
-
- SALOMEDS::ChildIterator_var aChildIter = aStudy->NewChildIterator(aSObject);
+//=====================================================================================
+// function : DeleteSObject()
+// purpose : is used by slots DeleteObject() and DeleteManyObjects()
+//=====================================================================================
+inline void DeleteSObject (SALOMEDS::Study_ptr theStudy,
+ SALOMEDS::SObject_ptr theSObject)
+{
+ SALOMEDS::ChildIterator_var aChildIter = theStudy->NewChildIterator(theSObject);
for (aChildIter->InitEx(true); aChildIter->More(); aChildIter->Next()) {
SALOMEDS::SObject_var aChildSObject = aChildIter->Value();
CORBA::Object_var aChildObj = VISU::SObjectToObject(aChildSObject);
::ErasePrs(aChildObj);
}
- CORBA::Object_var anObj = VISU::SObjectToObject(aSObject);
-
- // There is a transaction
- SALOMEDS::StudyBuilder_var aStudyBuilder = VisuGUI::NewBuilder();
- aStudyBuilder->NewCommand();
-
+ CORBA::Object_var anObj = VISU::SObjectToObject(theSObject);
if (!CORBA::is_nil(anObj)) {
- MESSAGE("VisuGUI::DeleteObject() : !CORBA::is_nil(anObj)");
-
VISU::RemovableObject_var aRemovableObject = VISU::RemovableObject::_narrow(anObj);
if (!CORBA::is_nil(aRemovableObject)) {
- MESSAGE("VisuGUI::DeleteObject() : !CORBA::is_nil(aRemovableObject)");
aRemovableObject->RemoveFromStudy();
}
} else {
- aStudyBuilder->RemoveObjectWithChildren(aSObject);
+ // Remove aSObject together with all its sub-objects
+ VISU::RemoveFromStudy(theSObject,
+ false, // remove not only IOR attribute, but Object With Children
+ false); // not Destroy() sub-objects
}
+}
- aStudyBuilder->CommitCommand();
+/*!
+ * Slot : deletes SObject with all subobjects
+ */
+void VisuGUI::DeleteObject() {
+ SALOMEDS::Study_var aStudy = GetStudyDocument();
+ if (checkLock(aStudy)) return;
- GetActiveStudy()->unHighlightAll();
- GetActiveStudy()->updateObjBrowser(true);
+ SALOME_Selection* aSel = SALOME_Selection::Selection(GetActiveStudy()->getSelection());
+ if (aSel->IObjectCount() == 1) {
+ Handle(SALOME_InteractiveObject) anIO = aSel->firstIObject();
+ if (anIO->hasEntry()) {
+ SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry());
+ if (!aSObject->_is_nil()) {
+ // There is a transaction
+ SALOMEDS::StudyBuilder_var aStudyBuilder = VisuGUI::NewBuilder();
+ aStudyBuilder->NewCommand();
+
+ DeleteSObject(aStudy, aSObject);
+
+ aStudyBuilder->CommitCommand();
+
+ GetActiveStudy()->unHighlightAll();
+ GetActiveStudy()->updateObjBrowser(true);
+ }
+ }
+ }
}
/*!
* Slot : deletes all selected SObjects with all subobjects
*/
void VisuGUI::DeleteManyObjects() {
- MESSAGE("VisuGUI::DeleteManyObjects()");
-
SALOMEDS::Study_var aStudy = GetStudyDocument();
if (checkLock(aStudy)) return;
- SALOME_Selection* aSel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() );
+ SALOME_Selection* aSel = SALOME_Selection::Selection(GetActiveStudy()->getSelection());
int i, nbSelected = aSel->IObjectCount();
if (nbSelected < 1) return;
entries[i++] = anIO->getEntry();
}
nbSelected = i;
+ if (nbSelected < 1) return;
// There is a transaction
SALOMEDS::StudyBuilder_var aStudyBuilder = VisuGUI::NewBuilder();
for (i = 0; i < nbSelected; i++) {
SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(entries[i]);
- if (aSObject->_is_nil()) continue;
-
- SALOMEDS::ChildIterator_var aChildIter = aStudy->NewChildIterator(aSObject);
- for (aChildIter->InitEx(true); aChildIter->More(); aChildIter->Next()) {
- SALOMEDS::SObject_var aChildSObject = aChildIter->Value();
- CORBA::Object_var aChildObj = VISU::SObjectToObject(aChildSObject);
- ::ErasePrs(aChildObj);
- }
-
- CORBA::Object_var anObj = VISU::SObjectToObject(aSObject);
- if (!CORBA::is_nil(anObj)) {
- MESSAGE("VisuGUI::DeleteManyObjects() : !CORBA::is_nil(anObj)");
-
- VISU::RemovableObject_var aRemovableObject = VISU::RemovableObject::_narrow(anObj);
- if (!CORBA::is_nil(aRemovableObject)) {
- MESSAGE("VisuGUI::DeleteManyObjects() : !CORBA::is_nil(aRemovableObject)");
- aRemovableObject->RemoveFromStudy();
- }
- } else {
- aStudyBuilder->RemoveObjectWithChildren(aSObject);
+ if (!aSObject->_is_nil()) {
+ DeleteSObject(aStudy, aSObject);
}
}
return aResult;
}
-void VISU::RemoveFromStudy (SALOMEDS::SObject_ptr theSObject, int theIsAttrOnly)
+void VISU::RemoveFromStudy (SALOMEDS::SObject_ptr theSObject,
+ bool theIsAttrOnly, bool theDestroySubObjects)
{
- if (!theSObject->_is_nil()) {
- SALOMEDS::Study_var aStudy = theSObject->GetStudy();
- SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
- if (theIsAttrOnly)
- aStudyBuilder->RemoveAttribute(theSObject,"AttributeIOR");
- else
- aStudyBuilder->RemoveObjectWithChildren(theSObject);
+ if (theSObject->_is_nil()) return;
+
+ SALOMEDS::Study_var aStudyDocument = theSObject->GetStudy();
+ SALOMEDS::StudyBuilder_var aStudyBuilder = aStudyDocument->NewBuilder();
+
+ if (theIsAttrOnly) {
+ aStudyBuilder->RemoveAttribute(theSObject,"AttributeIOR");
+ return;
}
+
+ // Remove possible sub-objects
+ SALOMEDS::ChildIterator_var aChildIter = aStudyDocument->NewChildIterator(theSObject);
+ for (aChildIter->InitEx(true); aChildIter->More(); aChildIter->Next()) {
+ SALOMEDS::SObject_var aChildSObject = aChildIter->Value();
+ CORBA::Object_var aChildObj = VISU::SObjectToObject(aChildSObject);
+ if (CORBA::is_nil(aChildObj)) continue;
+
+ VISU::RemovableObject_var aRemovableObject = VISU::RemovableObject::_narrow(aChildObj);
+ if (CORBA::is_nil(aRemovableObject)) continue;
+
+ aRemovableObject->RemoveFromStudy();
+
+ // Destroy
+ if (theDestroySubObjects) {
+ VISU::Prs3d_var aPrs3d = VISU::Prs3d::_narrow(aRemovableObject);
+ if (CORBA::is_nil(aPrs3d)) continue;
+ aPrs3d->Destroy();
+ }
+ }
+
+ // Remove the SObject itself
+ aStudyBuilder->RemoveObjectWithChildren(theSObject);
}
QString GenerateName(const char* theName){
void VISU::Result_i::RemoveFromStudy()
{
- // Remove presentations
- SALOMEDS::Study_var aStudyDocument = mySObject->GetStudy();
- SALOMEDS::StudyBuilder_var aStudyBuilder = aStudyDocument->NewBuilder();
- SALOMEDS::ChildIterator_var aChildIter = aStudyDocument->NewChildIterator(mySObject);
- for (aChildIter->InitEx(true); aChildIter->More(); aChildIter->Next()) {
- SALOMEDS::SObject_var aChildSObject = aChildIter->Value();
- CORBA::Object_var aChildObj = VISU::SObjectToObject(aChildSObject);
- if (CORBA::is_nil(aChildObj)) continue;
-
- VISU::Prs3d_var aPrs3d = VISU::Prs3d::_narrow(aChildObj);
- if (CORBA::is_nil(aPrs3d)) continue;
-
- aPrs3d->RemoveFromStudy();
- }
-
- // Remove the result itself
+ // Remove the result with all presentations and other possible sub-objects
VISU::RemoveFromStudy(mySObject,false);
}