mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-02-05 04:44:18 +05:00
rnc: added a method to put textures on shapes
This commit is contained in:
parent
ec92e342ca
commit
859f480fc1
@ -403,6 +403,7 @@ void GeometryGUI::OnGUIEvent( int id )
|
|||||||
case GEOMOp::OpCheckGeom: // MENU TOOLS - CHECK GEOMETRY
|
case GEOMOp::OpCheckGeom: // MENU TOOLS - CHECK GEOMETRY
|
||||||
case GEOMOp::OpDeflection: // POPUP MENU - DEFLECTION COEFFICIENT
|
case GEOMOp::OpDeflection: // POPUP MENU - DEFLECTION COEFFICIENT
|
||||||
case GEOMOp::OpColor: // POPUP MENU - COLOR
|
case GEOMOp::OpColor: // POPUP MENU - COLOR
|
||||||
|
case GEOMOp::OpSetTexture: // POPUP MENU - SETTEXTURE
|
||||||
case GEOMOp::OpTransparency: // POPUP MENU - TRANSPARENCY
|
case GEOMOp::OpTransparency: // POPUP MENU - TRANSPARENCY
|
||||||
case GEOMOp::OpIncrTransparency: // SHORTCUT - INCREASE TRANSPARENCY
|
case GEOMOp::OpIncrTransparency: // SHORTCUT - INCREASE TRANSPARENCY
|
||||||
case GEOMOp::OpDecrTransparency: // SHORTCUT - DECREASE TRANSPARENCY
|
case GEOMOp::OpDecrTransparency: // SHORTCUT - DECREASE TRANSPARENCY
|
||||||
@ -803,6 +804,7 @@ void GeometryGUI::initialize( CAM_Application* app )
|
|||||||
createGeomAction( GEOMOp::OpVectors, "POP_VECTORS", "", 0, true );
|
createGeomAction( GEOMOp::OpVectors, "POP_VECTORS", "", 0, true );
|
||||||
createGeomAction( GEOMOp::OpDeflection, "POP_DEFLECTION" );
|
createGeomAction( GEOMOp::OpDeflection, "POP_DEFLECTION" );
|
||||||
createGeomAction( GEOMOp::OpColor, "POP_COLOR" );
|
createGeomAction( GEOMOp::OpColor, "POP_COLOR" );
|
||||||
|
createGeomAction( GEOMOp::OpSetTexture, "POP_SETTEXTURE" );
|
||||||
createGeomAction( GEOMOp::OpTransparency, "POP_TRANSPARENCY" );
|
createGeomAction( GEOMOp::OpTransparency, "POP_TRANSPARENCY" );
|
||||||
createGeomAction( GEOMOp::OpIsos, "POP_ISOS" );
|
createGeomAction( GEOMOp::OpIsos, "POP_ISOS" );
|
||||||
createGeomAction( GEOMOp::OpAutoColor, "POP_AUTO_COLOR" );
|
createGeomAction( GEOMOp::OpAutoColor, "POP_AUTO_COLOR" );
|
||||||
@ -1122,10 +1124,14 @@ void GeometryGUI::initialize( CAM_Application* app )
|
|||||||
// ---- create popup menus --------------------------
|
// ---- create popup menus --------------------------
|
||||||
|
|
||||||
QString clientOCCorVTK = "(client='OCCViewer' or client='VTKViewer')";
|
QString clientOCCorVTK = "(client='OCCViewer' or client='VTKViewer')";
|
||||||
|
QString clientOCC = "(client='OCCViewer')";
|
||||||
QString clientOCCorVTK_AndSomeVisible = clientOCCorVTK + " and selcount>0 and isVisible";
|
QString clientOCCorVTK_AndSomeVisible = clientOCCorVTK + " and selcount>0 and isVisible";
|
||||||
|
QString clientOCC_AndSomeVisible = clientOCC + " and selcount>0 and isVisible";
|
||||||
|
|
||||||
|
QString clientOCCorOB = "(client='ObjectBrowser' or client='OCCViewer')";
|
||||||
QString clientOCCorVTKorOB = "(client='ObjectBrowser' or client='OCCViewer' or client='VTKViewer')";
|
QString clientOCCorVTKorOB = "(client='ObjectBrowser' or client='OCCViewer' or client='VTKViewer')";
|
||||||
QString clientOCCorVTKorOB_AndSomeVisible = clientOCCorVTKorOB + " and selcount>0 and isVisible";
|
QString clientOCCorVTKorOB_AndSomeVisible = clientOCCorVTKorOB + " and selcount>0 and isVisible";
|
||||||
|
QString clientOCCorOB_AndSomeVisible = clientOCCorOB + " and selcount>0 and isVisible";
|
||||||
|
|
||||||
QString autoColorPrefix =
|
QString autoColorPrefix =
|
||||||
"(client='ObjectBrowser' or client='OCCViewer') and type='Shape' and selcount=1 and isOCC=true";
|
"(client='ObjectBrowser' or client='OCCViewer') and type='Shape' and selcount=1 and isOCC=true";
|
||||||
@ -1152,8 +1158,8 @@ void GeometryGUI::initialize( CAM_Application* app )
|
|||||||
mgr->setRule( action( GEOMOp::OpShading ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
|
mgr->setRule( action( GEOMOp::OpShading ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
|
||||||
mgr->setRule( action( GEOMOp::OpShading ), clientOCCorVTK + " and displaymode='Shading'", QtxPopupMgr::ToggleRule );
|
mgr->setRule( action( GEOMOp::OpShading ), clientOCCorVTK + " and displaymode='Shading'", QtxPopupMgr::ToggleRule );
|
||||||
mgr->insert( action( GEOMOp::OpTexture ), dispmodeId, -1 ); // wireframe
|
mgr->insert( action( GEOMOp::OpTexture ), dispmodeId, -1 ); // wireframe
|
||||||
mgr->setRule( action( GEOMOp::OpTexture ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
|
mgr->setRule( action( GEOMOp::OpTexture ), clientOCC_AndSomeVisible, QtxPopupMgr::VisibleRule );
|
||||||
mgr->setRule( action( GEOMOp::OpTexture), clientOCCorVTK + " and displaymode='Texture'", QtxPopupMgr::ToggleRule );
|
mgr->setRule( action( GEOMOp::OpTexture), clientOCC + " and displaymode='Texture'", QtxPopupMgr::ToggleRule );
|
||||||
mgr->insert( separator(), dispmodeId, -1 );
|
mgr->insert( separator(), dispmodeId, -1 );
|
||||||
mgr->insert( action( GEOMOp::OpVectors ), dispmodeId, -1 ); // vectors
|
mgr->insert( action( GEOMOp::OpVectors ), dispmodeId, -1 ); // vectors
|
||||||
mgr->setRule( action( GEOMOp::OpVectors ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
|
mgr->setRule( action( GEOMOp::OpVectors ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule );
|
||||||
@ -1170,6 +1176,8 @@ void GeometryGUI::initialize( CAM_Application* app )
|
|||||||
mgr->insert( action( GEOMOp::OpPointMarker ), -1, -1 ); // point marker
|
mgr->insert( action( GEOMOp::OpPointMarker ), -1, -1 ); // point marker
|
||||||
//mgr->setRule( action( GEOMOp::OpPointMarker ), QString( "selcount>0 and $typeid in {%1}" ).arg(GEOM_POINT ), QtxPopupMgr::VisibleRule );
|
//mgr->setRule( action( GEOMOp::OpPointMarker ), QString( "selcount>0 and $typeid in {%1}" ).arg(GEOM_POINT ), QtxPopupMgr::VisibleRule );
|
||||||
mgr->setRule( action( GEOMOp::OpPointMarker ), QString( "selcount>0 and ( $typeid in {%1} or compoundOfVertices=true ) " ).arg(GEOM::VERTEX).arg(GEOM::COMPOUND), QtxPopupMgr::VisibleRule );
|
mgr->setRule( action( GEOMOp::OpPointMarker ), QString( "selcount>0 and ( $typeid in {%1} or compoundOfVertices=true ) " ).arg(GEOM::VERTEX).arg(GEOM::COMPOUND), QtxPopupMgr::VisibleRule );
|
||||||
|
mgr->insert( action( GEOMOp::OpSetTexture ), -1, -1 ); // texture
|
||||||
|
mgr->setRule( action( GEOMOp::OpSetTexture ), clientOCCorOB_AndSomeVisible + " and ($component={'GEOM'})", QtxPopupMgr::VisibleRule );
|
||||||
mgr->insert( separator(), -1, -1 ); // -----------
|
mgr->insert( separator(), -1, -1 ); // -----------
|
||||||
mgr->insert( action( GEOMOp::OpAutoColor ), -1, -1 ); // auto color
|
mgr->insert( action( GEOMOp::OpAutoColor ), -1, -1 ); // auto color
|
||||||
mgr->setRule( action( GEOMOp::OpAutoColor ), autoColorPrefix + " and isAutoColor=false", QtxPopupMgr::VisibleRule );
|
mgr->setRule( action( GEOMOp::OpAutoColor ), autoColorPrefix + " and isAutoColor=false", QtxPopupMgr::VisibleRule );
|
||||||
|
@ -48,6 +48,7 @@ namespace GEOMOp {
|
|||||||
OpAutoColor = 1208, // POPUP MENU - AUTO COLOR
|
OpAutoColor = 1208, // POPUP MENU - AUTO COLOR
|
||||||
OpNoAutoColor = 1209, // POPUP MENU - DISABLE AUTO COLOR
|
OpNoAutoColor = 1209, // POPUP MENU - DISABLE AUTO COLOR
|
||||||
OpPointMarker = 1210, // POPUP MENU - POINT MARKER
|
OpPointMarker = 1210, // POPUP MENU - POINT MARKER
|
||||||
|
OpSetTexture = 1211, // POPUP MENU - SETTEXTURE
|
||||||
OpShowChildren = 1250, // POPUP MENU - SHOW CHILDREN
|
OpShowChildren = 1250, // POPUP MENU - SHOW CHILDREN
|
||||||
OpHideChildren = 1251, // POPUP MENU - HIDE CHILDREN
|
OpHideChildren = 1251, // POPUP MENU - HIDE CHILDREN
|
||||||
OpUnpublishObject = 1253, // POPUP MENU - UNPUBLISH
|
OpUnpublishObject = 1253, // POPUP MENU - UNPUBLISH
|
||||||
|
@ -328,6 +328,9 @@ bool GEOMToolsGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent)
|
|||||||
case GEOMOp::OpColor: // POPUP - COLOR
|
case GEOMOp::OpColor: // POPUP - COLOR
|
||||||
OnColor();
|
OnColor();
|
||||||
break;
|
break;
|
||||||
|
case GEOMOp::OpSetTexture: // POPUP - TEXTURE
|
||||||
|
OnTexture();
|
||||||
|
break;
|
||||||
case GEOMOp::OpTransparency: // POPUP - TRANSPARENCY
|
case GEOMOp::OpTransparency: // POPUP - TRANSPARENCY
|
||||||
OnTransparency();
|
OnTransparency();
|
||||||
break;
|
break;
|
||||||
|
@ -66,6 +66,7 @@ private:
|
|||||||
void OnAutoColor();
|
void OnAutoColor();
|
||||||
void OnDisableAutoColor();
|
void OnDisableAutoColor();
|
||||||
void OnColor();
|
void OnColor();
|
||||||
|
void OnTexture();
|
||||||
void OnTransparency();
|
void OnTransparency();
|
||||||
void OnNbIsos( ActionType actionType = SHOWDLG );
|
void OnNbIsos( ActionType actionType = SHOWDLG );
|
||||||
void OnDeflection();
|
void OnDeflection();
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
#include "GEOMToolsGUI_PublishDlg.h"
|
#include "GEOMToolsGUI_PublishDlg.h"
|
||||||
|
|
||||||
#include <GeometryGUI.h>
|
#include <GeometryGUI.h>
|
||||||
|
#include <GeometryGUI_Operations.h>
|
||||||
#include <GEOM_Displayer.h>
|
#include <GEOM_Displayer.h>
|
||||||
|
|
||||||
#include <GEOMBase.h>
|
#include <GEOMBase.h>
|
||||||
@ -86,6 +87,7 @@
|
|||||||
// QT Includes
|
// QT Includes
|
||||||
#include <QColorDialog>
|
#include <QColorDialog>
|
||||||
#include <QInputDialog>
|
#include <QInputDialog>
|
||||||
|
#include <QFileDialog>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
|
|
||||||
#include <QGridLayout>
|
#include <QGridLayout>
|
||||||
@ -370,6 +372,49 @@ void GEOMToolsGUI::OnColor()
|
|||||||
app->updateActions(); //SRN: To update a Save button in the toolbar
|
app->updateActions(); //SRN: To update a Save button in the toolbar
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GEOMToolsGUI::OnTexture()
|
||||||
|
{
|
||||||
|
SALOME_ListIO selected;
|
||||||
|
SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
|
||||||
|
SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
|
||||||
|
if ( app && appStudy ) {
|
||||||
|
LightApp_SelectionMgr* aSelMgr = app->selectionMgr();
|
||||||
|
if ( aSelMgr ) {
|
||||||
|
aSelMgr->selectedObjects( selected );
|
||||||
|
if ( !selected.IsEmpty() ) {
|
||||||
|
SUIT_ViewWindow* window = app->desktop()->activeWindow();
|
||||||
|
bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() );
|
||||||
|
int mgrId = window->getViewManager()->getGlobalId();
|
||||||
|
if ( isOCC ) {
|
||||||
|
QString aTexture = QFileDialog::getOpenFileName(window,tr( "SELECT_IMAGE"),QString("/home"), tr("OCC_IMAGE_FILES"));
|
||||||
|
if( !aTexture.isEmpty() )
|
||||||
|
{
|
||||||
|
SUIT_OverrideCursor();
|
||||||
|
OCCViewer_Viewer* vm = dynamic_cast<OCCViewer_Viewer*> ( window->getViewManager()->getViewModel() );
|
||||||
|
Handle (AIS_InteractiveContext) ic = vm->getAISContext();
|
||||||
|
Handle(AIS_InteractiveObject) io ;
|
||||||
|
for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) {
|
||||||
|
io = GEOMBase::GetAIS( It.Value(), true );
|
||||||
|
if ( !io.IsNull() ) {
|
||||||
|
if ( io->IsKind( STANDARD_TYPE(GEOM_AISShape) ) )
|
||||||
|
Handle(GEOM_AISShape)::DownCast( io )->SetTextureFileName(TCollection_AsciiString(aTexture.toStdString().c_str()));
|
||||||
|
|
||||||
|
io->Redisplay( Standard_True );
|
||||||
|
}
|
||||||
|
} // for
|
||||||
|
ic->UpdateCurrentViewer();
|
||||||
|
GeometryGUI::Modified();
|
||||||
|
GeometryGUI* myGeomGUI = getGeometryGUI();
|
||||||
|
myGeomGUI->OnGUIEvent(GEOMOp::OpTexture);
|
||||||
|
} // if ( !selFile.isEmpty() )
|
||||||
|
} // if ( isOCC )
|
||||||
|
} // if ( selection not empty )
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
app->updateActions(); //SRN: To update a Save button in the toolbar
|
||||||
|
}
|
||||||
|
|
||||||
void GEOMToolsGUI::OnTransparency()
|
void GEOMToolsGUI::OnTransparency()
|
||||||
{
|
{
|
||||||
GEOMToolsGUI_TransparencyDlg dlg( SUIT_Session::session()->activeApplication()->desktop() );
|
GEOMToolsGUI_TransparencyDlg dlg( SUIT_Session::session()->activeApplication()->desktop() );
|
||||||
|
Loading…
Reference in New Issue
Block a user