-// 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
//
// 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 <GeometryGUI.h>
+#include <GEOM_Constants.h>
#include <GEOM_Displayer.h>
+#include <Basics_OCCTVersion.hxx>
+
#include <QtxComboBox.h>
#include <SUIT_ResourceMgr.h>
#include <SUIT_Session.h>
+#include <SUIT_ViewWindow.h>
+#include <SUIT_Desktop.h>
+#include <SUIT_ViewManager.h>
#include <LightApp_SelectionMgr.h>
#include <SalomeApp_Application.h>
#include <SalomeApp_Study.h>
GEOMToolsGUI_MarkerDlg::~GEOMToolsGUI_MarkerDlg()
{
- myOperation->Destroy();
+ myOperation->UnRegister();
}
void GEOMToolsGUI_MarkerDlg::setStandardMarker( GEOM::marker_type type, GEOM::marker_size size )
{
if ( getStudy() ) {
LightApp_SelectionMgr* selMgr = qobject_cast<SalomeApp_Application*>( 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 );
+ }
}
}
}
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;
+ }
+ }
+ }
}
}
}
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 );
}
}
}