listBase += 256;
HDC glHdc = ::wglGetCurrentDC();
- #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
- ::SelectObject( glHdc, theFont->handle() );
- #endif
if ( !::wglUseFontBitmaps( glHdc, 0, 256, listBase ) )
listBase = 0;
aList = listBase;
QString aFontDef = theFont->toString();
char** xFontList = XListFonts( aDisp, aFontDef.toLatin1()/*aFindFont.myFontString.data()*/, 1, &aFontCont );
// TODO (QT5 PORTING) Below is a temporary solution, to allow compiling with Qt 5
-#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
- if( !theFont->handle() )
- {
-#endif
#ifdef _DEBUG_
- printf( "Can't load font %s. loading default font....\n", aFontDef.toLatin1().data()/*aFindFont.myFontString.data()*/ );
+ printf( "Can't load font %s. loading default font....\n", aFontDef.toLatin1().data()/*aFindFont.myFontString.data()*/ );
#endif
- QString aFontMask ("-*-*-*-r-*-*-");
- aFontMask += aFontDef/*aFindFont.myFontString*/.section( ',', 1, 1 );
+ QString aFontMask ("-*-*-*-r-*-*-");
+ aFontMask += aFontDef/*aFindFont.myFontString*/.section( ',', 1, 1 );
#ifdef _DEBUG_
- printf( "Height of Default font: %s\n", aFontDef/*aFindFont.myFontString*/.section( ',', 1, 1 ).data() );
+ printf( "Height of Default font: %s\n", aFontDef/*aFindFont.myFontString*/.section( ',', 1, 1 ).data() );
#endif
- aFontMask += "-*-*-*-m-*-*-*";
- xFontList = XListFonts( aDisp, aFontMask.toLatin1().constData()/*"-*-*-*-r-*-*-12-*-*-*-m-*-*-*"*/, 1, &aFontCont );
- if( aFontCont == 0 )
- {
+ aFontMask += "-*-*-*-m-*-*-*";
+ xFontList = XListFonts( aDisp, aFontMask.toLatin1().constData()/*"-*-*-*-r-*-*-12-*-*-*-m-*-*-*"*/, 1, &aFontCont );
+ if( aFontCont == 0 )
+ {
#ifdef _DEBUG_
- printf( "Can't load default font\n" );
+ printf( "Can't load default font\n" );
#endif
- return 0;
- }
- glXUseXFont( (Font)(XLoadFont( aDisp,xFontList[0] )), 0, 256, listBase );
-#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
+ return 0;
}
- else
- glXUseXFont( (Font)(theFont->handle()), 0, 256, listBase );
-#endif
+ glXUseXFont( (Font)(XLoadFont( aDisp,xFontList[0] )), 0, 256, listBase );
aList = listBase;
GLViewer_TexFont::BitmapFontCache[aFindFont] = aList;
}
#ifdef DEBUG
cout << "Choosing cmap for vID = " << vi->visualid << endl;
#endif
-
-#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
- if ( vi->visualid == XVisualIDFromVisual( (Visual*)QX11Info::appVisual() ) )
- {
-#ifdef DEBUG
- cout << "Using x11AppColormap" << endl;
-#endif
- return QX11Info::appColormap();
- }
-#else
if ( vi->visualid == XVisualIDFromVisual( XDefaultVisual( QX11Info::display(), -1 ) ) )
{
#ifdef DEBUG
#endif
return XDefaultColormap( QX11Info::display(), -1 );
}
-#endif
if ( mesa_gl )
{
Atom hp_cmaps = XInternAtom( dpy, "_HP_RGB_SMOOTH_MAP_LIST", true );
if ( state == Fin )
{
-#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
- QApplication::syncX(); /* force rectangle redrawing */
-#endif
myViewer->activateSketching( GLViewer_Viewer::NoSketching );
}
}
return false;
QPrinter printer(QPrinter::ScreenResolution);
-#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
- printer.setOutputFormat(QPrinter::PostScriptFormat);
-#else
printer.setOutputFormat(QPrinter::PdfFormat);
-#endif
printer.setOutputFileName(fileName);
QPainter painter;
if (!painter.begin(&printer))
return true;
bool res = server->listen(socketName);
-#if defined(Q_OS_UNIX) && (QT_VERSION >= QT_VERSION_CHECK(4,5,0))
- // ### Workaround
- if (!res && server->serverError() == QAbstractSocket::AddressInUseError) {
- QFile::remove(QDir::cleanPath(QDir::tempPath())+QLatin1Char('/')+socketName);
- res = server->listen(socketName);
- }
-#endif
if (!res)
qWarning("QtSingleCoreApplication: listen on local socket failed, %s", qPrintable(server->errorString()));
QObject::connect(server, SIGNAL(newConnection()), SLOT(receiveConnection()));
// Maximum number of concurrent read locks. Must not be greater than MAXIMUM_WAIT_OBJECTS
#define MAX_READERS MAXIMUM_WAIT_OBJECTS
-#if QT_VERSION >= 0x050000
#define QT_WA(unicode, ansi) unicode
-#endif
Qt::HANDLE QtLockedFile::getMutexHandle(int idx, bool doCreate)
{
sysInit(appId);
}
-#if QT_VERSION < 0x050000
-
-/*!
- Creates a QtSingleApplication object. The application identifier
- will be QCoreApplication::applicationFilePath(). \a argc, \a
- argv, and \a type are passed on to the QAppliation constructor.
-*/
-QtSingleApplication::QtSingleApplication(int &argc, char **argv, Type type)
- : QApplication(argc, argv, type)
-{
- sysInit();
-}
-
-
-# if defined(Q_WS_X11)
-/*!
- Special constructor for X11, ref. the documentation of
- QApplication's corresponding constructor. The application identifier
- will be QCoreApplication::applicationFilePath(). \a dpy, \a visual,
- and \a cmap are passed on to the QApplication constructor.
-*/
-QtSingleApplication::QtSingleApplication(Display* dpy, Qt::HANDLE visual, Qt::HANDLE cmap)
- : QApplication(dpy, visual, cmap)
-{
- sysInit();
-}
-
-/*!
- Special constructor for X11, ref. the documentation of
- QApplication's corresponding constructor. The application identifier
- will be QCoreApplication::applicationFilePath(). \a dpy, \a argc, \a
- argv, \a visual, and \a cmap are passed on to the QApplication
- constructor.
-*/
-QtSingleApplication::QtSingleApplication(Display *dpy, int &argc, char **argv, Qt::HANDLE visual, Qt::HANDLE cmap)
- : QApplication(dpy, argc, argv, visual, cmap)
-{
- sysInit();
-}
-
-/*!
- Special constructor for X11, ref. the documentation of
- QApplication's corresponding constructor. The application identifier
- will be \a appId. \a dpy, \a argc, \a
- argv, \a visual, and \a cmap are passed on to the QApplication
- constructor.
-*/
-QtSingleApplication::QtSingleApplication(Display* dpy, const QString &appId, int argc, char **argv, Qt::HANDLE visual, Qt::HANDLE cmap)
- : QApplication(dpy, argc, argv, visual, cmap)
-{
- sysInit(appId);
-}
-# endif // Q_WS_X11
-#endif // QT_VERSION < 0x050000
-
-
/*!
Returns true if another instance of this application is running;
otherwise false.
public:
QtSingleApplication(int &argc, char **argv, bool GUIenabled = true);
QtSingleApplication(const QString &id, int &argc, char **argv);
-#if QT_VERSION < 0x050000
- QtSingleApplication(int &argc, char **argv, Type type);
# if defined(Q_WS_X11)
QtSingleApplication(Display* dpy, Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0);
QtSingleApplication(Display *dpy, int &argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE cmap= 0);
QtSingleApplication(Display* dpy, const QString &appId, int argc, char **argv, Qt::HANDLE visual = 0, Qt::HANDLE colormap = 0);
# endif // Q_WS_X11
-#endif // QT_VERSION < 0x050000
bool isRunning();
QString id() const;
// Create OBSelector
new LightApp_OBSelector( ob, mySelMgr );
-#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
- ob->treeView()->header()->setResizeMode(SUIT_DataObject::VisibilityId, QHeaderView::Fixed);
-#else
ob->treeView()->header()->setSectionResizeMode(SUIT_DataObject::VisibilityId, QHeaderView::Fixed);
-#endif
ob->treeView()->header()->moveSection(SUIT_DataObject::NameId,SUIT_DataObject::VisibilityId);
ob->treeView()->setColumnWidth(SUIT_DataObject::VisibilityId, VISIBILITY_COLUMN_WIDTH);
ob->setProperty( "shortcut", QKeySequence( "Alt+Shift+O" ) );
//cout << "Choosing cmap for vID = " << vi->visualid << endl;
//#endif
-#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
- if ( vi->visualid == XVisualIDFromVisual( (Visual*)QX11Info::appVisual() ) )
- {
-#ifdef DEBUG
-// cout << "Using x11AppColormap" << endl;
-#endif
- return QX11Info::appColormap();
- }
-#else
if ( vi->visualid == XVisualIDFromVisual( XDefaultVisual( QX11Info::display(), -1 ) ) )
{
#ifdef DEBUG
#endif
return XDefaultColormap( QX11Info::display(), -1 );
}
-#endif
+
if ( mesa_gl )
{
Atom hp_cmaps = XInternAtom( dpy, "_HP_RGB_SMOOTH_MAP_LIST", true );
mapView( activeView() );
#endif
if ( !myWindow.IsNull() ) {
-#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
- QApplication::syncX();
-#endif
if ( !myPaintersRedrawing ) {
activeView()->Redraw();
}
*/
void OCCViewer_ViewPort3d::resizeEvent( QResizeEvent* e )
{
-#if defined WIN32 || QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
+#if defined WIN32
/* Win32 : map before first show to avoid flicker */
if ( !mapped( activeView() ) )
mapView( activeView() );
-#endif
-#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
- QApplication::syncX();
#endif
QTimer::singleShot( 0, this, SLOT( repaintViewAfterMove() ) );
emit vpResizeEvent( e );
if ( state == Fin )
{
-#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
- QApplication::syncX(); /* force rectangle redrawing */
-#endif
mypViewWindow->activateSketching( OCCViewer_ViewWindow::NoSketching );
}
}
if ( state == Fin ) {
mypPolyRB->clearGeometry();
mypPolyRB->hide();
-#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
- QApplication::syncX();
-#endif
mypViewWindow->activateSketching( OCCViewer_ViewWindow::NoSketching );
} else {
mypPolyRB->setUpdatesEnabled ( false );
if ( !myViewFrame )
return;
-#if !defined(WIN32) && !defined(QT_NO_CUPS)
-#if QT_VERSION < 0x040303
- if ( !Qtx::hasAnyPrinters() ) {
- SUIT_MessageBox::warning( this, tr( "WRN_WARNING" ),
- tr( "WRN_NO_PRINTERS" ) );
- return;
- }
-#endif
-#endif
-
// stored settings for further starts
static QString aPrinterName;
static int aColorMode = -1;
#include <QApplication>
#include <QDesktopWidget>
#include <QtDebug>
-#if QT_VERSION > QT_VERSION_CHECK(5, 0, 0)
#include <QSurfaceFormat>
-#endif
#include <stdio.h>
#include <stdlib.h>
#endif // WIN32
-
-#if QT_VERSION > QT_VERSION_CHECK(5, 0, 0)
/*!
\brief Set default QSurfaceFormat for an application.
QSurfaceFormat::setDefaultFormat(fmt);
}
-#endif
/*!
\class Qtx::CmdLineArgs
static void* getDisplay();
static Qt::HANDLE getVisual();
#endif
-
-#if QT_VERSION > QT_VERSION_CHECK(5, 0, 0)
static void initDefaultSurfaceFormat();
-#endif
};
#endif
void QtxDialog::emitSignal()
{
QApplication::instance()->processEvents();
-#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
- QApplication::syncX();
-#endif
int id = buttonId( (QAbstractButton*)mySender );
mySender = 0;
#include <QMenu>
#include <QVariant>
-#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
-
-/*!
- \brief Used for comparing of two QVariant values.
- \param v1 first argument for comparison
- \param v2 second argument for comparison
- \return \c true if \a v1 less than \a v2
-*/
-bool operator<( const QVariant& v1, const QVariant& v2 )
-{
- QVariant::Type t1 = v1.type(), t2 = v2.type();
- if ( t1 == t2 )
- {
- switch( t1 )
- {
- case QVariant::Int:
- return v1.toInt() < v2.toInt();
- case QVariant::Double:
- return v1.toDouble() < v2.toDouble();
- case QVariant::String:
- return v1.toString() < v2.toString();
- case QVariant::StringList:
- case QVariant::List:
- {
- const QList<QVariant>& aList1 = v1.toList(), aList2 = v2.toList();
- QList<QVariant>::const_iterator anIt1 = aList1.begin(), aLast1 = aList1.end(),
- anIt2 = aList2.begin(), aLast2 = aList2.end();
- for ( ; anIt1 != aLast1 && anIt2 != aLast2; anIt1++, anIt2++ )
- {
- if ( (*anIt1) != (*anIt2) )
- return (*anIt1) < (*anIt2);
- }
- return anIt1 == aLast1 && anIt2 != aLast2;
- }
- default:
- return v1.toString() < v2.toString();
- }
- }
- return t1 < t2;
-}
-
-#else
-
bool operator<( const QList<QVariant>& v1, const QList<QVariant>& v2 )
{
QList<QVariant>::const_iterator anIt1 = v1.begin(), aLast1 = v1.end(),
return anIt1 == aLast1 && anIt2 != aLast2;
}
-#endif // QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
-
/*!
\class QtxPopupMgr::PopupCreator
\internal
{
}
-#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
-
-/*!
- \brief Returns the translation for the key.
- \param context message context
- \param sourceText message source name
- \param disambiguation message comment (optional)
- \return Translated text if found or \a sourceText otherwise
-*/
-QString QtxTranslator::translate( const char* context, const char* sourceText, const char* disambiguation ) const
-{
- QString res = QTranslator::translate( context, sourceText, disambiguation );
- if ( res.isNull() )
- res = QTranslator::translate( GLOBAL_CONTEXT, sourceText, disambiguation );
- return res;
-}
-
-#else
-
/*!
\brief Returns the translation for the key.
\param context message context
return res;
}
-#endif // QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
public:
QtxTranslator( QObject* parent = 0 );
~QtxTranslator();
-#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
- virtual QString translate( const char*, const char*, const char* = 0 ) const;
-#else
virtual QString translate( const char*, const char*, const char* = 0, int = -1 ) const;
-#endif
};
#endif
QVariant appropriate = model()->headerData( i, orientation(), Qtx::AppropriateRole );
QIcon icon;
if ( iconData.isValid() ) {
-#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
- if ( iconData.canConvert( QVariant::Icon ) )
- icon = iconData.value<QIcon>();
- else if ( iconData.canConvert( QVariant::Pixmap ) )
- icon = iconData.value<QPixmap>();
-#else
if ( iconData.canConvert( QMetaType::QIcon ) )
icon = iconData.value<QIcon>();
else if ( iconData.canConvert( QMetaType::QPixmap ) )
icon = iconData.value<QPixmap>();
-#endif
}
if( ( !lab.isEmpty() || !icon.isNull() ) &&
appropriate.isValid() ? appropriate.toInt()==Qtx::Toggled : true )
}
else if ( a && a == sortAction ) {
setSortIndicatorShown( a->isChecked() );
-#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
- setClickable( a->isChecked() );
-#else
setSectionsClickable( a->isChecked() );
-#endif
QtxTreeView* view = qobject_cast<QtxTreeView*>( parent() );
if ( view ) {
view->emitSortingEnabled( a->isChecked() );
: QTreeView( parent )
{
setHeader( new Header( false, this ) );
-#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
- header()->setMovable( true );
-#else
header()->setSectionsMovable( true );
-#endif
}
/*!
: QTreeView( parent )
{
setHeader( new Header( enableSortMenu, this ) );
-#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
- header()->setMovable( true );
-#else
header()->setSectionsMovable( true );
-#endif
}
/*!
setWindowIcon( parent->windowIcon() );
// GDD
-#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
- myUrls.insert(0,QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::ApplicationsLocation)));
- myUrls.insert(0,QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::HomeLocation)));
-#else
myUrls.insert(0,QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::ApplicationsLocation)));
myUrls.insert(0,QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::HomeLocation)));
-#endif
+
setSidebarUrls(myUrls);
// add quick directories widgets
void SUIT_TreeModel::registerColumn( const int group_id, const QString& name, const int custom_id )
{
bool found = false;
-#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)
beginResetModel();
-#endif
for ( int i=0, n=myColumns.size(); i<n && !found; i++ ) {
if ( name == myColumns[i].myName ) {
myColumns[i].myIds.insert( group_id, custom_id );
int n = myColumns.size();
myColumns.resize( n+1 );
myColumns[n] = inf;
-#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)
endResetModel();
-#else
- reset();
-#endif
}
}
void SUIT_TreeModel::unregisterColumn( const int group_id, const QString& name )
{
for ( int i = 0, n = myColumns.size(); i < n; i++ ) {
-#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)
beginResetModel();
-#endif
if ( myColumns[i].myName == name ) {
myColumns[i].myIds.remove( group_id );
if ( myColumns[i].myIds.isEmpty() ) {
myColumns.remove( i );
-#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)
endResetModel();
-#else
- reset();
-#endif
}
break;
}
{
if ( root() == r )
return;
-
-#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)
beginResetModel();
-#endif
if ( autoDeleteTree() ) {
SUIT_DataObject::disconnect( SIGNAL( inserted( SUIT_DataObject*, SUIT_DataObject* ) ),
myRoot = r;
//initialize();
-#if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)
endResetModel();
-#else
- reset();
-#endif
emit modelUpdated();
}
QSize SUIT_ItemDelegate::sizeHint ( const QStyleOptionViewItem & option, const QModelIndex & index ) const
{
QSize size = QItemDelegate::sizeHint ( option, index );
-#if QT_VERSION >= 0x040500
size.setHeight( size.height() + 1 );
-#endif
return size;
}
}
}
-#if QT_VERSION > QT_VERSION_CHECK(5, 0, 0)
+
// RNV: setup the default format:
// QSurfaceFormat should be set before creation of QApplication,
// so to avoid conflicts beetween SALOME and ParaView QSurfaceFormats we should merge theirs formats
// (see void Qtx::initDefaultSurfaceFormat()) and set the resultant format here.
Qtx::initDefaultSurfaceFormat();
-#endif
// add <qtdir>/plugins directory to the pluins search path for image plugins
QString qtdir = Qtx::qtDir( "plugins" );
if ( !qtdir.isEmpty() )
QApplication::addLibraryPath( qtdir );
-
-// TODO (QT5 PORTING) Below is a temporary solution, to allow compiling with Qt 5
-#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
- //Set a "native" graphic system in case if application runs on the remote host
- QString remote(::getenv("REMOTEHOST"));
- QString client(::getenv("SSH_CLIENT"));
- if(remote.length() > 0 || client.length() > 0 ) {
- QApplication::setGraphicsSystem(QLatin1String("native"));
- }
-#endif
SUITApp_Application app( argc, argv );
QString cfgAppName = getAppName( argList.isEmpty() ? QString() : argList.first() );
Constructor
*/
SUITApp_Application::SUITApp_Application( int& argc, char** argv, SUIT_ExceptionHandler* hand )
-// TODO (QT5 PORTING) Below is a temporary solution, to allow compiling with Qt 5
-#if !defined(WIN32) && !defined(__APPLE__) && (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
- // san: Opening an X display and choosing a visual most suitable for 3D visualization
- // in order to make SALOME viewers work with non-native X servers
- : QApplication( (Display*)Qtx::getDisplay(), argc, argv, Qtx::getVisual() ),
-#else
: QApplication( argc, argv ),
-#endif
myExceptHandler( hand )
{
}
-/*!
- Constructor
-*/
-// TODO (QT5 PORTING) Below is a temporary solution, to allow compiling with Qt 5
-#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
-SUITApp_Application::SUITApp_Application( int& argc, char** argv, Type type, SUIT_ExceptionHandler* hand )
- : QApplication( argc, argv, type ),
-myExceptHandler( hand )
-{
-}
-#endif
/*!
Sends event to receiver
\return the value that is returned from the receiver's event handler
public:
SUITApp_Application( int&, char**, SUIT_ExceptionHandler* = 0 );
-// TODO (QT5 PORTING) Below is a temporary solution, to allow compiling with Qt 5
-#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
- SUITApp_Application( int&, char**, Type, SUIT_ExceptionHandler* = 0 );
-#endif
virtual bool notify( QObject* receiver, QEvent* e );
SUIT_ExceptionHandler* handler() const;
// Put Qt includes before the X11 includes which #define the symbol None
// (see SVTK_SpaceMouse.h) to avoid the compilation error.
#if !defined(WIN32) && !defined(__APPLE__)
-#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
#include <xcb/xcb.h>
-#endif
#include <QX11Info>
#endif
#include <QMouseEvent>
::~QVTK_RenderWindowInteractor()
{
#if !defined WIN32 && !defined __APPLE__
-#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
- SVTK_SpaceMouseX* aSpaceMouse = SVTK_SpaceMouseX::getInstance();
- if ( aSpaceMouse && aSpaceMouse->isSpaceMouseOn() )
- aSpaceMouse->close( QX11Info::display() );
-#else
SVTK_SpaceMouseXCB* aSpaceMouse = SVTK_SpaceMouseXCB::getInstance();
if ( aSpaceMouse && aSpaceMouse->isSpaceMouseOn() )
aSpaceMouse->close( QX11Info::connection() );
#endif
-#endif
}
#if !defined WIN32 && !defined __APPLE__
// register set space mouse events receiver
-#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
- SVTK_SpaceMouseX* aSpaceMouse = SVTK_SpaceMouseX::getInstance();
- if ( aSpaceMouse )
- {
- if ( !aSpaceMouse->isSpaceMouseOn() )
- // initialize 3D space mouse driver
- aSpaceMouse->initialize( QX11Info::display(), winId() );
- else
- aSpaceMouse->setWindow( QX11Info::display(), winId() );
- }
-#else
SVTK_SpaceMouseXCB* aSpaceMouse = SVTK_SpaceMouseXCB::getInstance();
if ( aSpaceMouse )
{
aSpaceMouse->setWindow( QX11Info::connection(), winId() );
}
#endif
-#endif
}
/*!
QWidget::focusOutEvent( event );
#if !defined WIN32 && !defined __APPLE__
-#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
- // unregister set space mouse events receiver
- SVTK_SpaceMouseX* aSpaceMouse = SVTK_SpaceMouseX::getInstance();
- if ( aSpaceMouse && aSpaceMouse->isSpaceMouseOn() )
- aSpaceMouse->setWindow( QX11Info::display(), 0 );
-#else
SVTK_SpaceMouseXCB* aSpaceMouse = SVTK_SpaceMouseXCB::getInstance();
if ( aSpaceMouse && aSpaceMouse->isSpaceMouseOn() )
aSpaceMouse->setWindow( QX11Info::connection(), 0 );
#endif
-#endif
-}
-
-// TODO (QT5 PORTING) Below is a temporary solution, to allow compiling with Qt 5
-#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
-#if defined(WIN32)
-
-/*!
- To handle native Win32 events (from such devices as SpaceMouse)
-*/
-bool QVTK_RenderWindowInteractor::winEvent( MSG* msg, long* result )
-{
- // TODO: Implement event handling for SpaceMouse
- return QWidget::winEvent( msg, result);
}
-#elif !defined(__APPLE__)
-/*!
- To handle native X11 events (from such devices as SpaceMouse)
-*/
-bool
-QVTK_RenderWindowInteractor
-::x11Event( XEvent *xEvent )
-{
- // handle 3d space mouse events
- if ( SVTK_SpaceMouseX* aSpaceMouse = SVTK_SpaceMouseX::getInstance() )
- {
- if ( aSpaceMouse->isSpaceMouseOn() && xEvent->type == ClientMessage )
- {
- SVTK_SpaceMouse::MoveEvent anEvent;
- int type = aSpaceMouse->translateEvent( QX11Info::display(), xEvent, &anEvent, 1.0, 1.0 );
- switch ( type )
- {
- case SVTK_SpaceMouse::SpaceMouseMove:
- GetDevice()->InvokeEvent( SVTK::SpaceMouseMoveEvent, anEvent.data );
- break;
- case SVTK_SpaceMouse::SpaceButtonPress:
- GetDevice()->InvokeEvent( SVTK::SpaceMouseButtonEvent, &anEvent.button );
- break;
- case SVTK_SpaceMouse::SpaceButtonRelease:
- break;
- }
- return true; // stop handling the event
- }
- }
-
- return QWidget::x11Event( xEvent );
-}
-
-#endif
-
-#else // QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
-
bool QVTK_RenderWindowInteractor
::nativeEvent(const QByteArray& eventType, void* message, long* result)
{
if ( eventType == "xcb_generic_event_t" )
{
xcb_generic_event_t* ev = static_cast<xcb_generic_event_t *>(message);
-#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
- // TODO: this code is never called
- if ( SVTK_SpaceMouseX* aSpaceMouse = SVTK_SpaceMouseX::getInstance() )
-#else
if ( SVTK_SpaceMouseXCB* aSpaceMouse = SVTK_SpaceMouseXCB::getInstance() )
-#endif
{
if ( aSpaceMouse->isSpaceMouseOn() && ev->response_type == XCB_CLIENT_MESSAGE )
{
SVTK_SpaceMouse::MoveEvent anEvent;
-#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
- // TODO: this code is never called
- int type = aSpaceMouse->translateEvent( QX11Info::display(), xEvent, &anEvent, 1.0, 1.0 );
-#else
int type = aSpaceMouse->translateEvent( QX11Info::connection(), (xcb_client_message_event_t*)ev, &anEvent, 1.0, 1.0 );
-#endif
switch ( type )
{
case SVTK_SpaceMouse::SpaceMouseMove:
#endif
return QWidget::nativeEvent( eventType, message, result );
}
-#endif
+
/*!
Constructor
*/
virtual void focusOutEvent( QFocusEvent* );
//! To handle native events (from such devices as SpaceMouse)
-// TODO (QT5 PORTING) Below is a temporary solution, to allow compiling with Qt 5
-#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
-#if defined(WIN32)
- virtual bool winEvent( MSG*, long* );
-#elif !defined(__APPLE__)
- virtual bool x11Event( XEvent *e );
-#endif
-#else
virtual bool nativeEvent( const QByteArray&, void*, long* );
-#endif
vtkSmartPointer<vtkRenderWindow> myRenderWindow;
vtkSmartPointer<vtkGenericRenderWindowInteractor> myDevice;
};
#include <X11/Xutil.h>
#include <X11/Xatom.h>
#include <X11/keysym.h>
-#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
-#include <X11/Xlib.h>
-#else
#include <xcb/xcb.h>
#endif
-#endif
#include "SVTK_SpaceMouse.h"
-#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
-SVTK_SpaceMouseX* SVTK_SpaceMouseX::myInstance = 0;
-#else
SVTK_SpaceMouseXCB* SVTK_SpaceMouseXCB::myInstance = 0;
-#endif
/*!
Constructor
{
spaceMouseOn = 0;
}
-#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
-/*!
- Constructor
-*/
-SVTK_SpaceMouseX::SVTK_SpaceMouseX()
-: SVTK_SpaceMouse()
-{
-#if !defined WIN32 && !defined __APPLE__
- win = InputFocus;
-#endif
-}
-
-/*!
- \return shared instance of object (creates if there is no one)
-*/
-SVTK_SpaceMouseX* SVTK_SpaceMouseX::getInstance()
-{
- if ( !myInstance )
- myInstance = new SVTK_SpaceMouseX();
- return myInstance;
-}
-
-#if !defined WIN32 && !defined __APPLE__
-
-static int errorCallback( Display *display, XErrorEvent *Error )
-{
- char msg[ 128 ];
- if ( Error->error_code != BadWindow ) {
- XGetErrorText( display,Error->error_code,msg,sizeof( msg ) );
- fprintf( stderr, "SpaceMouse reported error = %s. Exit ... \n", msg );
- }
- return 0;
-}
-
-/*!
- Initialization
-*/
-int SVTK_SpaceMouseX::initialize( Display *display, Window window )
-{
- XMotionEvent = XInternAtom( display, "MotionEvent", 1 );
- XButtonPressEvent = XInternAtom( display, "ButtonPressEvent", 1 );
- XButtonReleaseEvent = XInternAtom( display, "ButtonReleaseEvent", 1 );
- XCommandEvent = XInternAtom( display, "CommandEvent", 1 );
-
- spaceMouseOn = (XMotionEvent != 0) &&
- (XButtonPressEvent != 0) &&
- (XButtonReleaseEvent != 0) &&
- (XCommandEvent != 0);
- if ( !spaceMouseOn )
- return 0;
-
- spaceMouseOn = setWindow( display, window );
- if ( !spaceMouseOn )
- return 0;
-
- return spaceMouseOn;
-}
-
-/*!
- Initialize by window
-*/
-int SVTK_SpaceMouseX::setWindow( Display *display, Window window )
-{
- XTextProperty winName;
- XEvent xEvent;
- Atom type;
- int format;
- unsigned long NItems, BytesReturn;
- unsigned char *PropReturn;
- Window root;
- int (*errorHandler)(Display *,XErrorEvent *);
-
- errorHandler = XSetErrorHandler( errorCallback );
-
- root = RootWindow( display, DefaultScreen(display) );
-
- PropReturn = NULL;
- XGetWindowProperty( display, root, XCommandEvent, 0,1, 0,
- AnyPropertyType, &type, &format, &NItems,
- &BytesReturn, &PropReturn );
-
- win = InputFocus;
- if ( PropReturn != NULL ) {
- win = *(Window *) PropReturn;
- XFree( PropReturn );
- }
- else
- return 0;
-
- if ( XGetWMName( display, win, &winName ) == 0 )
- return 0;
-
- if ( strcmp( (char *) "Magellan Window", (char *) winName.value) != 0 )
- return 0;
-
- xEvent.type = ClientMessage;
- xEvent.xclient.format = 16;
- xEvent.xclient.send_event = 0;
- xEvent.xclient.display = display;
- xEvent.xclient.window = win;
- xEvent.xclient.message_type = XCommandEvent;
-
- xEvent.xclient.data.s[0] = (short) ((window>>16)&0x0000FFFF);
- xEvent.xclient.data.s[1] = (short) (window&0x0000FFFF);
- xEvent.xclient.data.s[2] = 27695;
-
- if ( XSendEvent( display, win, 0, 0x0000, &xEvent ) == 0 )
- return 0;
-
- XFlush( display );
-
- XSetErrorHandler( errorHandler );
- return 1;
-}
-
-/*!
- Close
-*/
-int SVTK_SpaceMouseX::close(Display *display)
-{
- initialize( display, (Window)InputFocus );
- spaceMouseOn = 0;
-
- return 1;
-}
-
-/*!
- Custom event handler
-*/
-int SVTK_SpaceMouseX::translateEvent( Display* display, XEvent* xEvent, MoveEvent* spaceMouseEvent,
- double scale, double rScale )
-{
- if ( !spaceMouseOn )
- return 0;
-
- if ( xEvent->type == ClientMessage ) {
- if ( xEvent->xclient.message_type == XMotionEvent ) {
- spaceMouseEvent->type = SpaceMouseMove;
- spaceMouseEvent->data[ x ] =
- xEvent->xclient.data.s[2] * scale;
- spaceMouseEvent->data[ y ] =
- xEvent->xclient.data.s[3] * scale;
- spaceMouseEvent->data[ z ] =
- xEvent->xclient.data.s[4] * scale;
- spaceMouseEvent->data[ a ] =
- xEvent->xclient.data.s[5] * rScale;
- spaceMouseEvent->data[ b ] =
- xEvent->xclient.data.s[6] * rScale;
- spaceMouseEvent->data[ c ] =
- xEvent->xclient.data.s[7] * rScale;
- spaceMouseEvent->period = xEvent->xclient.data.s[8];
- return 1;
- }
- else if ( xEvent->xclient.message_type == XButtonPressEvent ) {
- spaceMouseEvent->type = SpaceButtonPress;
- spaceMouseEvent->button = xEvent->xclient.data.s[2];
- return 2;
- }
- else if ( xEvent->xclient.message_type == XButtonReleaseEvent ) {
- spaceMouseEvent->type = SpaceButtonRelease;
- spaceMouseEvent->button = xEvent->xclient.data.s[2];
- return 3;
- }
- }
- return (!display);
-}
-#endif
-#else
/*!
Constructor
return (!connection);
}
#endif
-#endif
extern "C"
{
#include <X11/X.h>
-#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
-#include <X11/Xlib.h>
-#else
#include <xcb/xcb.h>
-#endif
}
#endif
int spaceMouseOn;
};
-#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
-
-class SVTK_SpaceMouseX: public SVTK_SpaceMouse
-{
-
-public:
- SVTK_SpaceMouseX();
-
- // access to SpaceMouse utility class
- static SVTK_SpaceMouseX* getInstance();
-
-#if !defined WIN32 && !defined __APPLE__
- int initialize ( Display*, Window );
- int setWindow ( Display*, Window );
- int translateEvent ( Display*, XEvent*, MoveEvent*, double, double );
- int close ( Display* );
-
-private:
- Atom XMotionEvent;
- Atom XButtonPressEvent;
- Atom XButtonReleaseEvent;
- Atom XCommandEvent;
- Window win;
-#endif
-
- static SVTK_SpaceMouseX* myInstance;
-
-};
-
-#else
-
class SVTK_SpaceMouseXCB: public SVTK_SpaceMouse
{
};
#endif
-#endif
setRootIsDecorated(false);
setAllColumnsShowFocus(false);
// header()->setClickEnabled(false);
-#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
- header()->setMovable(false);
-#else
header()->setSectionsMovable(false);
-#endif
myEditedItem = 0;
myEdit = 0;
public:
SALOME_QApplication( int& argc, char** argv )
// TODO (QT5 PORTING) Below is a temporary solution, to allow compiling with Qt 5
-#if !defined(WIN32) && !defined(__APPLE__) && (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
- // san: Opening an X display and choosing a visual most suitable for 3D visualization
- // in order to make SALOME viewers work with non-native X servers
- : QApplication( (Display*)Qtx::getDisplay(), argc, argv, Qtx::getVisual() ),
-#else
: QApplication( argc, argv ),
-#endif
myHandler ( 0 ) {}
virtual bool notify( QObject* receiver, QEvent* e )
SessionMsgHandler msgHandler;
qInstallMessageHandler(QtxMsgHandler);
-// TODO (QT5 PORTING) Below is a temporary solution, to allow compiling with Qt 5
-#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
- //Set a "native" graphic system in case if application runs on the remote host
- QString remote(getenv("REMOTEHOST"));
- QString client(getenv("SSH_CLIENT"));
- if(remote.length() > 0 || client.length() > 0 ) {
- QApplication::setGraphicsSystem(QLatin1String("native"));
- }
-#endif
-
// add <qtdir>/plugins dir to the pluins search path for image plugins
QString qtdir = Qtx::qtDir( "plugins" );
if ( !qtdir.isEmpty() )
}
}
-#if QT_VERSION > QT_VERSION_CHECK(5, 0, 0)
-
// RNV: setup the default format:
// QSurfaceFormat should be set before creation of QApplication,
// so to avoid conflicts beetween SALOME and ParaView QSurfaceFormats we should merge theirs formats
// (see void Qtx::initDefaultSurfaceFormat()) and set the resultant format here.
Qtx::initDefaultSurfaceFormat();
-#endif
// Create Qt application instance;
// this should be done the very first!
p->setPen(opt->palette.text().color());
} // Fall through!
case PE_IndicatorViewItemCheck:
-#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
- case PE_Q3CheckListIndicator:
-#endif
{
if (!doRestore) {
p->save();
const QWidget* w ) const
{
if ( checkDebugLevel(10) ) {
-#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
- return BaseStyle::standardIconImplementation( standardIcon, opt, w );
-#else
return QCommonStyle::standardIcon( standardIcon, opt, w );
-#endif
}
switch ( standardIcon )
default:
break;
}
-#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
- return BaseStyle::standardIconImplementation( standardIcon, opt, w );
-#else
return BaseStyle::standardIcon( standardIcon, opt, w );
-#endif
}
/*!
#include <QtGlobal>
#include "Style.h"
-#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
-#include <QWindowsStyle>
-#define BaseStyle QWindowsStyle
-#else
#include <QCommonStyle>
#define BaseStyle QCommonStyle
-#endif
+
class Style_Model;
class QApplication;