mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2024-12-31 03:40:35 +05:00
Fix for imp 0020845: EDF 1376 GUI : More shortcuts.
This commit is contained in:
parent
343553810e
commit
35a3b96395
@ -377,7 +377,11 @@ void GeometryGUI::OnGUIEvent( int id )
|
||||
case GEOMOp::OpDeflection: // POPUP MENU - DEFLECTION COEFFICIENT
|
||||
case GEOMOp::OpColor: // POPUP MENU - COLOR
|
||||
case GEOMOp::OpTransparency: // POPUP MENU - TRANSPARENCY
|
||||
case GEOMOp::OpIncrTransparency: // SHORTCUT - INCREASE TRANSPARENCY
|
||||
case GEOMOp::OpDecrTransparency: // SHORTCUT - DECREASE TRANSPARENCY
|
||||
case GEOMOp::OpIsos: // POPUP MENU - ISOS
|
||||
case GEOMOp::OpIncrNbIsos: // SHORTCUT - INCREASE NB ISOS
|
||||
case GEOMOp::OpDecrNbIsos: // SHORTCUT - DECREASE NB ISOS
|
||||
case GEOMOp::OpAutoColor: // POPUP MENU - AUTO COLOR
|
||||
case GEOMOp::OpNoAutoColor: // POPUP MENU - DISABLE AUTO COLOR
|
||||
case GEOMOp::OpShowChildren: // POPUP MENU - SHOW CHILDREN
|
||||
@ -572,7 +576,8 @@ void GeometryGUI::OnMousePress( SUIT_ViewWindow* w, QMouseEvent* e )
|
||||
// function : createGeomAction
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
void GeometryGUI::createGeomAction( const int id, const QString& label, const QString& icolabel, const int accel, const bool toggle )
|
||||
void GeometryGUI::createGeomAction( const int id, const QString& label, const QString& icolabel,
|
||||
const int accel, const bool toggle, const QString& shortcutAction )
|
||||
{
|
||||
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
|
||||
QPixmap icon = icolabel.isEmpty() ? resMgr->loadPixmap( "GEOM", tr( (QString( "ICO_" )+label).toLatin1().constData() ), false )
|
||||
@ -585,11 +590,12 @@ void GeometryGUI::createGeomAction( const int id, const QString& label, const QS
|
||||
accel,
|
||||
application()->desktop(),
|
||||
toggle,
|
||||
this, SLOT( OnGUIEvent() ) );
|
||||
this, SLOT( OnGUIEvent() ),
|
||||
shortcutAction );
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : createGeomAction
|
||||
// function : createOriginAndBaseVectors
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
void GeometryGUI::createOriginAndBaseVectors()
|
||||
@ -768,6 +774,19 @@ void GeometryGUI::initialize( CAM_Application* app )
|
||||
createGeomAction( GEOMOp::OpPointMarker, "POP_POINT_MARKER" );
|
||||
|
||||
createGeomAction( GEOMOp::OpPipeTShape, "PIPETSHAPE" );
|
||||
|
||||
// Create actions for increase/decrease transparency shortcuts
|
||||
createGeomAction( GEOMOp::OpIncrTransparency, "", "", 0, false,
|
||||
"Geometry:Increase transparency");
|
||||
createGeomAction( GEOMOp::OpDecrTransparency, "", "", 0, false,
|
||||
"Geometry:Decrease transparency");
|
||||
|
||||
// Create actions for increase/decrease number of isolines
|
||||
createGeomAction( GEOMOp::OpIncrNbIsos, "", "", 0, false,
|
||||
"Geometry:Increase number of isolines");
|
||||
createGeomAction( GEOMOp::OpDecrNbIsos, "", "", 0, false,
|
||||
"Geometry:Decrease number of isolines");
|
||||
|
||||
// createGeomAction( GEOMOp::OpPipeTShapeGroups, "PIPETSHAPEGROUPS" );
|
||||
//@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@ do not remove this line @@ do not remove this line @@//
|
||||
|
||||
|
@ -147,7 +147,8 @@ private:
|
||||
GEOMGUI* getLibrary( const QString& libraryName );
|
||||
void createGeomAction( const int id, const QString& po_id,
|
||||
const QString& icon_id = QString(""),
|
||||
const int key = 0, const bool toggle = false );
|
||||
const int key = 0, const bool toggle = false,
|
||||
const QString& shortcutAction = QString() );
|
||||
void createPopupItem( const int, const QString& clients, const QString& types,
|
||||
const bool isSingle = false, const int isVisible = -1,
|
||||
const bool isExpandAll = false, const bool isOCC = false,
|
||||
|
@ -40,10 +40,14 @@ namespace GEOMOp {
|
||||
OpDeflection = 1200, // POPUP MENU - DEFLECTION COEFFICIENT
|
||||
OpColor = 1201, // POPUP MENU - COLOR
|
||||
OpTransparency = 1202, // POPUP MENU - TRANSPARENCY
|
||||
OpIsos = 1203, // POPUP MENU - ISOS
|
||||
OpAutoColor = 1204, // POPUP MENU - AUTO COLOR
|
||||
OpNoAutoColor = 1205, // POPUP MENU - DISABLE AUTO COLOR
|
||||
OpPointMarker = 1206, // POPUP MENU - POINT MARKER
|
||||
OpIncrTransparency = 1203, // SHORTCUT - INCREASE TRANSPARENCY
|
||||
OpDecrTransparency = 1204, // SHORTCUT - DECREASE TRANSPARENCY
|
||||
OpIsos = 1205, // POPUP MENU - ISOS
|
||||
OpIncrNbIsos = 1206, // SHORTCUT - INCREASE NB ISOS
|
||||
OpDecrNbIsos = 1207, // SHORTCUT - DECREASE NB ISOS
|
||||
OpAutoColor = 1208, // POPUP MENU - AUTO COLOR
|
||||
OpNoAutoColor = 1209, // POPUP MENU - DISABLE AUTO COLOR
|
||||
OpPointMarker = 1210, // POPUP MENU - POINT MARKER
|
||||
OpShowChildren = 1250, // POPUP MENU - SHOW CHILDREN
|
||||
OpHideChildren = 1251, // POPUP MENU - HIDE CHILDREN
|
||||
OpRename = 1252, // POPUP MENU - RENAME
|
||||
|
@ -334,9 +334,21 @@ bool GEOMToolsGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent)
|
||||
case GEOMOp::OpTransparency: // POPUP - TRANSPARENCY
|
||||
OnTransparency();
|
||||
break;
|
||||
case GEOMOp::OpIncrTransparency: // SHORTCUT - INCREASE TRANSPARENCY
|
||||
OnChangeTransparency( true );
|
||||
break;
|
||||
case GEOMOp::OpDecrTransparency: // SHORTCUT - DECREASE TRANSPARENCY
|
||||
OnChangeTransparency( false );
|
||||
break;
|
||||
case GEOMOp::OpIsos: // POPUP - ISOS
|
||||
OnNbIsos();
|
||||
break;
|
||||
case GEOMOp::OpIncrNbIsos: // SHORTCUT - INCREASE NB ISOLINES
|
||||
OnNbIsos( INCR );
|
||||
break;
|
||||
case GEOMOp::OpDecrNbIsos: // SHORTCUT - DECREASE NB ISOLINES
|
||||
OnNbIsos( DECR );
|
||||
break;
|
||||
case GEOMOp::OpAutoColor: // POPUP - AUTO COLOR
|
||||
OnAutoColor();
|
||||
break;
|
||||
|
@ -52,6 +52,8 @@ public:
|
||||
bool OnGUIEvent( int, SUIT_Desktop* );
|
||||
virtual void deactivate();
|
||||
|
||||
enum ActionType { SHOWDLG, INCR, DECR };
|
||||
|
||||
private:
|
||||
// Import and export topology methods
|
||||
bool Import();
|
||||
@ -67,12 +69,15 @@ private:
|
||||
void OnDisableAutoColor();
|
||||
void OnColor();
|
||||
void OnTransparency();
|
||||
void OnNbIsos();
|
||||
void OnNbIsos( ActionType actionType = SHOWDLG );
|
||||
void OnDeflection();
|
||||
void OnSelectOnly(int mode);
|
||||
void OnShowHideChildren( bool );
|
||||
void OnPointMarker();
|
||||
|
||||
// Shortcut commands
|
||||
void OnChangeTransparency( bool );
|
||||
|
||||
// Recursive deletion of object with children
|
||||
void removeObjectWithChildren( _PTR(SObject),
|
||||
_PTR(Study),
|
||||
|
@ -399,7 +399,86 @@ void GEOMToolsGUI::OnTransparency()
|
||||
dlg.exec();
|
||||
}
|
||||
|
||||
void GEOMToolsGUI::OnNbIsos()
|
||||
void GEOMToolsGUI::OnChangeTransparency( bool increase )
|
||||
{
|
||||
SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
|
||||
if ( !app )
|
||||
return;
|
||||
LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
|
||||
if ( !aSelMgr )
|
||||
return;
|
||||
SALOME_ListIO selected;
|
||||
aSelMgr->selectedObjects( selected );
|
||||
if ( selected.IsEmpty() )
|
||||
return;
|
||||
|
||||
Handle(SALOME_InteractiveObject) FirstIOS = selected.First();
|
||||
if ( FirstIOS.IsNull() )
|
||||
return;
|
||||
|
||||
// Delta
|
||||
float delta = 0.01;
|
||||
if ( !increase )
|
||||
delta *= -1;
|
||||
|
||||
SUIT_ViewWindow* window = app->desktop()->activeWindow();
|
||||
bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
|
||||
bool isVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() );
|
||||
|
||||
if ( isVTK ) {
|
||||
SVTK_ViewWindow* vtkVW = dynamic_cast<SVTK_ViewWindow*>( window );
|
||||
if ( !vtkVW )
|
||||
return;
|
||||
SVTK_View* aView = vtkVW->getView();
|
||||
|
||||
float transp = aView->GetTransparency(FirstIOS);
|
||||
|
||||
// Compute new transparency value
|
||||
transp = transp + delta;
|
||||
if ( transp < 0 )
|
||||
transp = 0;
|
||||
else if ( transp > 1 )
|
||||
transp = 1;
|
||||
|
||||
for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
|
||||
aView->SetTransparency( It.Value(), transp );
|
||||
}
|
||||
aView->Repaint();
|
||||
} // if ( isVTK )
|
||||
|
||||
else if ( isOCC ) {
|
||||
GEOMBase* gb = new GEOMBase();
|
||||
Standard_Boolean found;
|
||||
Handle(GEOM_AISShape) aisShape;
|
||||
|
||||
aisShape = gb->ConvertIOinGEOMAISShape( FirstIOS, found );
|
||||
if( !found )
|
||||
return;
|
||||
float transp = aisShape->Transparency();
|
||||
|
||||
// Compute new transparency value
|
||||
transp = transp + delta;
|
||||
if ( transp < 0 )
|
||||
transp = 0;
|
||||
else if ( transp > 1 )
|
||||
transp = 1;
|
||||
|
||||
OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*>( window->getViewManager()->getViewModel() );
|
||||
if ( !vm )
|
||||
return;
|
||||
Handle(AIS_InteractiveContext) ic = vm->getAISContext();
|
||||
for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
|
||||
aisShape = gb->ConvertIOinGEOMAISShape( It.Value(), found );
|
||||
if ( found ) {
|
||||
ic->SetTransparency( aisShape, transp, false );
|
||||
ic->Redisplay( aisShape, Standard_False, Standard_True );
|
||||
}
|
||||
} // for...
|
||||
ic->UpdateCurrentViewer();
|
||||
} // if ( isOCC )
|
||||
}
|
||||
|
||||
void GEOMToolsGUI::OnNbIsos( ActionType actionType )
|
||||
{
|
||||
SUIT_ViewWindow* window = SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
|
||||
|
||||
@ -419,6 +498,10 @@ void GEOMToolsGUI::OnNbIsos()
|
||||
int UIso = CurDrawer->UIsoAspect()->Number();
|
||||
int VIso = CurDrawer->VIsoAspect()->Number();
|
||||
|
||||
int newNbUIso = -1;
|
||||
int newNbVIso = -1;
|
||||
|
||||
if ( actionType == SHOWDLG ) {
|
||||
GEOMToolsGUI_NbIsosDlg * NbIsosDlg =
|
||||
new GEOMToolsGUI_NbIsosDlg( SUIT_Session::session()->activeApplication()->desktop() );
|
||||
|
||||
@ -427,22 +510,35 @@ void GEOMToolsGUI::OnNbIsos()
|
||||
|
||||
if ( NbIsosDlg->exec() ) {
|
||||
SUIT_OverrideCursor();
|
||||
|
||||
newNbUIso = NbIsosDlg->getU();
|
||||
newNbVIso = NbIsosDlg->getV();
|
||||
}
|
||||
}
|
||||
else if ( actionType == INCR || actionType == DECR ) {
|
||||
int delta = 1;
|
||||
if (actionType == DECR)
|
||||
delta = -1;
|
||||
|
||||
newNbUIso = UIso + delta;
|
||||
newNbVIso = VIso + delta;
|
||||
|
||||
if ( newNbUIso < 0 || newNbVIso < 0 || newNbUIso > 99 || newNbVIso > 99 )
|
||||
return;
|
||||
}
|
||||
|
||||
for(; ic->MoreCurrent(); ic->NextCurrent()) {
|
||||
CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current());
|
||||
Handle(AIS_Drawer) CurDrawer = CurObject->Attributes();
|
||||
|
||||
int nbUIso = NbIsosDlg->getU();
|
||||
int nbVIso = NbIsosDlg->getV();
|
||||
|
||||
CurDrawer->SetUIsoAspect( new Prs3d_IsoAspect(Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 0.5 , nbUIso) );
|
||||
CurDrawer->SetVIsoAspect( new Prs3d_IsoAspect(Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 0.5 , nbVIso) );
|
||||
CurDrawer->SetUIsoAspect( new Prs3d_IsoAspect(Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 0.5 , newNbUIso) );
|
||||
CurDrawer->SetVIsoAspect( new Prs3d_IsoAspect(Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 0.5 , newNbVIso) );
|
||||
|
||||
ic->SetLocalAttributes(CurObject, CurDrawer);
|
||||
ic->Redisplay(CurObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(isVTK){ // if is VTKViewer
|
||||
//
|
||||
// Warning. It's works incorrect. must be recheked.
|
||||
@ -493,6 +589,10 @@ void GEOMToolsGUI::OnNbIsos()
|
||||
else
|
||||
return;
|
||||
|
||||
int newNbUIso = -1;
|
||||
int newNbVIso = -1;
|
||||
|
||||
if ( actionType == SHOWDLG ) {
|
||||
GEOMToolsGUI_NbIsosDlg* NbIsosDlg =
|
||||
new GEOMToolsGUI_NbIsosDlg( SUIT_Session::session()->activeApplication()->desktop() );
|
||||
|
||||
@ -502,17 +602,31 @@ void GEOMToolsGUI::OnNbIsos()
|
||||
if ( NbIsosDlg->exec() ) {
|
||||
SUIT_OverrideCursor();
|
||||
|
||||
newNbUIso = NbIsosDlg->getU();
|
||||
newNbVIso = NbIsosDlg->getV();
|
||||
}
|
||||
}
|
||||
else if ( actionType == INCR || actionType == DECR ) {
|
||||
int delta = 1;
|
||||
if (actionType == DECR)
|
||||
delta = -1;
|
||||
|
||||
newNbUIso = UIso + delta;
|
||||
newNbVIso = VIso + delta;
|
||||
|
||||
if ( newNbUIso < 0 || newNbVIso < 0 || newNbUIso > 99 || newNbVIso > 99 )
|
||||
return;
|
||||
}
|
||||
|
||||
while( anAct!=NULL ) {
|
||||
if(GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(anAct)){
|
||||
// There are no casting to needed actor.
|
||||
UIso = NbIsosDlg->getU();
|
||||
VIso = NbIsosDlg->getV();
|
||||
int aIsos[2]={UIso,VIso};
|
||||
int aIsos[2]={newNbUIso,newNbVIso};
|
||||
anActor->SetNbIsos(aIsos);
|
||||
}
|
||||
anAct = aCollection->GetNextActor();
|
||||
}
|
||||
}
|
||||
view->Repaint();
|
||||
} // end vtkviewer
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user