X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGEOMBase%2FGEOMBase.cxx;h=7ab1fa15263328c61026fd9020bfd205c2e33959;hb=bbafce4b04731f9219f75dc124ec2429d994c202;hp=6b1d06ea5f216775e508958f72e05122195f6629;hpb=fa17d8fb3a9c783e27e03f043e01cd9fe9322872;p=modules%2Fgeom.git diff --git a/src/GEOMBase/GEOMBase.cxx b/src/GEOMBase/GEOMBase.cxx index 6b1d06ea5..7ab1fa152 100644 --- a/src/GEOMBase/GEOMBase.cxx +++ b/src/GEOMBase/GEOMBase.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -6,7 +6,7 @@ // 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. +// version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -40,7 +40,6 @@ #include #include -#include #include #include @@ -303,15 +302,12 @@ Handle(GEOM_AISShape) GEOMBase::ConvertIORinGEOMAISShape(const QString& IOR, boo AIS_ListOfInteractive displayed; ic->DisplayedObjects( displayed ); -#if OCC_VERSION_LARGE <= 0x06060000 - ic->ObjectsInCollector( displayed ); -#endif AIS_ListIteratorOfListOfInteractive it( displayed ); while ( it.More() && shape.IsNull() ) { if ( it.Value()->IsInstance( STANDARD_TYPE(GEOM_AISShape) ) ) { Handle(GEOM_AISShape) sh = Handle(GEOM_AISShape)::DownCast( it.Value() ); if ( !sh.IsNull() && sh->hasIO() ) { - Handle(SALOME_InteractiveObject) IO = Handle(SALOME_InteractiveObject)::DownCast( sh->getIO() ); + Handle(SALOME_InteractiveObject) IO = sh->getIO(); if ( !IO.IsNull() && IO->hasEntry() && obj->GetID() == IO->getEntry() ) shape = sh; } @@ -358,7 +354,7 @@ GEOM_Actor* GEOMBase::ConvertIORinGEOMActor(const QString& IOR, bool onlyInActiv if ( a->IsA( "GEOM_Actor" ) ) { GEOM_Actor* ga = GEOM_Actor::SafeDownCast( a ); if ( ga && ga->hasIO() ) { - Handle(SALOME_InteractiveObject) IO = Handle(SALOME_InteractiveObject)::DownCast( ga->getIO() ); + Handle(SALOME_InteractiveObject) IO = ga->getIO(); if ( !IO.IsNull() && IO->hasEntry() && obj->GetID() == IO->getEntry() ) actor = ga; } @@ -378,7 +374,7 @@ GEOM_Actor* GEOMBase::ConvertIORinGEOMActor(const QString& IOR, bool onlyInActiv // purpose : //======================================================================= Handle(AIS_InteractiveObject) GEOMBase::GetAIS( const Handle(SALOME_InteractiveObject)& IO, - bool onlyInActiveView, bool onlyGeom ) + bool onlyInActiveView, bool /*onlyGeom*/ ) { Handle(AIS_InteractiveObject) aisObject; @@ -454,12 +450,11 @@ GEOM::GEOM_Object_ptr GEOMBase::ConvertIOinGEOMObject( const Handle(SALOME_Inter SalomeApp_Study* study = dynamic_cast( SUIT_Session::session()->activeApplication()->activeStudy() ); if ( study ) { _PTR(Study) studyDS = study->studyDS(); - _PTR(SObject) obj( studyDS->FindObjectID( IO->getEntry() ) ); - if ( obj ) { - CORBA::Object_var corbaObj = GeometryGUI::ClientSObjectToObject( obj ); - if ( !CORBA::is_nil( corbaObj ) ) + _PTR(SObject) obj = studyDS->FindObjectID( IO->getEntry() ); + if ( GeometryGUI::IsInGeomComponent( obj )) { + CORBA::Object_var corbaObj = GeometryGUI::ClientSObjectToObject( obj ); object = GEOM::GEOM_Object::_narrow( corbaObj ); - } + } } } return object._retn(); @@ -493,7 +488,6 @@ void GEOMBase::ConvertListOfIOInListOfGO( const SALOME_ListIO& IObjects, } } - //================================================================================= // function : CreateArrowForLinearEdge() // purpose : Create a cone topology to be used to display an arrow in the middle @@ -530,7 +524,7 @@ TopoDS_Shape GEOMBase::CreateArrowForLinearEdge( const TopoDS_Shape& shape ) } } } - catch ( Standard_Failure ) { + catch ( Standard_Failure& ) { // OCC failures are hard to catch in GUI. // This is because of the position for #include that is very critical to find // in SALOME environment : compilation error ! @@ -630,7 +624,7 @@ bool GEOMBase::SelectionByNameInDialogs( QWidget* widget, const QString& objectU /* Create a SALOME_InteractiveObject with a SALOME::SObject */ Handle(SALOME_InteractiveObject) IO = new SALOME_InteractiveObject( listSO[0]->GetID().c_str(), "GEOM", - objectUserName.toLatin1().constData() ); + objectUserName.toUtf8().constData() ); /* Add as a selected object */ /* Clear any previous selection : */ @@ -714,7 +708,7 @@ void GEOMBase::ShowErrorMessage( const QString& errorCode, const QString& commen if ( !errorCode.isEmpty() ) text << QObject::tr( errorCode.toLatin1().constData() ); if ( !comment.isEmpty() ) - text << QObject::tr( comment.toLatin1().constData() ); + text << QObject::tr( comment.toUtf8().constData() ); SUIT_MessageBox::critical( SUIT_Session::session()->activeApplication()->desktop(), QObject::tr( "GEOM_ERROR" ), @@ -751,7 +745,10 @@ bool GEOMBase::GetShape( GEOM::GEOM_Object_ptr object, TopoDS_Shape& shape, cons if ( !CORBA::is_nil( object ) ) { TopAbs_ShapeEnum stype = (TopAbs_ShapeEnum)( object->GetShapeType() ); if ( type == TopAbs_SHAPE || type == stype ) - shape = GEOM_Client::get_client().GetShape( GeometryGUI::GetGeomGen(), object ); + { + GEOM::GEOM_Gen_var gen = object->GetGen(); + shape = GEOM_Client::get_client().GetShape( gen, object ); + } } return !shape.IsNull(); } @@ -812,7 +809,7 @@ bool GEOMBase::IsShape( GEOM::GEOM_Object_ptr object ) // function : TypeName() // purpose : Get string representation for the shape type //======================================================================= -QString GEOMBase::TypeName( TopAbs_ShapeEnum type ) +QString GEOMBase::TypeName( TopAbs_ShapeEnum type, bool capitalize ) { QString name = "shape"; switch( type ) { @@ -835,6 +832,8 @@ QString GEOMBase::TypeName( TopAbs_ShapeEnum type ) default: break; } + if ( capitalize && !name.isEmpty() ) + name = name.left(1).toUpper() + name.mid(1); return name; } @@ -861,7 +860,7 @@ QString GEOMBase::GetEntry( GEOM::GEOM_Object_ptr object ) // Function : PublishSubObject // Purpose : Publish sub-shape under the main object //================================================================ -void GEOMBase::PublishSubObject( GEOM::GEOM_Object_ptr object ) +void GEOMBase::PublishSubObject( GEOM::GEOM_Object_ptr object, const QString& name ) { SalomeApp_Study* study = dynamic_cast( SUIT_Session::session()->activeApplication()->activeStudy() ); if ( study && !CORBA::is_nil( object ) ) { @@ -870,9 +869,38 @@ void GEOMBase::PublishSubObject( GEOM::GEOM_Object_ptr object ) GEOM::GEOM_Object_var father = object->GetMainShape(); QString fatherEntry = GetEntry( father ); if ( entry.isEmpty() && !CORBA::is_nil( father ) && !fatherEntry.isEmpty() ) { - QString name = GetName( object ); - GeometryGUI::GetGeomGen()->AddInStudy( GeometryGUI::ClientStudyToStudy( studyDS ), - object, name.toLatin1().data(), father.in() ); + QString aName = !name.isEmpty() ? name : GetName( object ); + GeometryGUI::GetGeomGen()->AddInStudy( object, aName.toUtf8().data(), father.in() ); } } } + +//================================================================ +// Function : synchronize +// Purpose : +//================================================================ +void GEOMBase::Synchronize( QList& left, QList& right ) +{ + // 1. remove items from the "left" list that are not in the "right" list + QMutableListIterator it1( left ); + while ( it1.hasNext() ) { + GEOM::GeomObjPtr o1 = it1.next(); + bool found = false; + QMutableListIterator it2( right ); + while ( it2.hasNext() && !found ) + found = o1 == it2.next(); + if ( !found ) + it1.remove(); + } + // 2. add items from the "right" list that are not in the "left" list (to keep selection order) + it1 = right; + while ( it1.hasNext() ) { + GEOM::GeomObjPtr o1 = it1.next(); + bool found = false; + QMutableListIterator it2( left ); + while ( it2.hasNext() && !found ) + found = o1 == it2.next(); + if ( !found ) + left << o1; + } +}