#include <QTreeView>
#include <QMimeData>
#include <QShortcut>
+#include <QRegExp>
#include <utilities.h>
if ( activeModule() ) activeModule()->updateModuleVisibilityState();
+ updateActions();
return true;
}
tr( "MEN_DESK_PREFERENCES" ), tr( "PRP_DESK_PREFERENCES" ),
Qt::CTRL+Qt::Key_P, desk, false, this, SLOT( onPreferences() ) );
- // Help menu:
-
- // - Help for modules
+ // Help menu
int helpMenu = createMenu( tr( "MEN_DESK_HELP" ), -1, -1, 1000 );
- createMenu( separator(), helpMenu, -1, 10 );
+
+ int id = LightApp_Application::UserID + FIRST_HELP_ID;
+
+ // a) Link to web site
+ QString url = resMgr->stringValue("GUI", "site_url");
+ if ( !url.isEmpty() ) {
+ QString title = tr ( "SALOME_SITE" );
+ QAction* as = createAction( id, title,
+ resMgr->loadPixmap( "LightApp", tr( "ICON_WWW" ), false ),
+ title, title,
+ 0, desk, false, this, SLOT( onHelpOnline() ) );
+ as->setData( url );
+ createMenu( as, helpMenu, -1, 0 );
+ id++;
+ }
+
+ // b) Link to Forum
+ url = resMgr->stringValue("GUI", "forum_url");
+ if ( !url.isEmpty() ) {
+ QString title = tr ( "SALOME_FORUM" );
+ QAction* af = createAction( helpMenu, title,
+ resMgr->loadPixmap( "LightApp", tr( "ICON_WWW" ), false ),
+ title, title,
+ 0, desk, false, this, SLOT( onHelpOnline() ) );
+ af->setData( url );
+ createMenu( af, helpMenu, -1, 0 );
+ id++;
+ }
+
+ // c) Link to YouTube channel
+ url = resMgr->stringValue("GUI", "channel_url");
+ if ( !url.isEmpty() ) {
+ createMenu( separator(), helpMenu, -1, 0 );
+ QString title = tr ( "SALOME_VIDEO_TUTORIALS" );
+ QAction* av = createAction( helpMenu, title,
+ resMgr->loadPixmap( "LightApp", tr( "ICON_LIFE_RIGN" ), false ),
+ title, title,
+ 0, desk, false, this, SLOT( onHelpOnline() ) );
+ av->setData( url );
+ createMenu( av, helpMenu, -1, 0 );
+ id++;
+ }
+
+ // d) Help for modules
+
+ // - First create top-level menus to preserve correct order
+ QString userGuide = "User's Guide";
+ QString devGuide = "Developer's Guide";
+ createMenu( userGuide, helpMenu, -1, 5 );
+ createMenu( devGuide, helpMenu, -1, 5 );
+
QStringList aModuleList;
modules( aModuleList, false );
aModuleList.prepend( "GUI" );
aModuleList.prepend( "KERNEL" );
- int id = LightApp_Application::UserID + FIRST_HELP_ID;
-
QString aModule;
foreach( aModule, aModuleList ) {
if ( aModule.isEmpty() ) // module title (user name)
QString helpSubMenu; // help submenu name (empty if not needed)
QString modName = moduleName( aModule ); // module name
if ( modName.isEmpty() ) modName = aModule; // for KERNEL and GUI
- QString rootDir = QString( "%1_ROOT_DIR" ).arg( modName ); // module root dir variable
- QString modDir = getenv( rootDir.toUtf8().constData() ); // module root dir
+ QString rootDir = QString( "%1_ROOT_DIR" ).arg( modName ); // module root dir env variable
- QString modDir = getenv( rootDir.toLatin1().constData() ); // module root dir path
++ QString modDir = getenv( rootDir.toUtf8().constData() ); // module root dir path
QString docSection;
if (resMgr->hasValue( modName, "documentation" ) )
docSection = resMgr->stringValue(modName, "documentation");
helpFileName.replace( "//", "" );
// obtain submenus hierarchy if given
QStringList smenus = helpFileName.split( "/" );
- helpFileName = smenus.last();
- smenus.removeLast();
+ helpFileName = smenus.takeLast();
+ // workaround for User's Guide and Developer's Guide to avoid having single item in module's submenu.
+ if ( helpFileName == userGuide || helpFileName == devGuide ) {
+ QString menuPath = smenus.join( "/" );
+ QStringList allKeys = helpData.keys();
+ QStringList total = allKeys.filter( QRegExp( QString( "^%1" ).arg( menuPath ) ) );
+ if ( total.count() == 1 && smenus.count() > 0 )
+ helpFileName = smenus.takeLast();
+ }
QAction* a = createAction( id, helpFileName,
resMgr->loadPixmap( "STD", tr( "ICON_HELP" ), false ),
helpFileName, helpFileName,
}
// create sub-menus hierarchy
int menuId = helpMenu;
- foreach ( QString subMenu, smenus ) {
- menuId = createMenu( subMenu, menuId, -1, 0 );
- }
- createMenu( a, menuId, -1, 0 );
+ foreach ( QString subMenu, smenus )
+ menuId = createMenu( subMenu, menuId, -1, 5 );
+ createMenu( a, menuId, -1, ( menuId != helpMenu && (helpFileName == userGuide || helpFileName == devGuide) ) ? 0 : 5 );
id++;
}
}
// - Additional help items
- createMenu( separator(), helpMenu, -1, 5 );
+ createMenu( separator(), helpMenu, -1, 10 );
QStringList addHelpItems = resMgr->parameters( "add_help" );
foreach ( QString addHelpItem, addHelpItems ) {
addHelpItem, addHelpItem,
0, desk, false, this, SLOT( onHelpContentsModule() ) );
a->setData( valueStr );
- createMenu( a, helpMenu, -1, 5 );
+ createMenu( a, helpMenu, -1, 10 );
id++;
}
}
const QString& theApp,
const QString& theParams,
const QString& theHelpFile,
- const QString& theContext = QString() )
+ const QString& theContext = QString(),
+ //For the external browser always specify 'file://' protocol,
+ //because some WEB browsers (for example Mozilla Firefox) can't open local file without protocol.
+ const QString& theProtocol = QString("file://"),
+ const bool isFile = true)
: myApp( theApp ),
myParams( theParams ),
myContext( theContext ),
myStatus(0),
myLApp( app )
{
- //For the external browser always specify 'file://' protocol,
- //because some WEB browsers (for example Mozilla Firefox) can't open local file without protocol.
- myHelpFile = QString("file://%1").arg( QFileInfo( theHelpFile ).canonicalFilePath() );
+ QString path_begin = theProtocol+"%1";
+ QString path_end = theHelpFile;
+ if( isFile ) {
+ path_end = QFileInfo( theHelpFile ).canonicalFilePath();
+ }
+ myHelpFile = path_begin.arg( path_end );
}
virtual void run()
}
}
+/*!
+ SLOT: Displays help contents for choosen module
+*/
+void LightApp_Application::onHelpOnline()
+{
+ const QAction* a = (QAction*) sender();
+ QString url = a->data().toString();
+ if ( url.isEmpty() ) return;
+
+ SUIT_ResourceMgr* resMgr = resourceMgr();
+ QString platform;
+#ifdef WIN32
+ platform = "winapplication";
+#else
+ platform = "application";
+#endif
+ QString anApp = resMgr->stringValue("ExternalBrowser", platform);
+#ifdef WIN32
+ QString quote("\"");
+ anApp.prepend( quote );
+ anApp.append( quote );
+#endif
+ QString aParams = resMgr->stringValue("ExternalBrowser", "parameters");
+#if DISABLE_QTXWEBBROWSER
+ bool useExtBrowser = true;
+#else
+ bool useExtBrowser = resMgr->booleanValue("ExternalBrowser", "use_external_browser", false );
+#endif
+
+ if( useExtBrowser ) {
+ if ( !anApp.isEmpty() ) {
+ RunBrowser* rs = new RunBrowser( this, anApp, aParams, url, "", "http://", false );
+ rs->start();
+ }
+ else {
+ if ( SUIT_MessageBox::question( desktop(), tr( "WRN_WARNING" ), tr( "DEFINE_EXTERNAL_BROWSER" ),
+ SUIT_MessageBox::Yes | SUIT_MessageBox::No,
+ SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes )
+
+ showPreferences( tr( "PREF_APP" ) );
+ }
+ }
+ else {
+ QStringList parameters;
+ parameters << QString( "--language=%1" ).arg( resMgr->stringValue( "language", "language" ) );
+ parameters << QString( "--add=%1" ).arg( QApplication::instance()->applicationPid() );
+ parameters << "http://" + url;
+ QProcess::startDetached( "HelpBrowser", parameters );
+ }
+}
+
/*!
Sets enable or disable some actions on selection changed.
*/
pref->addPreference( tr( "PREF_OPAQUE_RESIZE" ), lookGroup, LightApp_Preferences::Bool, "desktop", "opaque_resize" );
// .... -> drop-down buttons
pref->addPreference( tr( "PREF_DROP_DOWN_BUTTONS" ), lookGroup, LightApp_Preferences::Bool, "viewers", "drop_down_buttons" );
+ // .... -> Notification timeout
+ int delay = pref->addPreference( tr( "PREF_NOTIFY_TIMEOUT" ), lookGroup, LightApp_Preferences::IntSpin, "notification", "timeout" );
+ pref->setItemProperty( "special", tr("PREF_NOTIFY_TIMEOUT_NONE"), delay );
+ pref->setItemProperty( "min", 0, delay );
+ pref->setItemProperty( "max", 100, delay );
+ pref->setItemProperty( "suffix", " sec", delay );
// ... "Look and feel" group <<end>>
// ... "Study properties" group <<start>>
SUIT_DataOwnerPtrList aList;
#ifndef DISABLE_SALOMEOBJECT
Handle(SALOME_InteractiveObject) aSObj = new SALOME_InteractiveObject
- ( anObject->entry().toLatin1().constData(),
+ ( anObject->entry().toUtf8().constData(),
anObject->componentDataType().toLatin1().constData(),
- anObject->name().toLatin1().constData() );
+ anObject->name().toUtf8().constData() );
LightApp_DataOwner* owner = new LightApp_DataOwner( aSObj );
#else
LightApp_DataOwner* owner = new LightApp_DataOwner( anEntry );
{
if( myViewer ) {
if( SVTK_Viewer* aSViewer = dynamic_cast<SVTK_Viewer*>(myViewer) ) {
- if( !aSViewer->isSelectionEnabled() )
- return;
+ if( !aSViewer->isSelectionEnabled() )
+ return;
}
if(SUIT_ViewManager* aViewManager = myViewer->getViewManager()){
if(SVTK_ViewManager* aViewMgr = dynamic_cast<SVTK_ViewManager*>(aViewManager)){
/*!
Sets selection to selector from data owner list \a theList.
*/
-void
+void
LightApp_VTKSelector
::setSelection( const SUIT_DataOwnerPtrList& theList )
{
SVTK_Viewer* aViewer = dynamic_cast<SVTK_Viewer*>(myViewer);
- if(myViewer && aViewer && aViewer->isSelectionEnabled()){
+ if ( myViewer && aViewer && ( theList.isEmpty() || aViewer->isSelectionEnabled() )) {
if(SUIT_ViewManager* aViewMgr = myViewer->getViewManager()){
if(SVTK_ViewWindow* aView = dynamic_cast<SVTK_ViewWindow*>(aViewMgr->getActiveView())){
if(SVTK_Selector* aSelector = aView->GetSelector()){
SALOME_ListIO anAppendList;
const SALOME_ListIO& aStoredList = aSelector->StoredIObjects();
SUIT_DataOwnerPtrList::const_iterator anIter = theList.begin();
- for(; anIter != theList.end(); ++anIter){
+ for(; anIter != theList.end(); ++anIter) {
const SUIT_DataOwner* aDataOwner = (*anIter).get();
- if(const LightApp_SVTKDataOwner* anOwner = dynamic_cast<const LightApp_SVTKDataOwner*>(aDataOwner)){
+ if(const LightApp_SVTKDataOwner* anOwner = dynamic_cast<const LightApp_SVTKDataOwner*>(aDataOwner))
+ {
MESSAGE("aSelector->SetSelectionMode("<<anOwner->GetMode()<<");");
aSelector->SetSelectionMode(anOwner->GetMode());
Handle(SALOME_InteractiveObject) anIO = anOwner->IO();
anAppendList.Append(anIO);
aSelector->AddOrRemoveIndex(anIO,anOwner->GetIds(),false);
- }else if(const LightApp_DataOwner* anOwner = dynamic_cast<const LightApp_DataOwner*>(aDataOwner)){
- Handle(SALOME_InteractiveObject) anIO =
+ }
+ else if(const LightApp_DataOwner* anOwner = dynamic_cast<const LightApp_DataOwner*>(aDataOwner))
+ {
+ Handle(SALOME_InteractiveObject) anIO =
- new SALOME_InteractiveObject(anOwner->entry().toLatin1(),"");
+ new SALOME_InteractiveObject(anOwner->entry().toUtf8(),"");
aSelector->AddIObject(anIO);
anAppendList.Append(anIO);
}
toRemove.remove( anIt.Value()->getEntry() );
QMap< QString, Handle( SALOME_InteractiveObject )>::const_iterator RIt = toRemove.begin(),
- REnd = toRemove.end();
+ REnd = toRemove.end();
for( ; RIt!=REnd; RIt++ )
aSelector->RemoveIObject( RIt.value() );
-
+
aView->onSelectionChanged();
}
}
// set texture image: file name and fill mode
switch ( textureMode ) {
case Qtx::CenterTexture:
- activeView()->SetBackgroundImage( fi.absoluteFilePath().toLatin1().constData(), Aspect_FM_CENTERED );
+ activeView()->SetBackgroundImage( fi.absoluteFilePath().toUtf8().constData(), Aspect_FM_CENTERED );
break;
case Qtx::TileTexture:
- activeView()->SetBackgroundImage( fi.absoluteFilePath().toLatin1().constData(), Aspect_FM_TILED );
+ activeView()->SetBackgroundImage( fi.absoluteFilePath().toUtf8().constData(), Aspect_FM_TILED );
break;
case Qtx::StretchTexture:
- activeView()->SetBackgroundImage( fi.absoluteFilePath().toLatin1().constData(), Aspect_FM_STRETCH );
+ activeView()->SetBackgroundImage( fi.absoluteFilePath().toUtf8().constData(), Aspect_FM_STRETCH );
break;
default:
break;
QApplication::syncX();
#endif
QTimer::singleShot( 0, this, SLOT( repaintViewAfterMove() ) );
+ emit vpResizeEvent( e );
}
/*!
#include <Graphic3d_ExportFormat.hxx>
#include <Graphic3d_StereoMode.hxx>
#include <Graphic3d_RenderingParams.hxx>
+#include <Graphic3d_BndBox3d.hxx>
#include <V3d_Plane.hxx>
#include <V3d_Light.hxx>
"................................",
"................................"};
-
-/*!
+
+ /*!
\brief Constructor
\param theDesktop main window of application
\param theModel OCC 3D viewer
mySelectionEnabled = true;
myCursorIsHand = false;
+ myPanningByBtn = false;
+ myAutomaticZoom = true;
clearViewAspects();
}
}
+void OCCViewer_ViewWindow::onPanning()
+{
+ OCCViewer_ViewManager* aMgr = dynamic_cast<OCCViewer_ViewManager*>( getViewManager() );
+ bool isChained = aMgr->isChainedOperations();
+ bool isReset = ( myPanningByBtn && isChained );
+ if( isReset )
+ {
+ resetState();
+ }
+ else
+ {
+ myPanningByBtn = true;
+ activatePanning();
+ }
+}
+
/*!
\brief Start panning operation.
if ( aStructure->IsEmpty() || !aStructure->IsVisible() || aStructure->CStructure()->IsForHighlight )
continue;
- Bnd_Box aBox = aStructure->MinMaxValues();
- aXmin = aBox.IsVoid() ? RealFirst() : aBox.CornerMin().X();
- aYmin = aBox.IsVoid() ? RealFirst() : aBox.CornerMin().Y();
- aZmin = aBox.IsVoid() ? RealFirst() : aBox.CornerMin().Z();
- aXmax = aBox.IsVoid() ? RealLast() : aBox.CornerMax().X();
- aYmax = aBox.IsVoid() ? RealLast() : aBox.CornerMax().Y();
- aZmax = aBox.IsVoid() ? RealLast() : aBox.CornerMax().Z();
+ Bnd_Box aBox1 = aStructure->MinMaxValues();
+ const Graphic3d_BndBox3d& aBox = aStructure->CStructure()->BoundingBox();
+ if (!aBox.IsValid())
+ continue;
+ aXmin = /*aBox.IsVoid() ? RealFirst() :*/ aBox.CornerMin().x();
+ aYmin = /*aBox.IsVoid() ? RealFirst() : */aBox.CornerMin().y();
+ aZmin = /*aBox.IsVoid() ? RealFirst() : */aBox.CornerMin().z();
+ aXmax = /*aBox.IsVoid() ? RealLast() : */aBox.CornerMax().x();
+ aYmax = /*aBox.IsVoid() ? RealLast() : */aBox.CornerMax().y();
+ aZmax = /*aBox.IsVoid() ? RealLast() : */aBox.CornerMax().z();
// Infinite structures are skipped
Standard_Real aLIM = ShortRealLast() - 1.0;
theX /= aPointsNb;
theY /= aPointsNb;
theZ /= aPointsNb;
+ return true;
}
- return true;
+ else
+ return false;
}
/*!
case PANVIEW:
case ZOOMVIEW:
- resetState();
- break;
+ {
+ OCCViewer_ViewManager* aMgr = dynamic_cast<OCCViewer_ViewManager*>( getViewManager() );
+ bool isChained = aMgr->isChainedOperations();
+ bool isReset = !( myOperation==PANVIEW && myPanningByBtn && isChained ) || theEvent->button() == Qt::RightButton;
+ if( isReset )
+ resetState();
+ break;
+ }
case PANGLOBAL:
if ( theEvent->button() == Qt::LeftButton ) {
setTransformInProcess( false );
setTransformRequested( NOTHING );
+
+ myPanningByBtn = false;
}
aAction = new QtxAction(tr("MNU_PAN_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_PAN" ) ),
tr( "MNU_PAN_VIEW" ), 0, this);
aAction->setStatusTip(tr("DSC_PAN_VIEW"));
- connect(aAction, SIGNAL(triggered()), this, SLOT(activatePanning()));
+ connect(aAction, SIGNAL(triggered()), this, SLOT(onPanning()));
toolMgr()->registerAction( aAction, PanId );
// Global Panning
{
emit vpTransformationStarted ( FRONTVIEW );
Handle(V3d_View) aView3d = myViewPort->getView();
- if ( !aView3d.IsNull() ) aView3d->SetProj (V3d_Xpos);
- onViewFitAll();
+ if (myAutomaticZoom)
+ {
+ if ( !aView3d.IsNull() )
+ aView3d->SetProj (V3d_Xpos);
+ onViewFitAll();
+ }
+ else
+ projAndPanToGravity(V3d_Xpos);
emit vpTransformationFinished ( FRONTVIEW );
}
{
emit vpTransformationStarted ( BACKVIEW );
Handle(V3d_View) aView3d = myViewPort->getView();
- if ( !aView3d.IsNull() ) aView3d->SetProj (V3d_Xneg);
- onViewFitAll();
+ if (myAutomaticZoom)
+ {
+ if ( !aView3d.IsNull() )
+ aView3d->SetProj (V3d_Xneg);
+ onViewFitAll();
+ }
+ else
+ projAndPanToGravity(V3d_Xneg);
emit vpTransformationFinished ( BACKVIEW );
}
{
emit vpTransformationStarted ( TOPVIEW );
Handle(V3d_View) aView3d = myViewPort->getView();
- if ( !aView3d.IsNull() ) aView3d->SetProj (V3d_Zpos);
- onViewFitAll();
+ if (myAutomaticZoom)
+ {
+ if ( !aView3d.IsNull() )
+ aView3d->SetProj (V3d_Zpos);
+ onViewFitAll();
+ }
+ else
+ projAndPanToGravity(V3d_Zpos);
emit vpTransformationFinished ( TOPVIEW );
}
{
emit vpTransformationStarted ( BOTTOMVIEW );
Handle(V3d_View) aView3d = myViewPort->getView();
- if ( !aView3d.IsNull() ) aView3d->SetProj (V3d_Zneg);
- onViewFitAll();
+ if (myAutomaticZoom)
+ {
+ if ( !aView3d.IsNull() )
+ aView3d->SetProj (V3d_Zneg);
+ onViewFitAll();
+ }
+ else
+ projAndPanToGravity(V3d_Zneg);
emit vpTransformationFinished ( BOTTOMVIEW );
}
{
emit vpTransformationStarted ( LEFTVIEW );
Handle(V3d_View) aView3d = myViewPort->getView();
- if ( !aView3d.IsNull() ) aView3d->SetProj (V3d_Yneg);
- onViewFitAll();
+ if (myAutomaticZoom)
+ {
+ if ( !aView3d.IsNull() )
+ aView3d->SetProj (V3d_Yneg);
+ onViewFitAll();
+ }
+ else
+ projAndPanToGravity(V3d_Yneg);
emit vpTransformationFinished ( LEFTVIEW );
}
{
emit vpTransformationStarted ( RIGHTVIEW );
Handle(V3d_View) aView3d = myViewPort->getView();
- if ( !aView3d.IsNull() ) aView3d->SetProj (V3d_Ypos);
- onViewFitAll();
+ if (myAutomaticZoom)
+ {
+ if ( !aView3d.IsNull() )
+ aView3d->SetProj (V3d_Ypos);
+ onViewFitAll();
+ }
+ else
+ projAndPanToGravity(V3d_Ypos);
emit vpTransformationFinished ( RIGHTVIEW );
}
OpenGl_Caps* aCaps = &aDriver->ChangeOptions();
int prev = aCaps->ffpEnable;
aCaps->ffpEnable = 1;
- res = a3dView->Export(strdup(qPrintable(fileName)), Graphic3d_EF_PostScript);
+ res = a3dView->Export(strdup(qUtf8Printable(fileName)), Graphic3d_EF_PostScript);
aCaps->ffpEnable = prev;
}
else if (format == "EPS") {
OpenGl_Caps* aCaps = &aDriver->ChangeOptions();
int prev = aCaps->ffpEnable;
aCaps->ffpEnable = 1;
- res = a3dView->Export(strdup(qPrintable(fileName)), Graphic3d_EF_EnhPostScript);
+ res = a3dView->Export(strdup(qUtf8Printable(fileName)), Graphic3d_EF_EnhPostScript);
aCaps->ffpEnable = prev;
}
else {
return enable;
}
-
bool OCCViewer_ViewWindow::isOpenGlStereoSupport() const
{
GLboolean support[1];
aDlg->show();
}
}
+
+bool OCCViewer_ViewWindow::isActionVisible( ActionId theId ) const
+{
+ QAction* a = toolMgr()->action( theId );
+ return a && a->isVisible();
+}
+
+void OCCViewer_ViewWindow::setActionVisible( ActionId theId, bool isVisible )
+{
+ QAction* a = toolMgr()->action( theId );
+ if( a )
+ a->setVisible( isVisible );
+}
+
+void OCCViewer_ViewWindow::projAndPanToGravity(V3d_TypeOfOrientation CamOri)
+{
+ const bool USE_XY = true;
+
+ Handle(V3d_View) aView3d = myViewPort->getView();
+ if (aView3d.IsNull())
+ return;
+
+ bool IsGr = false;
+ double X = 0, Y = 0, Z = 0;
+ if( USE_XY )
+ {
+ const double EPS = 1E-6;
+ int xp = myViewPort->width()/2, yp = myViewPort->height()/2, xp1, yp1;
+ aView3d->Convert( xp, yp, X, Y, Z );
+
+ gp_Dir d = aView3d->Camera()->Direction();
+ if( fabs( d.Z() ) > EPS )
+ {
+ double t = -Z/d.Z();
+ X += t*d.X();
+ Y += t*d.Y();
+ Z += t*d.Z();
+ }
+ }
+
+ // It is really necessary to compute gravity center even if it is not used in part of code below.
+ // Without this calculation the SetProj() method and other methods are not correct.
+ double X2, Y2, Z2;
+ IsGr = computeGravityCenter(X2, Y2, Z2);
+ if ( !IsGr )
+ IsGr = OCCViewer_Utilities::computeSceneBBCenter(aView3d, X2, Y2, Z2);
+
+ aView3d->SetProj(CamOri);
+ if (IsGr)
+ {
+ //aView3d->Update();
+ Handle(Graphic3d_Camera) Cam = aView3d->Camera();
+ gp_XYZ gp(X, Y, Z);
+ gp_Vec dir (Cam->Direction());
+ gp_Pnt eye = Cam->Eye();
+ gp_Vec V1(eye, gp);
+ Standard_Real D = dir.Dot(V1);
+ gp_Pnt ppdir = eye.Translated(D*dir);
+ gp_Vec V2(ppdir, gp);
+ gp_XYZ trEye = eye.XYZ() + V2.XYZ();
+
+ double xat, yat, zat;
+ aView3d->At(xat, yat, zat);
+ gp_Pnt At(xat, yat, zat);
+ gp_XYZ trAt = At.XYZ() + V2.XYZ();
+ aView3d->SetEye(trEye.X(), trEye.Y(), trEye.Z());
+ aView3d->SetAt(trAt.X(), trAt.Y(), trAt.Z());
+ }
+}
+
+
+bool OCCViewer_ViewWindow::isAutomaticZoom() const
+{
+ return myAutomaticZoom;
+}
+
+void OCCViewer_ViewWindow::setAutomaticZoom(const bool isOn)
+{
+ myAutomaticZoom = isOn;
+}
+
if ( !wid )
return;
- QList<QAction*> items = wid->actions();
- if ( items.isEmpty() )
- return;
-
- bool action = false;
- for ( int i = 0; i < items.count(); i++ )
+ if ( wid->inherits( "QMenu") || wid->inherits( "QMenuBar") )
{
- QAction* a = items[i];
- if ( a->isSeparator() ) {
- a->setVisible(action);
- action = false;
- }
- else if ( a->isVisible() ) {
- action = true;
- if ( recursive && a->menu() )
- simplifySeparators( a->menu(), recursive );
+ if ( qobject_cast<QMenu*>( wid ) )
+ qobject_cast<QMenu*>( wid )->setSeparatorsCollapsible( true );
+ if ( recursive )
+ {
+ foreach ( QAction* action, wid->actions() )
+ {
+ if ( action->menu() )
+ simplifySeparators( action->menu(), recursive );
+ }
}
}
-
- action = false;
- for ( int i = items.count() - 1; i > 0; i-- ) {
- QAction* a = items[i];
- if ( a->isSeparator() ) {
- a->setVisible(action);
- action = false;
+ else
+ {
+ QList<QAction*> actions = wid->actions();
+ if ( actions.isEmpty() )
+ return;
+
+ bool is_action = false;
+ for ( int i = 0; i < actions.count(); i++ )
+ {
+ QAction* action = actions[i];
+ if ( action->isSeparator() )
+ {
+ action->setVisible( is_action );
+ is_action = false;
+ }
+ else if ( action->isVisible() )
+ {
+ is_action = true;
+ }
+ }
+ is_action = false;
+ for ( int i = actions.count() - 1; i > 0; i-- )
+ {
+ QAction* action = actions[i];
+ if ( action->isSeparator() )
+ {
+ action->setVisible( is_action );
+ is_action = false;
+ }
+ else if ( action->isVisible() )
+ {
+ is_action = true;
+ }
}
- else if ( a->isVisible() )
- action = true;
}
}
*/
bool Qtx::dos2unix( const QString& absName )
{
- FILE* src = ::fopen( absName.toLatin1(), "rb" );
+ FILE* src = ::fopen( absName.toUtf8(), "rb" );
if ( !src )
return false;
/* we'll use temporary file */
char temp[512] = { '\0' };
QString dir = Qtx::dir( absName );
- FILE* tgt = ::fopen( strcpy( temp, ::tempnam( dir.toLatin1(), "__x" ) ), "wb" );
+ FILE* tgt = ::fopen( strcpy( temp, ::tempnam( dir.toUtf8(), "__x" ) ), "wb" );
if ( !tgt )
return false;
break;
QString newStr;
- if ( ::getenv( envName.toLatin1() ) || mode == Always )
- newStr = QString( ::getenv( envName.toLatin1() ) );
+ if ( ::getenv( envName.toUtf8() ) || mode == Always )
+ newStr = QString( ::getenv( envName.toUtf8() ) );
if ( newStr.isNull() )
{
#include "OCCViewer_ViewWindow.h"
#include "OCCViewer_ViewFrame.h"
#endif // DISABLE_OCCVIEWER
+#ifndef DISABLE_VTKVIEWER
+#include "SVTK_ViewWindow.h"
+#endif // DISABLE_VTKVIEWER
#ifndef DISABLE_PLOT2DVIEWER
#include "Plot2d_ViewManager.h"
#include "Plot2d_ViewWindow.h"
if ( app && !fileName.isEmpty() ) {
QPixmap pixmap = app->resourceMgr()->loadPixmap( module,
QApplication::translate( module.toLatin1().data(),
- fileName.toLatin1().data() ) );
+ fileName.toUtf8().data() ) );
if ( !pixmap.isNull() )
icon = QIcon( pixmap );
}
ProcessVoidEvent( new TPutInfoEvent( msg, sec ) );
}
+/*!
+ \fn int SalomePyQt::showNotification( const QString& msg, const QString& title, const int sec );
+ \brief Show notification in the application's desktop window.
+
+ Optional third delay parameter (\a sec) can be used to specify
+ time of the notification diplaying in seconds. If this parameter is less
+ or equal to zero, the permanent notification will be put.
+
+ Notification can be forcibly hidden via hideNotification() method.
+
+ \param msg message text
+ \param title title text
+ \param sec notification displaying time in seconds
+ \return unique ID of the notification (can be used to hide notification)
+ \sa hideNotification()
+*/
+
+class TShowNotifyEvent: public SALOME_Event
+{
+ QString myMsg;
+ QString myTitle;
+ int mySecs;
+
+public:
+ typedef int TResult;
+ TResult myResult;
+
+public:
+ TShowNotifyEvent( const QString& msg, const QString& title, const int sec = -1 ) : myMsg( msg ), myTitle( title), mySecs( sec ), myResult( -1 ) {}
+ virtual void Execute()
+ {
+ if ( LightApp_Application* anApp = getApplication() ) {
+ myResult = anApp->showNotification( myMsg, myTitle, mySecs * 1000 );
+ }
+ }
+};
+
+int SalomePyQt::showNotification( const QString& msg, const QString& title, const int sec )
+{
+ return ProcessEvent( new TShowNotifyEvent( msg, title, sec ) );
+}
+
+/*!
+ \fn void SalomePyQt::hideNotification( const QString& msg );
+ \brief Remove notification with given message text from the application's desktop.
+
+ \param msg message text
+ \sa showNotification()
+*/
+
+/*!
+ \fn void SalomePyQt::hideNotification( const int id );
+ \brief Remove notification with given \a id from the application's desktop.
+
+ \param id notification id
+ \sa showNotification()
+*/
+
+class THideNotifyEvent: public SALOME_Event
+{
+ int myId;
+ QString myMsg;
+
+public:
+ THideNotifyEvent( const QString& msg ) : myId( -1 ), myMsg( msg ) {}
+ THideNotifyEvent( const int id ) : myId( id ) {}
+ virtual void Execute()
+ {
+ if ( LightApp_Application* anApp = getApplication() ) {
+ if ( myId >= 0 )
+ anApp->hideNotification( myId );
+ else
+ anApp->hideNotification( myMsg );
+ }
+ }
+};
+
+void SalomePyQt::hideNotification( const QString& msg )
+{
+ ProcessVoidEvent( new THideNotifyEvent( msg ) );
+}
+
+void SalomePyQt::hideNotification( const int id )
+{
+ ProcessVoidEvent( new THideNotifyEvent( id ) );
+}
+
/*!
\fn const QString SalomePyQt::getActiveComponent();
\brief Get the currently active module name (for the current study).
return ProcessEvent( new TSetViewSize( w, h, id ) );
}
+/*!
+ \fn bool SalomePyQt::setViewRotationPoint( const double x, const double y, const double z, const int id );
+ \brief Set view rotation point
+ \param x coordinate X view rotation point
+ \param y coordinate Y view rotation point
+ \param z coordinate Z view rotation point
+ \param id window identifier
+ \return \c true if operation is completed successfully and \c false otherwise
+*/
+
+class TSetViewRotationPoint: public SALOME_Event
+{
+public:
+ typedef bool TResult;
+ TResult myResult;
+ double myX;
+ double myY;
+ double myZ;
+ int myWndId;
+ TSetViewRotationPoint( const double x, const double y, const double z, const int id )
+ : myResult( false ),
+ myX( x ),
+ myY( y ),
+ myZ( z ),
+ myWndId( id ) {}
+ virtual void Execute()
+ {
+ SUIT_ViewWindow* wnd = 0;
+ if ( !myWndId ) {
+ if ( LightApp_Application* anApp = getApplication() ) {
+ SUIT_ViewManager* vm = anApp->activeViewManager();
+ if ( vm )
+ wnd = vm->getActiveView();
+ }
+ }
+ else {
+ wnd = dynamic_cast<SUIT_ViewWindow*>( getWnd( myWndId ) );
+ }
+ if ( wnd ) {
+ SUIT_ViewManager* viewMgr = wnd->getViewManager();
+ if ( viewMgr ) {
+ QString type = viewMgr->getType();
+ if ( type == "OCCViewer") {
+#ifndef DISABLE_OCCVIEWER
+ // specific processing for OCC viewer:
+ // OCC view can embed up to 4 sub-views, split according to the specified layout;
+ // - if there is only one sub-view active; its rotation point will be changed;
+ // - if there are several sub-views, rotaion points of each of them will be changed.
+ OCCViewer_ViewWindow* occView = qobject_cast<OCCViewer_ViewWindow*>( wnd );
+ if ( occView ) {
+ for ( int i = OCCViewer_ViewFrame::BOTTOM_RIGHT; i <= OCCViewer_ViewFrame::TOP_RIGHT; i++ ) {
+ if ( occView && occView->getView( i ) ) {
+ occView->getView( i )->activateSetRotationSelected( myX, myY, myZ );
+ myResult = true;
+ }
+ }
+ }
+#endif // DISABLE_OCCVIEWER
+ }
+ else if ( type == "VTKViewer") {
+#ifndef DISABLE_VTKVIEWER
+ SVTK_ViewWindow* vtkView = qobject_cast<SVTK_ViewWindow*>( wnd );
+ if ( vtkView )
+ {
+ double aCenter[3] = { myX, myY, myZ };
+ vtkView->activateSetRotationSelected( (void*)aCenter );
+ myResult = true;
+ }
+#endif // DISABLE_VTKVIEWER
+ }
+ }
+ }
+ }
+};
+bool SalomePyQt::setViewRotationPoint( const double x, const double y, const double z, const int id )
+{
+ return ProcessEvent( new TSetViewRotationPoint( x, y, z, id ) );
+}
+
/*!
\fn QString SalomePyQt::getViewTitle( const int id );
\brief Get view caption
{
myModel = theModel;
myInteractor = new SVTK_RenderWindowInteractor(this,"SVTK_RenderWindowInteractor");
-
+
SVTK_Selector* aSelector = SVTK_Selector::New();
int aPreselectionMode = SUIT_Session::session()->resourceMgr()->
integerValue( "VTKViewer", "preselection", Standard_Preselection );
bool isSelectionEnabled = SUIT_Session::session()->resourceMgr()->
booleanValue( "VTKViewer", "enable_selection", true );
aSelector->SetSelectionEnabled( isSelectionEnabled );
-
+
SVTK_GenericRenderWindowInteractor* aDevice = SVTK_GenericRenderWindowInteractor::New();
aDevice->SetRenderWidget(myInteractor);
aDevice->SetSelector(aSelector);
-
+
SVTK_Renderer* aRenderer = SVTK_Renderer::New();
aRenderer->Initialize(aDevice,aSelector);
-
+
myInteractor->Initialize(aDevice,aRenderer,aSelector);
-
+
aDevice->Delete();
aRenderer->Delete();
aSelector->Delete();
-
+
myToolBar = toolMgr()->createToolBar( tr("LBL_TOOLBAR_LABEL"), // title (language-dependant)
- QString( "VTKViewerViewOperations" ), // name (language-independant)
- false ); // disable floatable toolbar
+ QString( "VTKViewerViewOperations" ), // name (language-independant)
+ false ); // disable floatable toolbar
myRecordingToolBar = toolMgr()->createToolBar( tr("LBL_TOOLBAR_RECORD_LABEL"), // title (language-dependant)
- QString( "VTKRecordingOperations" ), // name (language-independant)
- false ); // disable floatable toolbar
-
+ QString( "VTKRecordingOperations" ), // name (language-independant)
+ false ); // disable floatable toolbar
+
createActions( SUIT_Session::session()->resourceMgr() );
createToolBar();
-
+
SetEventDispatcher(myInteractor->GetDevice());
myInteractor->setBackgroundRole( QPalette::NoRole );//NoBackground
myInteractor->setFocusPolicy(Qt::StrongFocus);
booleanValue( "VTKViewer", "enable_quad_buffer_support", false );
myInteractor->getRenderWindow()->SetStereoCapableWindow((int)isSupportQuadBuffer);
setFocusProxy(myInteractor);
-
+
myUpdateRateDlg = new SVTK_UpdateRateDlg( getAction( UpdateRate ), this, "SVTK_UpdateRateDlg" );
myNonIsometricDlg = new SVTK_NonIsometricDlg( getAction( NonIsometric ), this, "SVTK_NonIsometricDlg" );
myCubeAxesDlg = new SVTK_CubeAxesDlg( getAction( GraduatedAxes ), this, "SVTK_CubeAxesDlg" );
myEventCallbackCommand->SetCallback(SVTK_ViewWindow::ProcessEvents);
myEventCallbackCommand->Delete();
- GetInteractor()->GetInteractorStyle()->AddObserver(SVTK::OperationFinished,
- myEventCallbackCommand.GetPointer(), 0.0);
- myKeyFreeInteractorStyle->AddObserver(SVTK::OperationFinished,
- myEventCallbackCommand.GetPointer(), 0.0);
+ GetInteractor()->GetInteractorStyle()->AddObserver(SVTK::OperationFinished,
+ myEventCallbackCommand.GetPointer(), 0.0);
+ myKeyFreeInteractorStyle->AddObserver(SVTK::OperationFinished,
+ myEventCallbackCommand.GetPointer(), 0.0);
+
-
myInteractor->getRenderWindow()->Render();
setBackground( Qtx::BackgroundData( Qt::black ) ); // set default background
onResetView();
switch ( bgData.mode() ) {
case Qtx::ColorBackground:
{
- QColor c = bgData.color();
- if ( c.isValid() ) {
- // show solid-colored background
- getRenderer()->SetTexturedBackground( false ); // cancel texture mode
- getRenderer()->SetGradientBackground( false ); // cancel gradient mode
- getRenderer()->SetBackground( c.red()/255.0,
- c.green()/255.0,
- c.blue()/255.0 ); // set background color
- ok = true;
- }
- break;
+ QColor c = bgData.color();
+ if ( c.isValid() ) {
+ // show solid-colored background
+ getRenderer()->SetTexturedBackground( false ); // cancel texture mode
+ getRenderer()->SetGradientBackground( false ); // cancel gradient mode
+ getRenderer()->SetBackground( c.red()/255.0,
+ c.green()/255.0,
+ c.blue()/255.0 ); // set background color
+ ok = true;
+ }
+ break;
}
case Qtx::SimpleGradientBackground:
{
}
case Qtx::CustomGradientBackground:
{
- // NOT IMPLEMENTED YET
- getRenderer()->SetTexturedBackground( false ); // cancel texture mode
- getRenderer()->SetGradientBackground( false ); // cancel gradient mode
- // .........
- break;
+ // NOT IMPLEMENTED YET
+ getRenderer()->SetTexturedBackground( false ); // cancel texture mode
+ getRenderer()->SetGradientBackground( false ); // cancel gradient mode
+ // .........
+ break;
}
default:
break;
int textureMode = bgData.texture( fileName );
QFileInfo fi( fileName );
if ( !fileName.isEmpty() && fi.exists() ) {
- // read texture from file
- QString extension = fi.suffix().toLower();
- vtkImageReader2* aReader = 0;
- if ( extension == "jpg" || extension == "jpeg" )
- aReader = vtkJPEGReader::New();
- else if ( extension == "bmp" )
- aReader = vtkBMPReader::New();
- else if ( extension == "tif" || extension == "tiff" )
- aReader = vtkTIFFReader::New();
- else if ( extension == "png" )
- aReader = vtkPNGReader::New();
- else if ( extension == "mhd" || extension == "mha" )
- aReader = vtkMetaImageReader::New();
- if ( aReader ) {
- // create texture
- aReader->SetFileName( fi.absoluteFilePath().toUtf8().constData() );
- aReader->Update();
- VTKViewer_Texture* aTexture = VTKViewer_Texture::New();
- vtkImageMapToColors* aMap = 0;
- vtkAlgorithmOutput* anOutput;
- /*
- // special processing for BMP reader
- vtkBMPReader* aBMPReader = (vtkBMPReader*)aReader;
- if ( aBMPReader ) {
- // Special processing for BMP file
- aBMPReader->SetAllow8BitBMP(1);
-
- aMap = vtkImageMapToColors::New();
- aMap->SetInputConnection( aBMPReader->GetOutputPort() );
- aMap->SetLookupTable( (vtkScalarsToColors*)aBMPReader->GetLookupTable() );
- aMap->SetOutputFormatToRGB();
-
- anOutput = aMap->GetOutputPort();
- }
- else {
- }
- */
- anOutput = aReader->GetOutputPort( 0 );
- aTexture->SetInputConnection( anOutput );
- // set texture mode
- // VSR: Currently, VTK only supports Stretch mode, so below code will give
- // the same results for all modes
- switch ( textureMode ) {
- case Qtx::TileTexture:
- aTexture->SetPosition((int)VTKViewer_Texture::Tiled);
- break;
- case Qtx::StretchTexture:
- aTexture->SetPosition((int)VTKViewer_Texture::Stretched);
- break;
- case Qtx::CenterTexture:
- aTexture->SetPosition((int)VTKViewer_Texture::Centered);
- default:
- break;
- }
- // show textured background
- getRenderer()->SetTexturedBackground( true );
- getRenderer()->SetBackgroundTexture( aTexture );
-
- // clean-up resources
- if ( aMap )
- aMap->Delete();
- aReader->Delete();
- aTexture->Delete();
- ok = true;
- }
+ // read texture from file
+ QString extension = fi.suffix().toLower();
+ vtkImageReader2* aReader = 0;
+ if ( extension == "jpg" || extension == "jpeg" )
+ aReader = vtkJPEGReader::New();
+ else if ( extension == "bmp" )
+ aReader = vtkBMPReader::New();
+ else if ( extension == "tif" || extension == "tiff" )
+ aReader = vtkTIFFReader::New();
+ else if ( extension == "png" )
+ aReader = vtkPNGReader::New();
+ else if ( extension == "mhd" || extension == "mha" )
+ aReader = vtkMetaImageReader::New();
+ if ( aReader ) {
+ // create texture
- aReader->SetFileName( fi.absoluteFilePath().toLatin1().constData() );
++ aReader->SetFileName( fi.absoluteFilePath().toUtf8().constData() );
+ aReader->Update();
+ VTKViewer_Texture* aTexture = VTKViewer_Texture::New();
+ vtkImageMapToColors* aMap = 0;
+ vtkAlgorithmOutput* anOutput;
+ /*
+ // special processing for BMP reader
+ vtkBMPReader* aBMPReader = (vtkBMPReader*)aReader;
+ if ( aBMPReader ) {
+ // Special processing for BMP file
+ aBMPReader->SetAllow8BitBMP(1);
+
+ aMap = vtkImageMapToColors::New();
+ aMap->SetInputConnection( aBMPReader->GetOutputPort() );
+ aMap->SetLookupTable( (vtkScalarsToColors*)aBMPReader->GetLookupTable() );
+ aMap->SetOutputFormatToRGB();
+
+ anOutput = aMap->GetOutputPort();
+ }
+ else {
+ }
+ */
+ anOutput = aReader->GetOutputPort( 0 );
+ aTexture->SetInputConnection( anOutput );
+ // set texture mode
+ // VSR: Currently, VTK only supports Stretch mode, so below code will give
+ // the same results for all modes
+ switch ( textureMode ) {
+ case Qtx::TileTexture:
+ aTexture->SetPosition((int)VTKViewer_Texture::Tiled);
+ break;
+ case Qtx::StretchTexture:
+ aTexture->SetPosition((int)VTKViewer_Texture::Stretched);
+ break;
+ case Qtx::CenterTexture:
+ aTexture->SetPosition((int)VTKViewer_Texture::Centered);
+ default:
+ break;
+ }
+ // show textured background
+ getRenderer()->SetTexturedBackground( true );
+ getRenderer()->SetBackgroundTexture( aTexture );
+
+ // clean-up resources
+ if ( aMap )
+ aMap->Delete();
+ aReader->Delete();
+ aTexture->Delete();
+ ok = true;
+ }
}
}
}
SVTK_Viewer* aViewer = dynamic_cast<SVTK_Viewer*>(myModel);
QtxAction* aSwitchZoomingStyle = dynamic_cast<QtxAction*>( toolMgr()->action( SwitchZoomingStyleId ) );
if ( theMode == Parallel && !aParallelAction->isChecked() ) {
- aParallelAction->setChecked( true );
- aSwitchZoomingStyle->setEnabled(true);
- aStereoAction->setChecked( false );
+ aParallelAction->setChecked( true );
+ aSwitchZoomingStyle->setEnabled(true);
+ aStereoAction->setChecked( false );
}
if ( theMode == Projection && !aProjectionAction->isChecked() ) {
- aProjectionAction->setChecked( true );
- aSwitchZoomingStyle->setEnabled(false);
+ aProjectionAction->setChecked( true );
+ aSwitchZoomingStyle->setEnabled(false);
}
if ( theMode == Stereo ) {
aStereoAction->setChecked( true );
if ( aParallelAction->isEnabled() ) {
- aParallelAction->setEnabled( false );
- aParallelAction->setChecked( false );
- aStereoAction->setChecked( false );
+ aParallelAction->setEnabled( false );
+ aParallelAction->setChecked( false );
+ aStereoAction->setChecked( false );
}
else {
aParallelAction->setEnabled( true );
for (int i = 0; i < actors->GetNumberOfItems(); ++i )
if (VTKViewer_Actor *actor = dynamic_cast<VTKViewer_Actor*>(actors->GetItemAsObject(i)))
{
- cout << "actor " << actor << endl;
actor->EnableSelection( theEnable );
}
}
QString aFilePrefix(fileName);
QString anExtension(SUIT_Tools::extension(fileName));
aFilePrefix.truncate(aFilePrefix.length() - 1 - anExtension.length());
- anExporter->SetFilePrefix(aFilePrefix.toLatin1().data());
+ anExporter->SetFilePrefix(aFilePrefix.toUtf8().data());
anExporter->Write();
anExporter->Delete();
}
//printf("#### Color: %f, %f, %f\n", color[0], color[1], color[2]);
actor->SetTitleVisibility( isVisible );
- actor->SetTitle( title.toLatin1() );
+ actor->SetTitle( title.toUtf8() );
vtkTextProperty* txtProp = actor->GetTitleTextProperty();
if ( txtProp ) {
txtProp->SetColor( color );
int shadow = paramsLst[10].toInt();
actor->SetTitleVisibility( isVisible );
- actor->SetTitle( title.toLatin1() );
+ actor->SetTitle( title.toUtf8() );
vtkTextProperty* txtProp = actor->GetTitleTextProperty();
if ( txtProp ) {
txtProp->SetColor( color );
*/
void SVTK_ViewWindow::doSetVisualParameters( const QString& parameters, bool baseParamsOnly )
{
-
+
double pos[3], focalPnt[3], viewUp[3], parScale, scale[3];
QXmlStreamReader aReader(parameters);
if (aReader.isStartElement()) {
QXmlStreamAttributes aAttr = aReader.attributes();
//printf("### Name = %s\n", qPrintable(aReader.name().toString()));
- if (aReader.name() == "Position") {
+ if (aReader.name() == "Position") {
pos[0] = aAttr.value("X").toString().toDouble();
pos[1] = aAttr.value("Y").toString().toDouble();
pos[2] = aAttr.value("Z").toString().toDouble();
scale[1] = aAttr.value("Y").toString().toDouble();
scale[2] = aAttr.value("Z").toString().toDouble();
//printf("#### ViewScale %f; %f; %f\n", scale[0], scale[1], scale[2]);
- }
+ }
else if (aReader.name() == "DisplayCubeAxis") {
- if ( !baseParamsOnly ) {
- if (aAttr.value("Show") == "0")
- gradAxesActor->VisibilityOff();
- else
- gradAxesActor->VisibilityOn();
- }
+ if ( !baseParamsOnly ) {
+ if (aAttr.value("Show") == "0")
+ gradAxesActor->VisibilityOff();
+ else
+ gradAxesActor->VisibilityOn();
+ }
}
else if (aReader.name() == "GraduatedAxis") {
- if ( !baseParamsOnly ) {
- if(aAttr.value("Axis") == "X")
- setGradAxisVisualParams(aReader, gradAxesActor->GetXAxisActor2D());
- else if(aAttr.value("Axis") == "Y")
- setGradAxisVisualParams(aReader, gradAxesActor->GetYAxisActor2D());
- else if(aAttr.value("Axis") == "Z")
- setGradAxisVisualParams(aReader, gradAxesActor->GetZAxisActor2D());
- }
- }
+ if ( !baseParamsOnly ) {
+ if(aAttr.value("Axis") == "X")
+ setGradAxisVisualParams(aReader, gradAxesActor->GetXAxisActor2D());
+ else if(aAttr.value("Axis") == "Y")
+ setGradAxisVisualParams(aReader, gradAxesActor->GetYAxisActor2D());
+ else if(aAttr.value("Axis") == "Z")
+ setGradAxisVisualParams(aReader, gradAxesActor->GetZAxisActor2D());
+ }
+ }
else if (aReader.name() == "Trihedron") {
- if ( !baseParamsOnly ) {
- if (aAttr.value("isShown") == "0")
- GetTrihedron()->VisibilityOff();
- else
- GetTrihedron()->VisibilityOn();
- SetTrihedronSize(aAttr.value("Size").toString().toDouble());
- }
+ if ( !baseParamsOnly ) {
+ if (aAttr.value("isShown") == "0")
+ GetTrihedron()->VisibilityOff();
+ else
+ GetTrihedron()->VisibilityOn();
+ SetTrihedronSize(aAttr.value("Size").toString().toDouble());
+ }
}
else if (aReader.name() == "Background") {
- if ( !baseParamsOnly ) {
- setBackground( Qtx::stringToBackground( aAttr.value("Value").toString() ) );
- }
+ if ( !baseParamsOnly ) {
+ setBackground( Qtx::stringToBackground( aAttr.value("Value").toString() ) );
+ }
}
}
}
scale[0] = paramsLst[10].toDouble();
scale[1] = paramsLst[11].toDouble();
scale[2] = paramsLst[12].toDouble();
-
+
// applying parameters
vtkCamera* camera = getRenderer()->GetActiveCamera();
camera->SetPosition( pos );
camera->SetParallelScale( parScale );
GetRenderer()->SetScale( scale );
//SetScale( scale );
-
+
// apply graduated axes parameters
if ( !baseParamsOnly ) {
- SVTK_CubeAxesActor2D* gradAxesActor = GetCubeAxes();
- if ( gradAxesActor && paramsLst.size() == nAllParams ) {
- int i = nNormalParams+1, j = i + nGradAxisParams - 1;
- ::setGradAxisVisualParams( gradAxesActor->GetXAxisActor2D(), parameters.section( '*', i, j ) );
- i = j + 1; j += nGradAxisParams;
- ::setGradAxisVisualParams( gradAxesActor->GetYAxisActor2D(), parameters.section( '*', i, j ) );
- i = j + 1; j += nGradAxisParams;
- ::setGradAxisVisualParams( gradAxesActor->GetZAxisActor2D(), parameters.section( '*', i, j ) );
-
- if ( paramsLst[13].toUShort() )
- gradAxesActor->VisibilityOn();
- else
- gradAxesActor->VisibilityOff();
- }
- else if ( paramsLst.size() == nAllParams ) {
- if ( paramsLst[90].toUShort() )
- GetTrihedron()->VisibilityOn();
- else
- GetTrihedron()->VisibilityOff();
-
- SetTrihedronSize(paramsLst[91].toDouble());
- }
+ SVTK_CubeAxesActor2D* gradAxesActor = GetCubeAxes();
+ if ( gradAxesActor && paramsLst.size() == nAllParams ) {
+ int i = nNormalParams+1, j = i + nGradAxisParams - 1;
+ ::setGradAxisVisualParams( gradAxesActor->GetXAxisActor2D(), parameters.section( '*', i, j ) );
+ i = j + 1; j += nGradAxisParams;
+ ::setGradAxisVisualParams( gradAxesActor->GetYAxisActor2D(), parameters.section( '*', i, j ) );
+ i = j + 1; j += nGradAxisParams;
+ ::setGradAxisVisualParams( gradAxesActor->GetZAxisActor2D(), parameters.section( '*', i, j ) );
+
+ if ( paramsLst[13].toUShort() )
+ gradAxesActor->VisibilityOn();
+ else
+ gradAxesActor->VisibilityOff();
+ }
+ else if ( paramsLst.size() == nAllParams ) {
+ if ( paramsLst[90].toUShort() )
+ GetTrihedron()->VisibilityOn();
+ else
+ GetTrihedron()->VisibilityOff();
+
+ SetTrihedronSize(paramsLst[91].toDouble());
+ }
}
}
}
this->addAction(anAction);
mgr->registerAction( anAction, FrontId );
- anAction = new QtxAction(tr("MNU_BACK_VIEW"),
+ anAction = new QtxAction(tr("MNU_BACK_VIEW"),
theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_BACK" ) ),
tr( "MNU_BACK_VIEW" ), 0, this, false, "Viewers:Back view");
anAction->setStatusTip(tr("DSC_BACK_VIEW"));
this->addAction(anAction);
mgr->registerAction( anAction, BackId );
- anAction = new QtxAction(tr("MNU_TOP_VIEW"),
+ anAction = new QtxAction(tr("MNU_TOP_VIEW"),
theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_TOP" ) ),
tr( "MNU_TOP_VIEW" ), 0, this, false, "Viewers:Top view");
anAction->setStatusTip(tr("DSC_TOP_VIEW"));
this->addAction(anAction);
mgr->registerAction( anAction, TopId );
- anAction = new QtxAction(tr("MNU_BOTTOM_VIEW"),
+ anAction = new QtxAction(tr("MNU_BOTTOM_VIEW"),
theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_BOTTOM" ) ),
tr( "MNU_BOTTOM_VIEW" ), 0, this, false, "Viewers:Bottom view");
anAction->setStatusTip(tr("DSC_BOTTOM_VIEW"));
this->addAction(anAction);
mgr->registerAction( anAction, BottomId );
- anAction = new QtxAction(tr("MNU_LEFT_VIEW"),
+ anAction = new QtxAction(tr("MNU_LEFT_VIEW"),
theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_LEFT" ) ),
tr( "MNU_LEFT_VIEW" ), 0, this, false, "Viewers:Left view");
anAction->setStatusTip(tr("DSC_LEFT_VIEW"));
this->addAction(anAction);
mgr->registerAction( anAction, LeftId );
- anAction = new QtxAction(tr("MNU_RIGHT_VIEW"),
+ anAction = new QtxAction(tr("MNU_RIGHT_VIEW"),
theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_RIGHT" ) ),
tr( "MNU_RIGHT_VIEW" ), 0, this, false, "Viewers:Right view");
anAction->setStatusTip(tr("DSC_RIGHT_VIEW"));
// rotate anticlockwise
anAction = new QtxAction(tr("MNU_ANTICLOCKWISE_VIEW"),
- theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_ANTICLOCKWISE" ) ),
+ theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_ANTICLOCKWISE" ) ),
tr( "MNU_ANTICLOCKWISE_VIEW" ), 0, this, false, "Viewers:Rotate anticlockwise");
anAction->setStatusTip(tr("DSC_ANTICLOCKWISE_VIEW"));
connect(anAction, SIGNAL(triggered()), this, SLOT(onAntiClockWiseView()));
// rotate clockwise
anAction = new QtxAction(tr("MNU_CLOCKWISE_VIEW"),
- theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_CLOCKWISE" ) ),
+ theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_CLOCKWISE" ) ),
tr( "MNU_CLOCKWISE_VIEW" ), 0, this, false, "Viewers:Rotate clockwise");
anAction->setStatusTip(tr("DSC_CLOCKWISE_VIEW"));
connect(anAction, SIGNAL(triggered()), this, SLOT(onClockWiseView()));
Processes events
*/
void SVTK_ViewWindow::ProcessEvents(vtkObject* vtkNotUsed(theObject),
- unsigned long theEvent,
- void* theClientData,
- void* theCallData)
+ unsigned long theEvent,
+ void* theClientData,
+ void* theCallData)
{
SVTK_ViewWindow* self = reinterpret_cast<SVTK_ViewWindow*>(theClientData);
if(self)
script.remove( QRegExp("^python.*[\\s]+") );
QString cmd = script+" "+args;
- QString command = QString( "exec(open(\"%1\",encoding='utf-8').read())" ).arg(cmd.trimmed());
++
+ QString command = QString( "exec(open(\"%1\", \"rb\").read())" ).arg(cmd.trimmed());
pyConsole->exec(command);
}
} // end for loop on pyfiles QStringList
{
onNewDoc();
- QString command = QString("exec(open(\"%1\",encoding='utf-8').read())").arg(aFile);
+ QString command = QString("exec(open(\"%1\", \"rb\").read())").arg(aFile);
#ifndef DISABLE_PYCONSOLE
PyConsole_Console* pyConsole = pythonConsole();
/*!SLOT. Copy objects to study maneger from selection maneger..*/
void SalomeApp_Application::onCopy()
{
+ LightApp_Application::onCopy();
+
SALOME_ListIO list;
LightApp_SelectionMgr* mgr = selectionMgr();
mgr->selectedObjects(list);
if(it.More())
{
_PTR(SObject) so = stdDS->FindObjectID(it.Value()->getEntry());
- try {
- stdDS->Copy(so);
- onSelectionChanged();
- }
- catch(...) {
+ if( so )
+ {
+ try {
+ stdDS->Copy(so);
+ onSelectionChanged();
+ }
+ catch(...) {
+ }
}
}
}
/*!SLOT. Paste objects to study maneger from selection manager.*/
void SalomeApp_Application::onPaste()
{
+ LightApp_Application::onPaste();
+
SALOME_ListIO list;
LightApp_SelectionMgr* mgr = selectionMgr();
mgr->selectedObjects(list);
if(it.More())
{
_PTR(SObject) so = stdDS->FindObjectID(it.Value()->getEntry());
- try {
- stdDS->Paste(so);
- updateObjectBrowser( true );
- updateActions(); //SRN: BugID IPAL9377, case 3
- }
- catch(...) {
+ if( so )
+ {
+ try {
+ stdDS->Paste(so);
+ updateObjectBrowser( true );
+ updateActions(); //SRN: BugID IPAL9377, case 3
+ }
+ catch(...) {
+ }
}
}
}
if ( !aFile.isEmpty() )
{
- QString command = QString("exec(open(\"%1\",encoding='utf-8').read())").arg(aFile);
++
+ QString command = QString("exec(open(\"%1\", \"rb\").read())").arg(aFile);
#ifndef DISABLE_PYCONSOLE
PyConsole_Console* pyConsole = pythonConsole();
} else { // file is not exist on disk
SUIT_MessageBox::warning( desktop(),
QObject::tr("WRN_WARNING"),
- QObject::tr("WRN_FILE_NOT_EXIST").arg(aName.toLatin1().data()));
+ QObject::tr("WRN_FILE_NOT_EXIST").arg(aName.toUtf8().data()));
return false;
}
SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
// load study from the temporary directory
- QString command = QString( "exec(open(\"%1\",encoding='utf-8').read())" ).arg( theDumpScript );
++
+ QString command = QString( "exec(open(\"%1\" ,\"rb\").read())" ).arg( theDumpScript );
#ifndef DISABLE_PYCONSOLE
PyConsole_Console* pyConsole = app->pythonConsole();
#define BallTextureId 0
+
+void MessageCallback( GLenum source,
+ GLenum type,
+ GLuint id,
+ GLenum severity,
+ GLsizei length,
+ const GLchar* message,
+ const void* userParam )
+{
+ fprintf( stderr, "GL CALLBACK: %s type = 0x%x, severity = 0x%x, message = %s\n",
+ ( type == GL_DEBUG_TYPE_ERROR ? "** GL ERROR **" : "" ),
+ type, severity, message );
+}
+
+
//-----------------------------------------------------------------------------
VTKViewer_PolyDataMapper::VTKViewer_PolyDataMapper()
{
#endif
this->OpenGLHelper.Init();
+
+ // For debug purposes only
+ // glEnable ( GL_DEBUG_OUTPUT );
+ // glDebugMessageCallback( (GLDEBUGPROC) MessageCallback, 0 );
+
}
//-----------------------------------------------------------------------------
return false;
// Get uniform locations.
+ GLint current_program;
+ glGetIntegerv( GL_CURRENT_PROGRAM, ¤t_program );
this->OpenGLHelper.vglUseProgramObjectARB( this->PointProgram );
this->myLocations.ModelViewProjection = this->OpenGLHelper.vglGetUniformLocationARB( this->PointProgram, "uModelViewProjectionMatrix" );
this->myLocations.GeneralPointSize = this->OpenGLHelper.vglGetUniformLocationARB( this->PointProgram, "uGeneralPointSize" );
this->myLocations.PointSprite = this->OpenGLHelper.vglGetUniformLocationARB( this->PointProgram, "uPointSprite" );
- this->OpenGLHelper.vglUseProgramObjectARB( 0 );
+ this->OpenGLHelper.vglUseProgramObjectARB( current_program );
this->OpenGLHelper.vglGenVertexArraysARB(1, &this->VertexArrayObject);
#else
QString anAlphaTexture = getenv( "GUI_ROOT_DIR" );
anAlphaTexture.append( "/share/salome/resources/gui/sprite_alpha.vti" );
- vtkSmartPointer<vtkImageData> aTextureValue = VTK::MakeTexture( aMainTexture.toLatin1().constData(), anAlphaTexture.toLatin1().constData() );
+ vtkSmartPointer<vtkImageData> aTextureValue = VTK::MakeTexture( aMainTexture.toUtf8().constData(), anAlphaTexture.toUtf8().constData() );
this->SpecialTextures[BallTextureId] = aTextureValue;
}
this->ImageData = this->SpecialTextures[BallTextureId];
// make sure our window is current
ren->GetRenderWindow()->MakeCurrent();
-
+ GLint current_program;
+ glGetIntegerv( GL_CURRENT_PROGRAM, ¤t_program );
this->OpenGLHelper.vglUseProgramObjectARB( this->PointProgram );
#ifndef VTK_OPENGL2
// this->RenderEdges(ren,act);
//this->RenderPieceFinish(ren, act);
#endif
- this->OpenGLHelper.vglUseProgramObjectARB( 0 );
+ this->OpenGLHelper.vglUseProgramObjectARB( current_program );
this->CleanupPointSprites();
glBindTexture( GL_TEXTURE_2D, 0 );
}
if( this->ExtensionsInitialized == ES_Ok ) {
#ifdef VTK_OPENGL2
+ GLint current_program;
+ glGetIntegerv( GL_CURRENT_PROGRAM, ¤t_program );
this->OpenGLHelper.vglUseProgramObjectARB( this->PointProgram );
vtkOpenGLCamera *cam = (vtkOpenGLCamera *)(ren->GetActiveCamera());
this->OpenGLHelper.vglDeleteBuffersARB( 1, &aBufferObjectID );
this->OpenGLHelper.vglBindVertexArrayARB( 0 );
- this->OpenGLHelper.vglUseProgramObjectARB( 0 );
+ this->OpenGLHelper.vglUseProgramObjectARB( current_program );
#else
GLuint aBufferObjectID, aDiamsID = 0;
GLint attribute_diams = -1;