#include "GEOMToolsGUI_PublishDlg.h"
#include "GEOMToolsGUI_MaterialPropertiesDlg.h"
#include "GEOMToolsGUI_LineWidthDlg.h"
-#include "Material_Model.h"
+#include <Material_Model.h>
+
+#include <GEOM_VTKPropertyMaterial.hxx>
#include <GeometryGUI.h>
#include <GeometryGUI_Operations.h>
// VTK includes
#include <vtkRenderer.h>
+class QtxDialog;
// If the next macro is defined, autocolor feature works for all sub-shapes;
// if it is undefined, autocolor feature works for groups only
#define GENERAL_AUTOCOLOR
SUIT_ViewWindow* window = app->desktop()->activeWindow();
if ( !window ) return;
- bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
- bool isVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
+ bool isOCC = window->getViewManager()->getType() == OCCViewer_Viewer::Type();
+ bool isVTK = window->getViewManager()->getType() == SVTK_Viewer::Type();
// get view id
int mgrId = window->getViewManager()->getGlobalId();
bool isVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
// get view id
- int mgrId = window->getViewManager()->getGlobalId();
+ int mgrId = window ? window->getViewManager()->getGlobalId() : -1;
if ( isVTK ) {
SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>( window );
// get initial color (use first object from selection)
SVTK_View* aView = vtkVW->getView();
QColor color = aView->GetColor( selected.First() );
- QVariant v = appStudy->getObjectProperty( mgrId, selected.First()->getEntry(), COLOR_PROP, color );
+ QVariant v = appStudy->getObjectProperty( mgrId, selected.First()->getEntry(), GEOM::propertyName( GEOM::Color ), color );
// show Choose Color dialog box
color = QColorDialog::getColor( v.value<QColor>(), app->desktop() );
QColor color = QColor((int)( aColor.Red() * 255.0 ),
(int)( aColor.Green() * 255.0 ),
(int)( aColor.Blue() * 255.0 ));
- QVariant v = appStudy->getObjectProperty( mgrId, selected.First()->getEntry(), COLOR_PROP, color );
+ QVariant v = appStudy->getObjectProperty( mgrId, selected.First()->getEntry(), GEOM::propertyName( GEOM::Color ), color );
// show Choose Color dialog box
color = QColorDialog::getColor( v.value<QColor>(), app->desktop() );
{
// get material property
QString matProp;
- matProp = study->getObjectProperty( mgrId, IO->getEntry(), MATERIAL_PROP, matProp ).toString();
+ matProp = study->getObjectProperty( mgrId, IO->getEntry(), GEOM::propertyName( GEOM::Material ), matProp ).toString();
Material_Model material;
material.fromProperties( matProp );
// change color only for shapes with not physical type of material
if ( !material.isPhysical() ) {
view->SetColor( IO, color );
- study->setObjectProperty( mgrId, IO->getEntry(), COLOR_PROP, color );
+ study->setObjectProperty( mgrId, IO->getEntry(), GEOM::propertyName( GEOM::Color ), color );
}
// store color to GEOM_Object
// get material property
QString matProp;
- matProp = study->getObjectProperty( mgrId, IO->getEntry(), MATERIAL_PROP, matProp ).toString();
+ matProp = study->getObjectProperty( mgrId, IO->getEntry(), GEOM::propertyName( GEOM::Material ), matProp ).toString();
Material_Model material;
material.fromProperties( matProp );
io->Redisplay( Standard_True );
- study->setObjectProperty( mgrId, IO->getEntry(), COLOR_PROP, color );
+ study->setObjectProperty( mgrId, IO->getEntry(), GEOM::propertyName( GEOM::Color ), color );
}
// store color to GEOM_Object
OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*>( window->getViewManager()->getViewModel() );
Handle (AIS_InteractiveContext) ic = vm->getAISContext();
+ int aMgrId = window->getViewManager()->getGlobalId();
ic->InitCurrent();
if ( ic->MoreCurrent() ) {
}
for(; ic->MoreCurrent(); ic->NextCurrent()) {
- int aMgrId = window->getViewManager()->getGlobalId();
CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current());
Handle(AIS_Drawer) CurDrawer = CurObject->Attributes();
- QVariant v = aStudy->getObjectProperty( aMgrId, CurObject->getIO()->getEntry(), EDGE_WIDTH_PROP , QVariant() );
+ QVariant v = aStudy->getObjectProperty( aMgrId, CurObject->getIO()->getEntry(), GEOM::propertyName( GEOM::LineWidth ) , QVariant() );
int width = v.isValid() ? v.toInt() : 1;
ic->SetLocalAttributes(CurObject, CurDrawer);
ic->Redisplay(CurObject);
- QString anIsos("%1%2%3");anIsos = anIsos.arg(newNbUIso);anIsos = anIsos.arg(DIGIT_SEPARATOR);anIsos = anIsos.arg(newNbVIso);
- aStudy->setObjectProperty(aMgrId ,CurObject->getIO()->getEntry(), ISOS_PROP, anIsos);
+ QString anIsos = QString("%1%2%3").arg(newNbUIso).arg(GEOM::subSectionSeparator()).arg(newNbVIso);
+ aStudy->setObjectProperty(aMgrId ,CurObject->getIO()->getEntry(), GEOM::propertyName( GEOM::NbIsos ), anIsos);
}
}
GeometryGUI::Modified();
if ( !vtkVW )
return;
+ int aMgrId = window->getViewManager()->getGlobalId();
+
SALOME_View* view = GEOM_Displayer::GetActiveView();
vtkActorCollection* aCollection = vtkActorCollection::New();
anActor->SetNbIsos(aIsos);
anActor->StoreIsoNumbers();
- QString anIsos("%1%2%3");anIsos = anIsos.arg(newNbUIso);anIsos = anIsos.arg(DIGIT_SEPARATOR);anIsos = anIsos.arg(newNbVIso);
- int aMgrId = window->getViewManager()->getGlobalId();
- aStudy->setObjectProperty(aMgrId ,anActor->getIO()->getEntry(), ISOS_PROP, anIsos);
+ QString anIsos = QString("%1%2%3").arg(newNbUIso).arg(GEOM::subSectionSeparator()).arg(newNbVIso);
+ aStudy->setObjectProperty(aMgrId ,anActor->getIO()->getEntry(), GEOM::propertyName( GEOM::NbIsos ), anIsos);
}
anAct = aCollection->GetNextActor();
}
bool isOCC = (window && window->getViewManager()->getType() == OCCViewer_Viewer::Type());
bool isVTK = (window && window->getViewManager()->getType() == SVTK_Viewer::Type());
- int mgrId = window->getViewManager()->getGlobalId();
+ int mgrId = window ? window->getViewManager()->getGlobalId() : -1;
if (isOCC) { // if is OCCViewer
OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*>(window->getViewManager()->getViewModel());
CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current());
ic->SetDeviationCoefficient(CurObject, aNewDC, Standard_True);
ic->Redisplay(CurObject);
- appStudy->setObjectProperty(mgrId,CurObject->getIO()->getEntry(), DEFLECTION_COEFF_PROP, aNewDC);
+ appStudy->setObjectProperty(mgrId,CurObject->getIO()->getEntry(), GEOM::propertyName( GEOM::Deflection ), aNewDC);
}
}
}
if (GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(anAct)) {
// There are no casting to needed actor.
anActor->SetDeflection(aDC);
- appStudy->setObjectProperty(mgrId, anActor->getIO()->getEntry(), DEFLECTION_COEFF_PROP, aDC);
+ appStudy->setObjectProperty(mgrId, anActor->getIO()->getEntry(), GEOM::propertyName( GEOM::Deflection ), aDC);
}
anAct = aCollection->GetNextActor();
}
void GEOMToolsGUI::OnMaterialProperties()
{
- GEOMToolsGUI_MaterialPropertiesDlg dlg( SUIT_Session::session()->activeApplication()->desktop() );
+ GEOMToolsGUI_MaterialPropertiesDlg* dlg = new GEOMToolsGUI_MaterialPropertiesDlg( SUIT_Session::session()->activeApplication()->desktop(), true, false, QtxDialog::OK | QtxDialog::Close | QtxDialog::Apply | QtxDialog::Help );
+ dlg->show();
+}
+
+void GEOMToolsGUI::OnMaterialsLibrary()
+{
+ GEOMToolsGUI_MaterialPropertiesDlg dlg( SUIT_Session::session()->activeApplication()->desktop(), false, true, QtxDialog::Standard );
+ dlg.setWindowTitle( tr( "MATERIAL_LIBRARY_TLT" ) );
dlg.exec();
}
bool isOCC = (window && window->getViewManager()->getType() == OCCViewer_Viewer::Type());
bool isVTK = (window && window->getViewManager()->getType() == SVTK_Viewer::Type());
- int mgrId = window->getViewManager()->getGlobalId();
+ int mgrId = window ? window->getViewManager()->getGlobalId() : -1;
if (isOCC) { // if is OCCViewer
OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*>(window->getViewManager()->getViewModel());
ic->Redisplay(cur);
}
}
- appStudy->setObjectProperty(mgrId, CurObject->getIO()->getEntry(), EDGE_WIDTH_PROP, aNewWidth);
+ appStudy->setObjectProperty(mgrId, CurObject->getIO()->getEntry(), GEOM::propertyName( GEOM::LineWidth ), aNewWidth);
}
}
}
if (GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(anAct)) {
// There are no casting to needed actor.
anActor->SetWidth(aWidth);
- appStudy->setObjectProperty(mgrId, anActor->getIO()->getEntry(), EDGE_WIDTH_PROP, aWidth);
+ appStudy->setObjectProperty(mgrId, anActor->getIO()->getEntry(), GEOM::propertyName( GEOM::LineWidth ), aWidth);
}
anAct = aCollection->GetNextActor();
}
OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*>( window->getViewManager()->getViewModel() );
Handle (AIS_InteractiveContext) ic = vm->getAISContext();
+ int aMgrId = window->getViewManager()->getGlobalId();
ic->InitCurrent();
if ( ic->MoreCurrent() ) {
return;
for(; ic->MoreCurrent(); ic->NextCurrent()) {
- int aMgrId = window->getViewManager()->getGlobalId();
CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current());
Handle(AIS_Drawer) CurDrawer = CurObject->Attributes();
ic->Redisplay(CurObject);
- aStudy->setObjectProperty(aMgrId ,CurObject->getIO()->getEntry(), ISOS_WIDTH_PROP, aWidth);
+ aStudy->setObjectProperty(aMgrId ,CurObject->getIO()->getEntry(), GEOM::propertyName( GEOM::IsosWidth ), aWidth);
}
GeometryGUI::Modified();
}
if ( !vtkVW )
return;
+ int aMgrId = window->getViewManager()->getGlobalId();
+
SALOME_View* view = GEOM_Displayer::GetActiveView();
vtkActorCollection* aCollection = vtkActorCollection::New();
if(GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(anAct)) {
// There are no casting to needed actor.
anActor->SetIsosWidth(aWidth);
- int aMgrId = window->getViewManager()->getGlobalId();
- aStudy->setObjectProperty(aMgrId ,anActor->getIO()->getEntry(), ISOS_WIDTH_PROP, aWidth);
+ aStudy->setObjectProperty(aMgrId ,anActor->getIO()->getEntry(), GEOM::propertyName( GEOM::IsosWidth ), aWidth);
}
anAct = aCollection->GetNextActor();
}
if ( isOCC ) {
GEOMBase* gb = new GEOMBase();
Handle(GEOM_AISShape) aisShape;
+ int aMgrId = window->getViewManager()->getGlobalId();
Handle(AIS_InteractiveContext) ic = vm->getAISContext();
SALOME_ListIO anIOlst;
for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
aisShape = gb->ConvertIOinGEOMAISShape( It.Value(), true );
if ( !aisShape.IsNull() ) {
+ appStudy->setObjectProperty( aMgrId, aisShape->getIO()->getEntry(), GEOM::propertyName( GEOM::TopLevel ), checked );
aisShape->setTopLevel(checked);
- int aMgrId = window->getViewManager()->getGlobalId();
- appStudy->setObjectProperty( aMgrId, aisShape->getIO()->getEntry(), TOP_LEVEL_PROP, checked );
anIOlst.Append(aisShape->getIO());
}
} // for...
OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*>( window->getViewManager()->getViewModel() );
Handle (AIS_InteractiveContext) ic = vm->getAISContext();
+ int aMgrId = window->getViewManager()->getGlobalId();
SALOME_ListIO anIOlst;
AIS_ListOfInteractive aList;
if(CurObject.IsNull())
continue;
+ appStudy->setObjectProperty( aMgrId, QString(CurObject->getIO()->getEntry()), GEOM::propertyName( GEOM::TopLevel ), Standard_False );
CurObject->setTopLevel(Standard_False);
-
- int aMgrId = window->getViewManager()->getGlobalId();
- appStudy->setObjectProperty( aMgrId, QString(CurObject->getIO()->getEntry()), TOP_LEVEL_PROP, Standard_False );
anIOlst.Append(CurObject->getIO());
}
disp->Redisplay(anIOlst);
}
}
+void GEOMToolsGUI::OnSetMaterial( const QVariant& theParam )
+{
+ if ( !theParam.canConvert<QString>() ) return;
+
+ QString theName = theParam.toString();
+
+ SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
+ if ( !app ) return;
+
+ SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
+ if ( !study ) return;
+
+ LightApp_SelectionMgr* selMgr = app->selectionMgr();
+
+ SALOME_ListIO selected;
+ selMgr->selectedObjects( selected );
+
+ if ( selected.IsEmpty() ) return;
+
+ GEOM_Displayer displayer( study );
+
+ SALOME_View* window = displayer.GetActiveView();
+ if ( !window ) return;
+
+ int mgrId = dynamic_cast<SUIT_ViewModel*>( window )->getViewManager()->getGlobalId();
+
+ Material_Model aModel;
+ aModel.fromResources( theName );
+ QString prop = aModel.toProperties();
+
+ for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
+ Handle(SALOME_InteractiveObject) io = It.Value();
+ study->setObjectProperty( mgrId, io->getEntry(), GEOM::propertyName( GEOM::Material ), prop );
+ if ( window->isVisible( io ) ) displayer.Redisplay( io, false );
+ }
+ displayer.UpdateViewer();
+}