1 // Copyright (C) 2014-2015 EDF-R&D
2 // This library is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU Lesser General Public
4 // License as published by the Free Software Foundation; either
5 // version 2.1 of the License, or (at your option) any later version.
7 // This library is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 // Lesser General Public License for more details.
12 // You should have received a copy of the GNU Lesser General Public
13 // License along with this library; if not, write to the Free Software
14 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #include "HYDROGUI_Tool.h"
21 #include "HYDROGUI_DataModel.h"
22 #include "HYDROGUI_DataObject.h"
23 #include "HYDROGUI_Module.h"
24 #include "HYDROGUI_Prs.h"
26 #include <HYDROData_Document.h>
27 #include <HYDROData_Iterator.h>
28 #include <HYDROData_ImmersibleZone.h>
29 #include <HYDROData_Tool.h>
30 #include <HYDROData_Profile.h>
32 #include <GeometryGUI.h>
35 #include <GraphicsView_Viewer.h>
37 #include <SalomeApp_Study.h>
39 #include <LightApp_Application.h>
40 #include <LightApp_DataOwner.h>
41 #include <LightApp_SelectionMgr.h>
43 #include <OCCViewer_ViewModel.h>
44 #include <OCCViewer_ViewFrame.h>
46 #include <QtxWorkstack.h>
47 #include <QtxActionToolMgr.h>
49 #include <STD_TabDesktop.h>
51 #include <SUIT_Session.h>
52 #include <SUIT_Study.h>
53 #include <SUIT_ViewManager.h>
54 #include <SUIT_ViewWindow.h>
56 #include <SALOMEDSClient.hxx>
58 #include <SVTK_ViewModel.h>
62 #include <QDockWidget>
65 // Definition of this id allows to use 'latin1' (Qt alias for 'ISO-8859-1')
66 // encoding instead of default 'System'
67 #define USE_LATIN1_ENCODING
69 // #define DEB_GROUPS 1
71 QString HYDROGUI_Tool::ToQString( const TCollection_AsciiString& src )
73 #ifdef USE_LATIN1_ENCODING
74 QTextCodec* codec = QTextCodec::codecForName( "latin1" ); // alias for ISO-8859-1
76 QTextCodec* codec = QTextCodec::codecForLocale();
80 res = codec ? codec->toUnicode( (char*)src.ToCString(), src.Length() ) :
81 QString( (char*)src.ToCString() );
85 QString HYDROGUI_Tool::ToQString( const TCollection_ExtendedString& src )
87 return QString( (QChar*)src.ToExtString(), src.Length() );
90 QString HYDROGUI_Tool::ToQString( const Handle(TCollection_HAsciiString)& src )
95 return ToQString( src->String() );
98 QString HYDROGUI_Tool::ToQString( const Handle(TCollection_HExtendedString)& src )
102 return ToQString( src->String() );
105 TCollection_AsciiString HYDROGUI_Tool::ToAsciiString( const QString& src )
107 TCollection_AsciiString res;
110 #ifdef USE_LATIN1_ENCODING
111 QTextCodec* codec = QTextCodec::codecForName( "latin1" ); // alias for ISO-8859-1
113 QTextCodec* codec = QTextCodec::codecForLocale();
117 QByteArray str = codec->fromUnicode( src );
118 res = TCollection_AsciiString( (Standard_CString)str.constData() );
121 res = TCollection_AsciiString( src.toLatin1().data() );
126 TCollection_ExtendedString HYDROGUI_Tool::ToExtString( const QString& src )
129 return TCollection_ExtendedString();
131 Standard_Integer len = src.length();
132 Standard_ExtString extStr = new Standard_ExtCharacter[ ( len + 1 ) * 2 ];
133 memcpy( (void*)extStr, src.unicode(), len * 2 );
134 ((short*)extStr)[ len ] = 0;
136 TCollection_ExtendedString trg( extStr );
141 Handle(TCollection_HAsciiString) HYDROGUI_Tool::ToHAsciiString( const QString& src )
143 return new TCollection_HAsciiString( ToAsciiString( src ) );
146 Handle(TCollection_HExtendedString) HYDROGUI_Tool::ToHExtString( const QString& src )
148 return new TCollection_HExtendedString( ToExtString( src ) );
151 int HYDROGUI_Tool::GetActiveStudyId()
153 if( SUIT_Session* aSession = SUIT_Session::session() )
154 if( SUIT_Application* anApp = aSession->activeApplication() )
155 if( SUIT_Study* aStudy = anApp->activeStudy() )
160 QString HYDROGUI_Tool::GetTempDir( const bool theToCreate )
164 char* tmpdir = getenv ( "HYDRO_TMP_DIR" );
167 // try to create folder if it does not exist
168 QFileInfo fi( tmpdir );
169 if ( !fi.exists() && theToCreate )
171 if ( QDir().mkdir( tmpdir ) )
172 QFile::setPermissions( tmpdir, (QFile::Permissions)0x4FFFF );
173 QFileInfo fi( tmpdir );
174 if ( !fi.exists() || !fi.isWritable() )
179 tmpdir = getenv ( "TEMP" );
181 tmpdir = getenv ( "TMP" );
187 tmpdir = strdup( "/tmp" );
192 QFileInfo fi( aRes );
193 if ( !fi.exists() || !fi.isWritable() )
194 aRes = QString::null;
199 void HYDROGUI_Tool::SetActiveViewManager( HYDROGUI_Module* theModule,
200 SUIT_ViewManager* theViewManager )
203 if( SUIT_ViewWindow* aViewWindow = theViewManager->getActiveView() )
204 if( STD_TabDesktop* aTabDesktop = dynamic_cast<STD_TabDesktop*>( theModule->getApp()->desktop() ) )
205 if( QtxWorkstack* aWorkstack = aTabDesktop->workstack() )
206 aWorkstack->setActiveWindow( aViewWindow );
209 bool HYDROGUI_Tool::IsObjectHasPresentation( const Handle(HYDROData_Entity)& theObject,
210 const QString& theViewerType )
212 if ( theObject.IsNull() )
215 ObjectKind anObjectKind = theObject->GetKind();
216 if ( theViewerType.isEmpty() || theViewerType == OCCViewer_Viewer::Type() )
218 if ( anObjectKind == KIND_IMAGE ||
219 anObjectKind == KIND_POLYLINEXY ||
220 anObjectKind == KIND_POLYLINE ||
221 anObjectKind == KIND_IMMERSIBLE_ZONE ||
222 anObjectKind == KIND_REGION ||
223 anObjectKind == KIND_ZONE ||
224 anObjectKind == KIND_OBSTACLE ||
225 anObjectKind == KIND_PROFILE ||
226 anObjectKind == KIND_STREAM ||
227 anObjectKind == KIND_CHANNEL ||
228 anObjectKind == KIND_DIGUE ||
229 anObjectKind == KIND_DUMMY_3D ||
230 anObjectKind == KIND_BATHYMETRY ||
231 anObjectKind == KIND_LAND_COVER_MAP
233 || anObjectKind == KIND_SHAPES_GROUP ||
234 anObjectKind == KIND_SPLITTED_GROUP
242 if ( theViewerType.isEmpty() || theViewerType == SVTK_Viewer::Type() )
244 if ( anObjectKind == KIND_BATHYMETRY )
248 if ( theViewerType.isEmpty() || theViewerType == GraphicsView_Viewer::Type() )
250 if ( anObjectKind == KIND_IMAGE ||
251 anObjectKind == KIND_POLYLINEXY )
258 void HYDROGUI_Tool::GetPrsSubObjects( HYDROGUI_Module* theModule,
259 HYDROData_SequenceOfObjects& theSeq )
261 Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( theModule->getStudyId() );
262 if( !aDocument.IsNull() )
264 HYDROData_Iterator anIterator( aDocument );
265 for( ; anIterator.More(); anIterator.Next() )
267 Handle(HYDROData_Entity) anObject = anIterator.Current();
268 if ( !IsObjectHasPresentation( anObject ) )
271 theSeq.Append( anObject );
276 HYDROGUI_Prs* HYDROGUI_Tool::GetPresentation( const Handle(HYDROData_Entity)& theObj,
277 const GraphicsView_ObjectList& theObjects )
279 if( !theObj.IsNull() )
281 GraphicsView_ObjectListIterator anIter( theObjects );
282 while( anIter.hasNext() )
284 if( HYDROGUI_Prs* aPrs = dynamic_cast<HYDROGUI_Prs*>( anIter.next() ) )
286 Handle(HYDROData_Entity) anObj = aPrs->getObject();
287 if( IsEqual( anObj, theObj ) )
295 GraphicsView_ObjectList HYDROGUI_Tool::GetPrsList( GraphicsView_ViewPort* theViewPort )
297 GraphicsView_ObjectList aList;
300 GraphicsView_ObjectListIterator anIter( theViewPort->getObjects() );
301 while( anIter.hasNext() )
302 if( HYDROGUI_Prs* aPrs = dynamic_cast<HYDROGUI_Prs*>( anIter.next() ) )
303 aList.append( aPrs );
308 HYDROData_SequenceOfObjects HYDROGUI_Tool::GetSelectedObjects( HYDROGUI_Module* theModule )
310 HYDROData_SequenceOfObjects aSeq;
312 HYDROGUI_DataModel* aModel = theModule->getDataModel();
314 SUIT_SelectionMgr* aSelectionMgr = theModule->getApp()->selectionMgr();
315 SUIT_DataOwnerPtrList anOwners;
316 aSelectionMgr->selected( anOwners );
318 QStringList aCollectedNameList; // to avoid duplication
319 foreach( SUIT_DataOwner* aSUITOwner, anOwners )
321 if( LightApp_DataOwner* anOwner = dynamic_cast<LightApp_DataOwner*>( aSUITOwner ) )
323 Handle(HYDROData_Entity) anObject = aModel->objectByEntry( anOwner->entry() );
324 if( !anObject.IsNull() )
326 QString aName = anObject->GetName();
327 if( !aCollectedNameList.contains( aName ) )
329 aSeq.Append( anObject );
330 aCollectedNameList.append( aName );
338 Handle(HYDROData_Entity) HYDROGUI_Tool::GetSelectedObject( HYDROGUI_Module* theModule )
340 HYDROData_SequenceOfObjects aSeq = GetSelectedObjects( theModule );
341 if( !aSeq.IsEmpty() )
346 HYDROData_SequenceOfObjects HYDROGUI_Tool::GetGeometryObjects(
347 HYDROGUI_Module* theModule )
349 Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( theModule->getStudyId() );
351 HYDROData_SequenceOfObjects aResSeq;
353 HYDROData_Iterator anIter( aDocument );
354 for ( ; anIter.More(); anIter.Next() )
356 Handle(HYDROData_Entity) anObj = anIter.Current();
357 if ( !HYDROData_Tool::IsGeometryObject( anObj ) )
360 aResSeq.Append( anObj );
366 ObjectKind HYDROGUI_Tool::GetSelectedPartition( HYDROGUI_Module* theModule )
368 HYDROGUI_DataModel* aModel = theModule->getDataModel();
370 SUIT_SelectionMgr* aSelectionMgr = theModule->getApp()->selectionMgr();
371 SUIT_DataOwnerPtrList anOwners;
372 aSelectionMgr->selected( anOwners );
374 if( anOwners.size() != 1 )
377 if( LightApp_DataOwner* anOwner = dynamic_cast<LightApp_DataOwner*>( anOwners.first().operator->() ) )
379 QString anEntry = anOwner->entry();
380 QString aPrefix = HYDROGUI_DataObject::entryPrefix();
381 if( anEntry.left( aPrefix.length() ) == aPrefix )
383 anEntry.remove( aPrefix );
384 for( ObjectKind anObjectKind = KIND_UNKNOWN + 1; anObjectKind <= KIND_LAST; anObjectKind++ )
385 if( HYDROGUI_DataModel::tr( HYDROGUI_DataModel::partitionName( anObjectKind ).toAscii() ) == anEntry )
392 QStringList HYDROGUI_Tool::GetSelectedGeomObjects( HYDROGUI_Module* theModule,
393 QList<GEOM::shape_type> theTypes )
395 QStringList anEntryList;
397 // Get active SalomeApp_Study
398 SalomeApp_Study* aStudy = NULL;
399 if ( theModule && theModule->getApp() ) {
400 aStudy = dynamic_cast<SalomeApp_Study*>( theModule->getApp()->activeStudy() );
407 SUIT_SelectionMgr* aSelectionMgr = theModule->getApp()->selectionMgr();
408 SUIT_DataOwnerPtrList anOwners;
409 aSelectionMgr->selected( anOwners );
411 // Check if the selected objects belong to GEOM and have a shape
412 foreach( SUIT_DataOwner* aSUITOwner, anOwners )
414 if( LightApp_DataOwner* anOwner = dynamic_cast<LightApp_DataOwner*>( aSUITOwner ) )
416 QString anEntry = anOwner->entry();
417 _PTR(SObject) aSObject( aStudy->studyDS()->FindObjectID(qPrintable(anEntry)) );
419 _PTR(SComponent) aSComponent = aSObject->GetFatherComponent();
420 if ( aSComponent && aSComponent->ComponentDataType() == "GEOM" ) {
421 GEOM::GEOM_Object_var aGeomObj =
422 GEOMBase::GetObjectFromIOR( aSObject->GetIOR().c_str() );
424 if ( !aGeomObj->_is_nil() && aGeomObj->IsShape() &&
425 theTypes.contains( aGeomObj->GetShapeType() ) ) {
426 anEntryList << anEntry;
436 Handle(HYDROData_Entity) HYDROGUI_Tool::FindObjectByName( HYDROGUI_Module* theModule,
437 const QString& theName,
438 const ObjectKind theObjectKind )
440 Handle(HYDROData_Entity) aResObj;
442 Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( theModule->getStudyId() );
443 if ( !aDocument.IsNull() )
444 aResObj = aDocument->FindObjectByName( theName, theObjectKind );
449 HYDROData_SequenceOfObjects HYDROGUI_Tool::FindObjectsByNames( HYDROGUI_Module* theModule,
450 const QStringList& theNames,
451 const ObjectKind theObjectKind )
453 HYDROData_SequenceOfObjects aResSeq;
455 Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( theModule->getStudyId() );
456 if ( !aDocument.IsNull() )
457 aResSeq = aDocument->FindObjectsByNames( theNames, theObjectKind );
462 QString HYDROGUI_Tool::GenerateObjectName( HYDROGUI_Module* theModule,
463 const QString& thePrefix,
464 const QStringList& theUsedNames,
465 const bool theIsTryToUsePurePrefix)
467 Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( theModule->getStudyId() );
468 return HYDROData_Tool::GenerateObjectName( aDocument, thePrefix, theUsedNames, theIsTryToUsePurePrefix );
471 size_t HYDROGUI_Tool::GetActiveViewId( HYDROGUI_Module* theModule,
472 const QString& theViewId )
475 SUIT_ViewManager* aViewMgr = theModule->getApp()->activeViewManager();
476 if( !aViewMgr || ( !theViewId.isEmpty() && aViewMgr->getType() != theViewId ) )
479 if( SUIT_ViewModel* aViewer = aViewMgr->getViewModel() )
480 aViewId = (size_t)aViewer;
484 size_t HYDROGUI_Tool::GetActiveGraphicsViewId( HYDROGUI_Module* theModule )
486 return GetActiveViewId( theModule, GraphicsView_Viewer::Type() );
489 size_t HYDROGUI_Tool::GetActiveOCCViewId( HYDROGUI_Module* theModule )
491 return GetActiveViewId( theModule, OCCViewer_Viewer::Type() );
494 QList<size_t> getViewIdList( HYDROGUI_Module* theModule,
495 const QString& theViewId )
498 ViewManagerList aViewMgrs;
499 theModule->getApp()->viewManagers( theViewId, aViewMgrs );
500 QListIterator<SUIT_ViewManager*> anIter( aViewMgrs );
501 while( anIter.hasNext() )
503 if( SUIT_ViewManager* aViewMgr = anIter.next() )
505 if( SUIT_ViewModel* aViewer = aViewMgr->getViewModel() )
506 aList.append( (size_t)aViewer );
512 QList<size_t> HYDROGUI_Tool::GetGraphicsViewIdList( HYDROGUI_Module* theModule )
514 return getViewIdList( theModule, GraphicsView_Viewer::Type() );
517 QList<size_t> HYDROGUI_Tool::GetOCCViewIdList( HYDROGUI_Module* theModule )
519 return getViewIdList( theModule, OCCViewer_Viewer::Type() );
522 void HYDROGUI_Tool::setOCCActionShown( OCCViewer_ViewFrame* theViewFrame,
523 const int theActionId,
529 OCCViewer_ViewWindow* aView = theViewFrame->getView( OCCViewer_ViewFrame::MAIN_VIEW );
531 aView->toolMgr()->setShown( theActionId, isShown );
532 if ( theActionId == OCCViewer_ViewWindow::MaximizedId )
533 theViewFrame->onMaximizedView( aView, true );
537 void HYDROGUI_Tool::setOCCActionShown( HYDROGUI_Module* theModule,
538 const int theActionId,
542 ViewManagerList aViewMgrs;
543 theModule->getApp()->viewManagers( OCCViewer_Viewer::Type(), aViewMgrs );
544 QListIterator<SUIT_ViewManager*> anIter( aViewMgrs );
545 while( anIter.hasNext() )
547 if( SUIT_ViewManager* aViewMgr = anIter.next() )
549 OCCViewer_ViewFrame* aViewFrame = dynamic_cast<OCCViewer_ViewFrame*>
550 ( aViewMgr->getActiveView() );
552 setOCCActionShown( aViewFrame, theActionId, isShown );
557 void HYDROGUI_Tool::GetObjectReferences( const Handle(HYDROData_Entity)& theObj,
558 HYDROData_SequenceOfObjects& theRefObjects,
559 QStringList& theRefNames )
561 if( theObj.IsNull() )
564 HYDROData_SequenceOfObjects anAllRefObjects = theObj->GetAllReferenceObjects();
565 theRefObjects.Append( anAllRefObjects );
567 for( int i = 1, n = anAllRefObjects.Length(); i <= n; ++i )
569 Handle(HYDROData_Entity) aRefObj = theRefObjects.Value( i );
570 if( aRefObj.IsNull() || aRefObj->IsRemoved() )
573 QString aRefObjectName = aRefObj->GetName();
574 if( theRefNames.contains( aRefObjectName ) )
577 theRefObjects.Append( aRefObj );
578 theRefNames.append( aRefObjectName );
580 GetObjectReferences( aRefObj, theRefObjects, theRefNames );
584 HYDROData_SequenceOfObjects HYDROGUI_Tool::GetObjectBackReferences(
585 HYDROGUI_Module* theModule,
586 const Handle(HYDROData_Entity)& theObj )
588 if( theObj.IsNull() )
589 return HYDROData_SequenceOfObjects();
591 QString anObjName = theObj->GetName();
593 QMap<QString,HYDROData_SequenceOfObjects> aMapOfBackRefs =
594 GetObjectsBackReferences( theModule, QStringList() << anObjName );
596 return aMapOfBackRefs[ anObjName ];
599 QMap<QString,HYDROData_SequenceOfObjects> HYDROGUI_Tool::GetObjectsBackReferences(
600 HYDROGUI_Module* theModule, const QStringList& theObjectNames )
602 QMap<QString,HYDROData_SequenceOfObjects> aResMap;
604 if( theObjectNames.isEmpty() )
607 Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( theModule->getStudyId() );
608 if( aDocument.IsNull() )
611 HYDROData_Iterator anIterator( aDocument );
612 for( ; anIterator.More(); anIterator.Next() )
614 Handle(HYDROData_Entity) anObject = anIterator.Current();
615 if( anObject.IsNull() || anObject->IsRemoved() )
618 QString anObjectName = anObject->GetName();
619 if ( theObjectNames.contains( anObjectName ) )
622 HYDROData_SequenceOfObjects aRefObjects = anObject->GetAllReferenceObjects();
623 for ( int i = 1, n = aRefObjects.Length(); i <= n; ++i )
625 Handle(HYDROData_Entity) aRefObject = aRefObjects.Value( i );
626 if( aRefObject.IsNull() || aRefObject->IsRemoved() )
629 QString aRefObjectName = aRefObject->GetName();
630 if ( !theObjectNames.contains( aRefObjectName ) )
633 aResMap[ aRefObjectName ].Append( anObject );
640 QDockWidget* HYDROGUI_Tool::WindowDock( QWidget* wid )
645 QDockWidget* dock = 0;
646 QWidget* w = wid->parentWidget();
649 dock = ::qobject_cast<QDockWidget*>( w );
650 w = w->parentWidget();
655 QColor HYDROGUI_Tool::GenerateFillingColor( HYDROGUI_Module* theModule,
656 const QStringList& theZoneNames )
658 Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( theModule->getStudyId() );
659 return GenerateFillingColor( aDocument, theZoneNames );
662 QColor HYDROGUI_Tool::GenerateFillingColor( const Handle(HYDROData_Document)& theDoc,
663 const QStringList& theZoneNames )
665 QColor aFillingColor( HYDROData_ImmersibleZone::DefaultFillingColor() );
668 int aR = 0, aG = 0, aB = 0;
669 QStringListIterator aZoneNameIter( theZoneNames );
670 while( aZoneNameIter.hasNext() )
672 const QString& aZoneName = aZoneNameIter.next();
673 Handle(HYDROData_ImmersibleZone) aRefZone =
674 Handle(HYDROData_ImmersibleZone)::DownCast( theDoc->FindObjectByName( aZoneName, KIND_IMMERSIBLE_ZONE ) );
675 if( !aRefZone.IsNull() )
677 QColor aRefColor = aRefZone->GetFillingColor();
678 aR += aRefColor.red();
679 aG += aRefColor.green();
680 aB += aRefColor.blue();
687 aFillingColor = QColor( aR / aCounter, aG / aCounter, aB / aCounter );
690 return aFillingColor;
693 QStringList HYDROGUI_Tool::FindExistingObjectsNames( const Handle(HYDROData_Document)& theDoc,
694 const ObjectKind theObjectKind,
695 bool isCheckValidProfile )
699 HYDROData_Iterator anIter( theDoc, theObjectKind );
700 for ( ; anIter.More(); anIter.Next() ) {
701 Handle(HYDROData_Entity) anObject = anIter.Current();
703 bool isOK = !anObject.IsNull();
705 if( isOK && isCheckValidProfile )
707 Handle_HYDROData_Profile aProfile = Handle_HYDROData_Profile::DownCast( anObject );
708 if( !aProfile.IsNull() && !aProfile->IsValid() )
713 aNames.append( anObject->GetName() );
719 QString HYDROGUI_Tool::GetCoordinateString( const double theNumber, bool isInLocale )
723 static QLocale aLocale( QLocale::English, QLocale::France );
724 return aLocale.toString( theNumber, 'f', 2 );
727 return QString::number( theNumber, 'f', 2 );
730 Handle(Image_PixMap) HYDROGUI_Tool::Pixmap( const QImage& theImage )
732 Handle(Image_PixMap) pix;
733 if ( theImage.isNull() || theImage.format() == QImage::Format_Invalid )
736 Handle(Image_PixMap) tmpPix = new Image_PixMap();
737 tmpPix->SetTopDown( false );
738 QImage anImage = theImage.mirrored();
739 if ( !anImage.hasAlphaChannel() && anImage.allGray() )
741 tmpPix->InitTrash( Image_PixMap::ImgGray, anImage.width(), anImage.height(), anImage.width() );
742 for ( int r = 0; r < anImage.height(); r++ )
744 Standard_Byte* aRowData = tmpPix->ChangeRow( anImage.height() - r - 1 );
745 for ( int p = 0; p < anImage.width(); p++ )
746 aRowData[p] = qRed( anImage.pixel( p, r ) );
751 Image_PixMap::ImgFormat aFormat;
752 if ( anImage.hasAlphaChannel() )
754 if ( anImage.format() != QImage::Format_ARGB32 )
755 anImage = anImage.convertToFormat( QImage::Format_ARGB32 );
756 aFormat = Image_PixMap::ImgRGBA;
760 if ( anImage.format() != QImage::Format_RGB888 )
761 anImage = anImage.convertToFormat( QImage::Format_RGB888 );
762 aFormat = Image_PixMap::ImgRGB;
765 tmpPix->InitWrapper( aFormat, (Standard_Byte*)anImage.bits(), anImage.width(), anImage.height(), anImage.bytesPerLine() );
768 if ( !tmpPix.IsNull() )
770 pix = new Image_PixMap();
771 pix->InitCopy( *tmpPix.operator->() );
772 pix->SetTopDown( tmpPix->IsTopDown() );
778 void HYDROGUI_Tool::DeleteGeomObjects( HYDROGUI_Module* theModule, const QStringList& theEntries )
780 QStringList anEntryList;
782 // Get active SalomeApp_Study
783 SalomeApp_Study* aStudy = NULL;
784 if ( theModule && theModule->getApp() ) {
785 aStudy = dynamic_cast<SalomeApp_Study*>( theModule->getApp()->activeStudy() );
792 GEOM::GEOM_Gen_var aGeomEngine = GeometryGUI::GetGeomGen();
793 if ( aGeomEngine->_is_nil() ) {
797 // Delete GEOM objects
798 _PTR(StudyBuilder) aStudyBuilder( aStudy->studyDS()->NewBuilder() );
799 foreach ( const QString anEntry, theEntries ) {
800 _PTR(SObject) aSObject( aStudy->studyDS()->FindObjectID( qPrintable(anEntry) ) );
802 GEOM::GEOM_Object_var aGeomObj =
803 GEOMBase::GetObjectFromIOR( aSObject->GetIOR().c_str() );
805 if ( !aGeomObj->_is_nil() ) {
806 aGeomEngine->RemoveObject( aGeomObj );
809 aStudyBuilder->RemoveObject( aSObject );