X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGEOMToolsGUI%2FGEOMToolsGUI_MarkerDlg.cxx;h=4ba147b787100ca8a7d9ba29be122d251e6991ab;hb=46c866d149f7e60135fb1cf5ad9979680b041bf3;hp=cb5b81754b30bcdc030e21a7f25d2867bfa66ac5;hpb=cb234e246225d575d6682ca4587e54b5f6f30497;p=modules%2Fgeom.git diff --git a/src/GEOMToolsGUI/GEOMToolsGUI_MarkerDlg.cxx b/src/GEOMToolsGUI/GEOMToolsGUI_MarkerDlg.cxx index cb5b81754..4ba147b78 100644 --- a/src/GEOMToolsGUI/GEOMToolsGUI_MarkerDlg.cxx +++ b/src/GEOMToolsGUI/GEOMToolsGUI_MarkerDlg.cxx @@ -1,7 +1,4 @@ -// Copyright (C) 2007-2009 CEA/DEN, EDF R&D, OPEN CASCADE -// -// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -19,18 +16,24 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // + // File : GEOMToolsGUI_MarkerDlg.cxx // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) -// #include "GEOMToolsGUI_MarkerDlg.h" #include +#include #include +#include + #include #include #include +#include +#include +#include #include #include #include @@ -160,7 +163,7 @@ GEOMToolsGUI_MarkerDlg::GEOMToolsGUI_MarkerDlg( QWidget* parent ) GEOMToolsGUI_MarkerDlg::~GEOMToolsGUI_MarkerDlg() { - myOperation->Destroy(); + myOperation->UnRegister(); } void GEOMToolsGUI_MarkerDlg::setStandardMarker( GEOM::marker_type type, GEOM::marker_size size ) @@ -207,24 +210,38 @@ void GEOMToolsGUI_MarkerDlg::accept() { if ( getStudy() ) { LightApp_SelectionMgr* selMgr = qobject_cast( getStudy()->application() )->selectionMgr(); - if ( selMgr ) { - SALOME_ListIO selected; - selMgr->selectedObjects( selected ); - if ( !selected.IsEmpty() ) { - _PTR(Study) study = getStudy()->studyDS(); - for ( SALOME_ListIteratorOfListIO it( selected ); it.More(); it.Next() ) { - _PTR(SObject) aSObject( study->FindObjectID( it.Value()->getEntry() ) ); - GEOM::GEOM_Object_var anObject = - GEOM::GEOM_Object::_narrow( GeometryGUI::ClientSObjectToObject( aSObject ) ); - if ( !anObject->_is_nil() ) { - if ( myWGStack->currentIndex() == 0 ) - anObject->SetMarkerStd( getMarkerType(), getStandardMarkerScale() ); - else if ( getCustomMarkerID() > 0 ) - anObject->SetMarkerTexture( getCustomMarkerID() ); - } - } - GEOM_Displayer displayer( getStudy() ); - displayer.Redisplay( selected, true ); + + SUIT_ViewWindow* window = getStudy()->application()->desktop()->activeWindow(); + if (window && window->getViewManager()) { + int mgrId = window->getViewManager()->getGlobalId(); + if ( selMgr ) { + SALOME_ListIO selected; + selMgr->selectedObjects( selected ); + if ( !selected.IsEmpty() ) { + _PTR(Study) study = getStudy()->studyDS(); + for ( SALOME_ListIteratorOfListIO it( selected ); it.More(); it.Next() ) { + _PTR(SObject) aSObject( study->FindObjectID( it.Value()->getEntry() ) ); + GEOM::GEOM_Object_var anObject = + GEOM::GEOM_Object::_narrow( GeometryGUI::ClientSObjectToObject( aSObject ) ); + if ( !anObject->_is_nil() ) { + if ( myWGStack->currentIndex() == 0 ) { + anObject->SetMarkerStd( getMarkerType(), getStandardMarkerScale() ); + QString aMarker = "%1%2%3"; + aMarker = aMarker.arg(getMarkerType()); + aMarker = aMarker.arg(DIGIT_SEPARATOR); + aMarker = aMarker.arg(getStandardMarkerScale()); + getStudy()->setObjectProperty(mgrId ,it.Value()->getEntry(),MARKER_TYPE_PROP, aMarker); + } + else if ( getCustomMarkerID() > 0 ) { + anObject->SetMarkerTexture( getCustomMarkerID() ); + getStudy()->setObjectProperty(mgrId ,it.Value()->getEntry(),MARKER_TYPE_PROP, QString::number(getCustomMarkerID())); + } + } + } + GEOM_Displayer displayer( getStudy() ); + displayer.Redisplay( selected, true ); + selMgr->setSelectedObjects( selected ); + } } } } @@ -277,35 +294,35 @@ void GEOMToolsGUI_MarkerDlg::init() SALOME_ListIO selected; selMgr->selectedObjects( selected ); if ( !selected.IsEmpty() ) { - _PTR(Study) study = getStudy()->studyDS(); - for ( SALOME_ListIteratorOfListIO it( selected ); it.More(); it.Next() ) { - _PTR(SObject) aSObject( study->FindObjectID( it.Value()->getEntry() ) ); - GEOM::GEOM_Object_var anObject = - GEOM::GEOM_Object::_narrow( GeometryGUI::ClientSObjectToObject( aSObject ) ); - if ( !anObject->_is_nil() ) { - GEOM::marker_type mtype = anObject->GetMarkerType(); - if ( aType == -1 ) - aType = mtype; - else if ( aType != mtype ) { - aType = (GEOM::marker_type)-1; - break; - } - if ( mtype > GEOM::MT_NONE && mtype < GEOM::MT_USER ) { - GEOM::marker_size msize = anObject->GetMarkerSize(); - if ( aSize == -1 ) - aSize = msize; - else if ( aSize != msize ) - break; - } - else if ( mtype == GEOM::MT_USER ) { - int mtexture = anObject->GetMarkerTexture(); - if ( aTexture == 0 ) - aTexture = mtexture; - else if ( aTexture != mtexture ) - break; - } - } - } + _PTR(Study) study = getStudy()->studyDS(); + for ( SALOME_ListIteratorOfListIO it( selected ); it.More(); it.Next() ) { + _PTR(SObject) aSObject( study->FindObjectID( it.Value()->getEntry() ) ); + GEOM::GEOM_Object_var anObject = + GEOM::GEOM_Object::_narrow( GeometryGUI::ClientSObjectToObject( aSObject ) ); + if ( !anObject->_is_nil() ) { + GEOM::marker_type mtype = anObject->GetMarkerType(); + if ( aType == -1 ) + aType = mtype; + else if ( aType != mtype ) { + aType = (GEOM::marker_type)-1; + break; + } + if ( mtype > GEOM::MT_NONE && mtype < GEOM::MT_USER ) { + GEOM::marker_size msize = anObject->GetMarkerSize(); + if ( aSize == -1 ) + aSize = msize; + else if ( aSize != msize ) + break; + } + else if ( mtype == GEOM::MT_USER ) { + int mtexture = anObject->GetMarkerTexture(); + if ( aTexture == 0 ) + aTexture = mtexture; + else if ( aTexture != mtexture ) + break; + } + } + } } } } @@ -315,32 +332,38 @@ void GEOMToolsGUI_MarkerDlg::init() setCustomMarker( aTexture ); else setStandardMarker((GEOM::marker_type)(resMgr->integerValue("Geometry", "type_of_marker", (int)Aspect_TOM_PLUS) + 1), - (GEOM::marker_size)(resMgr->integerValue("Geometry", "marker_scale", 1))); + (GEOM::marker_size)(resMgr->integerValue("Geometry", "marker_scale", 1))); } void GEOMToolsGUI_MarkerDlg::addTexture( int id, bool select ) const { if ( id > 0 && myCustomTypeCombo->index( id ) == -1 ) { int tWidth, tHeight; - Handle(Graphic3d_HArray1OfBytes) texture = GeometryGUI::getTexture( getStudy(), id, tWidth, tHeight ); + +#if OCC_VERSION_LARGE > 0x06040000 // Porting to OCCT6.5.1 + Handle(TColStd_HArray1OfByte) texture = GeometryGUI::getTexture(getStudy(), id, tWidth, tHeight); +#else + Handle(Graphic3d_HArray1OfBytes) texture = GeometryGUI::getTexture(getStudy(), id, tWidth, tHeight); +#endif + if ( !texture.IsNull() && texture->Length() == tWidth*tHeight/8 ) { QImage image( tWidth, tHeight, QImage::Format_Mono ); image.setColor( 0, qRgba( 0, 0, 0, 0 ) ); image.setColor( 1, qRgba( 0, 0, 0, 255 ) ); int bytesperline = tWidth/8; for ( int j = texture->Lower(); j <= texture->Upper(); j++ ) { - uchar val = (uchar)texture->Value( j ); - for ( int k = 0; k < 8; k++ ) { - int row = ( j - texture->Lower() ) / bytesperline; - int col = ( ( j - texture->Lower() ) % bytesperline ) * 8 + k; - image.setPixel( row, col, ( val & (1<<(8-k-1)) ) ? 1 : 0 ); - } + uchar val = (uchar)texture->Value( j ); + for ( int k = 0; k < 8; k++ ) { + int row = ( j - texture->Lower() ) / bytesperline; + int col = ( ( j - texture->Lower() ) % bytesperline ) * 8 + k; + image.setPixel( row, col, ( val & (1<<(8-k-1)) ) ? 1 : 0 ); + } } QPixmap pixmap = QPixmap::fromImage( image ); if ( !pixmap.isNull() ) { - myCustomTypeCombo->addItem( pixmap, QString::number( id ) ); - myCustomTypeCombo->setId( myCustomTypeCombo->count()-1, id ); - if ( select ) myCustomTypeCombo->setCurrentId( id ); + myCustomTypeCombo->addItem( pixmap, QString::number( id ) ); + myCustomTypeCombo->setId( myCustomTypeCombo->count()-1, id ); + if ( select ) myCustomTypeCombo->setCurrentId( id ); } } }