#ifndef STD_H
#define STD_H
-#if defined STD_EXPORTS
#if defined WIN32
-#define STD_EXPORT __declspec( dllexport )
+# if defined STD_EXPORTS
+# define STD_EXPORT __declspec( dllexport )
+# else
+# define STD_EXPORT __declspec( dllimport )
+# endif
#else
-#define STD_EXPORT
-#endif
-#else
-#if defined WIN32
-#define STD_EXPORT __declspec( dllimport )
-#else
-#define STD_EXPORT
-#endif
+# define STD_EXPORT
#endif
#if defined SOLARIS
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
+// File : SUIT.h
+// Author :
+//
+
#ifndef SUIT_H
#define SUIT_H
-#if defined SUIT_EXPORTS
-#if defined WIN32
-#define SUIT_EXPORT __declspec( dllexport )
-#else
-#define SUIT_EXPORT
-#endif
-#else
#if defined WIN32
-#define SUIT_EXPORT __declspec( dllimport )
+# if defined SUIT_EXPORTS
+# define SUIT_EXPORT __declspec( dllexport )
+# else
+# define SUIT_EXPORT __declspec( dllimport )
+# endif
#else
-#define SUIT_EXPORT
-#endif
+# define SUIT_EXPORT
#endif
#if defined SOLARIS
#define SUIT_ASSERT(x)
#endif
-#endif
+#endif // SUIT_H
CONFIG += qt thread debug dll shared
win32:DEFINES += WNT WIN32
-DEFINES += SUIT_EXPORTS
+DEFINES += SUIT_EXPORTS DISABLE_TESTRECORDER
HEADERS = *.h
#include <QTimer>
#include <QLabel>
#include <QStatusBar>
+#include <QApplication>
+#include <QSize>
#include <QtxAction.h>
#include <QtxActionMenuMgr.h>
#include <QtxActionToolMgr.h>
+/*!
+ \class StatusLabel
+ \brief Status bar customization label. Used to workaroubd desktop resizing bug.
+ \internal
+*/
+class StatusLabel : public QLabel
+{
+public:
+ StatusLabel( QWidget* parent ) : QLabel( parent ) {}
+ QSize minimumSizeHint () const { return QSize( 0, QLabel::minimumSizeHint().height() ); }
+};
+
/*!
Default constructor
*/
SUIT_Application::SUIT_Application()
: QObject( 0 ),
-myStudy( 0 ),
-myDesktop( 0 ),
-myStatusLabel( 0 )
+ myStudy( 0 ),
+ myDesktop( 0 ),
+ myStatusLabel( 0 )
{
if ( SUIT_Session::session() )
SUIT_Session::session()->insertApplication( this );
*/
SUIT_Application::~SUIT_Application()
{
- delete myStudy;
- myStudy = 0;
+ SUIT_Study* s = myStudy;
+ setActiveStudy( 0 );
+ delete s;
setDesktop( 0 );
}
\return FALSE if application can not be closed (because of non saved data for example).
This method called by SUIT_Session whin closing of application was requested.
*/
-bool SUIT_Application::isPossibleToClose( bool& closePermanently )
+bool SUIT_Application::isPossibleToClose( bool& )
{
return true;
}
*/
QString SUIT_Application::applicationVersion() const
{
- return QString::null;
+ return QString();
}
/*!
return status;
}
-/*!
- Opens other study into active Study. If Study is empty - creates it.
- \param theName - name of study
-*/
-bool SUIT_Application::useStudy( const QString& /*theName*/ )
-{
- return false;
-}
-
/*!
Creates new empty Study if active Study = 0
*/
if ( !myStatusLabel )
{
- myStatusLabel = new QLabel( desktop()->statusBar() );
+ myStatusLabel = new StatusLabel( desktop()->statusBar() );
desktop()->statusBar()->addWidget( myStatusLabel, 1 );
myStatusLabel->show();
}
bool changed = !myStatusLabel->text().isEmpty();
myStatusLabel->clear();
if ( changed )
- emit infoChanged( QString::null );
+ emit infoChanged( QString() );
+}
+
+/*!
+ Update status of the registerd actions
+*/
+void SUIT_Application::updateCommandsStatus()
+{
}
/*!
delete myDesktop;
myDesktop = desk;
- if ( myDesktop )
+ if ( myDesktop ) {
connect( myDesktop, SIGNAL( activated() ), this, SLOT( onDesktopActivated() ) );
+ // Force desktop activation (NPAL16628)
+ QApplication::postEvent(myDesktop, new QEvent(QEvent::WindowActivate));
+ }
}
/*!
if ( myStudy == study )
return;
+ if ( myStudy )
+ disconnect( myStudy, SIGNAL( studyModified( SUIT_Study* ) ),
+ this, SLOT( updateCommandsStatus() ) );
+ if ( study )
+ connect( study, SIGNAL( studyModified( SUIT_Study* ) ),
+ this, SLOT( updateCommandsStatus() ) );
+
myStudy = study;
}
return id;
}
+QList<QAction*> SUIT_Application::actions() const
+{
+ return myActionMap.values();
+}
+
+QList<int> SUIT_Application::actionIds() const
+{
+ return myActionMap.keys();
+}
+
/*!
Creates action and registers it both in menu manager and tool manager
\return new instance of action
{
emit activated( this );
}
+
+/*!
+ SLOT: is used for Help browsing
+*/
+void SUIT_Application::onHelpContextModule( const QString& /*theComponentName*/,
+ const QString& /*theFileName*/,
+ const QString& /*theContext*/ )
+{
+}
//! Opens document <theFileName> into active Study. If Study is empty - creates it.
virtual bool useFile( const QString& theFileName);
- //! Loads document <theName> into active Study. If Study is empty - creates it.
- virtual bool useStudy( const QString& theName);
-
//! Creates new empty Study if active Study = 0
virtual void createEmptyStudy();
void activated( SUIT_Application* );
void infoChanged( QString );
+public slots:
+ virtual void updateCommandsStatus();
+ virtual void onHelpContextModule( const QString&, const QString&, const QString& = QString() );
+
private slots:
void onInfoClear();
static QAction* separator();
QAction* action( const int ) const;
int actionId( const QAction* ) const;
+
+ QList<QAction*> actions() const;
+ QList<int> actionIds() const;
+
int registerAction( const int, QAction* );
QAction* createAction( const int, const QString&, const QIcon&, const QString&,
const QString&, const int, QObject* = 0,
#include "SUIT_MessageBox.h"
+#ifndef DISABLE_TESTRECORDER
+ #include <TestApplication.h>
+#endif
+
#include <QApplication>
/*!\class SUIT_ExceptionHandler
*/
bool SUIT_ExceptionHandler::internalHandle( QObject* o, QEvent* e )
{
+#ifndef DISABLE_TESTRECORDER
+ TestApplication* aTApp = qobject_cast<TestApplication*>(qApp);
+ return aTApp ? aTApp->TestApplication::notify( o, e ) : false;
+#else
return qApp ? qApp->QApplication::notify( o, e ) : false;
+#endif
}
/*!
--- /dev/null
+// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "SUIT_LicenseDlg.h"
+
+#include <QApplication>
+#include <QTextEdit>
+#include <QLayout>
+#include <QPushButton>
+#include <QTextStream>
+#include <QFile>
+#include <QPrinter>
+//#include <QSimpleRichText>
+#include <QTextDocument>
+#include <QPainter>
+
+#include <math.h>
+
+#ifdef WIN32
+#include <UserEnv.h>
+#endif
+
+
+/*!
+ Constructor
+ Construct a dialog with specified parent and name.
+ \param modal define modal status of dialog (default modal dialog created).
+*/
+SUIT_LicenseDlg::SUIT_LicenseDlg( bool firstShow, QWidget* parent, const char* name, bool modal )
+ : QDialog( parent )
+{
+ setObjectName( name );
+ setModal( modal );
+ QString env;
+ if ( ::getenv( "TRIPOLI_ROOT_DIR" ) )
+ env = ::getenv( "TRIPOLI_ROOT_DIR" );
+
+ QFile file( env + "/share/salome/resources/License.txt" ); // Read the text from a file
+
+ if ( !file.exists() || !file.open( QIODevice::ReadOnly ) )
+ return;
+
+ setWindowTitle( tr( "License" ) );
+
+ // Create text editor
+ myTextEdit = new QTextEdit( this );
+ QTextStream stream( &file );
+ myTextEdit->setText( stream.readAll() );
+ file.close();
+ myTextEdit->setReadOnly( true );
+ //myTextEdit->ensureVisible(0, 0);
+
+ // Create buttons
+ QPushButton* anAgreeBtn = new QPushButton( tr( "Agree" ), this );
+ if (firstShow) {
+ anAgreeBtn->setAutoDefault( true );
+ anAgreeBtn->setFocus();
+ }
+ else
+ anAgreeBtn->hide();
+
+ QPushButton* aCancelBtn = new QPushButton( this );
+ aCancelBtn->setText( firstShow ? tr( "Cancel" ) : tr( "Close" ) );
+ if ( !firstShow )
+ aCancelBtn->setFocus();
+
+ QPushButton* aPrintBtn = new QPushButton( tr( "Print..." ), this );
+
+ // Layouting
+ QVBoxLayout* aBaseLayout = new QVBoxLayout( this );
+ aBaseLayout->setMargin( 5 );
+ aBaseLayout->setSpacing( 5 );
+ aBaseLayout->addWidget( myTextEdit );
+
+ QHBoxLayout* aButtonsLayout = new QHBoxLayout();
+ aBaseLayout->addLayout( aButtonsLayout );
+ if (firstShow)
+ aButtonsLayout->addWidget( anAgreeBtn );
+
+ aButtonsLayout->addWidget( aCancelBtn );
+ aButtonsLayout->addStretch();
+ aButtonsLayout->addWidget( aPrintBtn );
+
+ // Connections
+ connect( anAgreeBtn, SIGNAL( clicked() ), this, SLOT( onAgree( ) ) );
+ connect( aCancelBtn, SIGNAL( clicked() ), this, SLOT( onCancel( ) ) );
+ connect( aPrintBtn, SIGNAL( clicked() ), this, SLOT( onPrint( ) ) );
+
+ resize( 640, 480 );
+}
+
+/*!
+ Name: ~SUIT_LicenseDlg [public]
+ Desc: Destructor
+*/
+
+SUIT_LicenseDlg::~SUIT_LicenseDlg()
+{
+}
+
+void SUIT_LicenseDlg::onAgree()
+{
+ QString env;
+#ifdef WIN32
+ DWORD aLen=1024;
+ char aStr[1024];
+ HANDLE aToken=0;
+ HANDLE hProcess = GetCurrentProcess();
+ OpenProcessToken(hProcess,TOKEN_QUERY,&aToken);
+ if( ! GetUserProfileDirectory( aToken, aStr, &aLen ) )
+ reject();
+
+ env = aStr;
+#else
+ if( ! ::getenv( "HOME" ) )
+ reject();
+ env = ::getenv( "HOME" );
+#endif
+
+ QFile file( env + "/ReadLicense.log" ); // Read the text from a file
+
+ file.open( QIODevice::WriteOnly );
+
+ QTextStream ts( &file );
+ ts << "OK" << endl;
+ //file.writeBlock( "OK", (Q_ULONG)qstrlen( "OK" ) );
+ file.close();
+
+ accept();
+}
+
+void SUIT_LicenseDlg::onCancel()
+{
+ reject();
+}
+
+void SUIT_LicenseDlg::onPrint()
+{
+ QPrinter aPrinter( QPrinter::HighResolution );
+ aPrinter.setFullPage(true);
+
+ if ( true /*aPrinter.pageSetup( this )*/ ) {
+ QPainter aPainter( &aPrinter );
+ if( !aPainter.isActive() ) // starting printing failed
+ return;
+
+ // define fonts
+ QFont aBodyFont = myTextEdit->currentFont();
+ QFont aFooterFont = aBodyFont;
+
+ // calculate margin
+ QPaintDevice* aMetrics(aPainter.device());
+ int aDpiY = aMetrics->logicalDpiY();
+ int aMargin = (int) ( (2/2.54)*aDpiY ); // 2 cm margins
+
+ QRect aBody( aMargin, aMargin, aMetrics->width() - 2*aMargin, aMetrics->height() - 2*aMargin );
+
+ // convert text to rich text format
+ QString aFormattedText = Qt::convertFromPlainText( myTextEdit->toPlainText() );
+
+ QTextDocument aRichText( aFormattedText );
+ aRichText.setDefaultFont( aBodyFont );
+
+
+ /*QSimpleRichText aRichText( aFormattedText,
+ aBodyFont,
+ myTextEdit->context(),
+ myTextEdit->styleSheet(),
+ myTextEdit->mimeSourceFactory(),
+ aBody.height() );
+ */
+ aRichText.setPageSize( QSize( aBody.width(), aRichText.pageSize().height() ) );
+ //aRichText.setWidth( &aPainter, aBody.width() );
+
+ QRect aView( aBody );
+
+ int aPageIndex = 1;
+
+ do {
+ // print page text
+ aRichText.drawContents( &aPainter, aView );
+ //aRichText.draw( &aPainter, aBody.left(), aBody.top(), aView, colorGroup() );
+ aView.translate( 0, aBody.height() );
+ aPainter.translate( 0 , -aBody.height() );
+
+ // print page number
+ aPainter.setPen(Qt::gray);
+ aPainter.setFont(aFooterFont);
+ QString aFooter = QString("Page ") + QString::number(aPageIndex);
+ aPainter.drawText( aView.right() - aPainter.fontMetrics().width( aFooter ),
+ aView.bottom() + aPainter.fontMetrics().ascent() + 5, aFooter );
+
+ if ( aView.top() >= aRichText.size().height() )
+ break;
+ aPrinter.newPage();
+ aPageIndex++;
+ } while (true);
+ }
+}
--- /dev/null
+// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+
+#ifndef SUIT_LICENSEDLG_H
+#define SUIT_LICENSEDLG_H
+
+#include "SUIT.h"
+
+#include <QDialog>
+class QTextEdit;
+
+#ifdef WIN32
+#pragma warning( disable:4251 )
+#endif
+
+class SUIT_EXPORT SUIT_LicenseDlg :public QDialog
+{
+ Q_OBJECT
+public:
+ SUIT_LicenseDlg( bool firstShow = true, QWidget* = 0, const char* = 0, bool = true );
+ virtual ~SUIT_LicenseDlg();
+
+private slots:
+ void onAgree();
+ void onCancel();
+ void onPrint();
+
+private:
+ QTextEdit* myTextEdit;
+};
+
+#ifdef WIN32
+#pragma warning( default:4251 )
+#endif
+
+#endif
*/
QString SUIT_Operation::operationName() const
{
- return QString::null;
+ return QString();
}
/*!
virtual bool openTransaction();
virtual bool abortTransaction();
virtual bool hasTransaction() const;
- virtual bool commitTransaction( const QString& = QString::null );
+ virtual bool commitTransaction( const QString& = QString() );
void setExecStatus( const int );
class SUIT_EXPORT SUIT_ResourceMgr : public QtxResourceMgr
{
public:
- SUIT_ResourceMgr( const QString&, const QString& = QString::null );
+ SUIT_ResourceMgr( const QString&, const QString& = QString() );
virtual ~SUIT_ResourceMgr();
virtual QString version() const;
{
for ( SelectorList::iterator it = mySelectors.begin(); it != mySelectors.end(); ++it )
{
- if ( *it != sel )
+ // Temporary action(to avoid selection of the objects which don't pass the filters):
+ //if ( *it != sel )
(*it)->setSelected( newOwners );
}
}
virtual ~SUIT_SelectionMgr();
void clearSelected();
- virtual void selected( SUIT_DataOwnerPtrList&, const QString& = QString::null ) const;
+ virtual void selected( SUIT_DataOwnerPtrList&, const QString& = QString() ) const;
virtual void setSelected( const SUIT_DataOwnerPtrList&, const bool = false );
void selectors( QList<SUIT_Selector*>& ) const;
void selectors( const QString&, QList<SUIT_Selector*>& ) const;
- void setEnabled( const bool, const QString& = QString::null );
+ void setEnabled( const bool, const QString& = QString() );
bool hasSelectionMode( const int ) const;
SUIT_Session::SUIT_Session()
: QObject(),
-myResMgr( 0 ),
-myActiveApp( 0 ),
-myHandler( 0 ),
-myExitStatus( FROM_GUI )
+ myResMgr( 0 ),
+ myActiveApp( 0 ),
+ myHandler( 0 ),
+ myExitStatus( NORMAL ),
+ myExitFlags ( 0 )
{
SUIT_ASSERT( !mySession )
if ( myAppList.isEmpty() )
{
- printf( "Calling QApplication::exit() with exit code = %d\n", myExitStatus );
+ //printf( "Calling QApplication::exit() with exit code = %d\n", myExitStatus );
QApplication::instance()->exit( myExitStatus );
}
}
/*!
Destroys session by closing all applications.
*/
-void SUIT_Session::closeSession( int mode )
+void SUIT_Session::closeSession( int mode, int flags )
{
AppList apps = myAppList;
for ( AppList::const_iterator it = apps.begin(); it != apps.end(); ++it )
}
else if ( mode == DONT_SAVE )
{
- myExitStatus = FROM_CORBA_SESSION;
- //....
+ myExitStatus = FORCED;
}
app->closeApplication();
}
+
+ myExitFlags = flags;
+}
+
+/*!
+ Get session exit flags.
+
+ By default, exit flags are set to 0. You can use pass any flags to the
+ closeSession() method if you need to process them later on application
+ quiting.
+
+ \return exit flags
+*/
+int SUIT_Session::exitFlags() const
+{
+ return myExitFlags;
}
/*! \retval return myHandler*/
typedef LIB_HANDLE AppLib;
enum { ASK = 0, SAVE, DONT_SAVE } CloseMode;
- enum { FROM_GUI = 0, FROM_CORBA_SESSION } ExitStatus;
+ enum { NORMAL = 0, FORCED } ExitStatus;
public:
SUIT_Session();
SUIT_ResourceMgr* resourceMgr() const;
- void closeSession( int mode = ASK );
+ void closeSession( int mode = ASK, int flags = 0 );
+ int exitFlags() const;
SUIT_ExceptionHandler* handler() const;
static SUIT_Session* mySession;
int myExitStatus;
+ int myExitFlags;
};
#endif
myIsModified = on;
}
+/*!
+ Set study modified to \a on.
+ */
+void SUIT_Study::Modified()
+{
+ setIsModified( true );
+ sendChangesNotification();
+}
+
/*!
Set root object.
*/
return 0;
Operations tmpOps( myOperations );
- for ( Operations::const_iterator it = tmpOps.end(); it != tmpOps.begin(); --it )
+ for ( Operations::const_iterator it = tmpOps.end(); it != tmpOps.begin(); )
{
+ it--;
SUIT_Operation* anOp = *it;
if ( anOp != 0 && anOp!= theOp && !anOp->isValid( theOp ) )
return anOp;
}
/*!
- * \brief Stores the study state
-*/
-int SUIT_Study::storeState()
-{
- return -1;
-}
-
-/*!
- * \brief Restores the study state
-*/
+ * \brief Restores the study state.
+ */
void SUIT_Study::restoreState(int /*savePoint*/)
{
}
virtual bool isSaved() const;
virtual bool isModified() const;
+ virtual void Modified();
virtual void closeDocument( bool = true );
virtual bool openDocument( const QString& );
bool suspend( SUIT_Operation* );
bool resume( SUIT_Operation* );
- virtual int storeState();
virtual void restoreState(int savePoint);
signals:
virtual void setRoot( SUIT_DataObject* );
virtual void setStudyName( const QString& );
- virtual void operationStarted( SUIT_Operation* );
- virtual void operationAborted( SUIT_Operation* );
- virtual void operationStopped( SUIT_Operation* );
- virtual void operationCommited( SUIT_Operation* );
+ virtual void operationStarted( SUIT_Operation* );
+ virtual void operationAborted( SUIT_Operation* );
+ virtual void operationStopped( SUIT_Operation* );
+ virtual void operationCommited( SUIT_Operation* );
virtual bool openTransaction();
virtual bool abortTransaction();
virtual bool hasTransaction() const;
- virtual bool commitTransaction( const QString& = QString::null );
+ virtual bool commitTransaction( const QString& = QString() );
private:
typedef QList<SUIT_Operation*> Operations;
return aView;
}
+/*! Get identifier */
+int SUIT_ViewManager::getId() const
+{
+ return myId;
+}
+
/*!Create view window.*/
void SUIT_ViewManager::createView()
{
virtual void setShown( const bool );
virtual void setDestructiveClose( const bool );
+ int getId() const;
+
public slots:
void createView();
void closeAllViews();
#include "SUIT_MessageBox.h"
#include "SUIT_Application.h"
#include "SUIT_ViewManager.h"
-
+#include "QtxActionToolMgr.h"
#include "Qtx.h"
#include <QEvent>
#include <QIcon>
#include <QApplication>
#include <QContextMenuEvent>
-#include <QPrintDialog>
-#include <QPrinter>
#include <QPainter>
-
+#include <QPrinter>
+#include <QPrintDialog>
/*!\class SUIT_ViewWindow
* Class provide view window.
/*! Constructor.*/
SUIT_ViewWindow::SUIT_ViewWindow( SUIT_Desktop* theDesktop )
-: QMainWindow( theDesktop ), myManager( 0 )
+: QMainWindow( theDesktop )
{
myDesktop = theDesktop;
setWindowIcon( myDesktop->windowIcon() );
setAttribute( Qt::WA_DeleteOnClose );
+
+ myToolMgr = new QtxActionToolMgr( this );
}
/*! Destructor.*/
return dumpViewToFormat( dumpView(), fileName, format );
}
+/*!
+ Prints given image
+ \param theImage - the image to print
+*/
+void SUIT_ViewWindow::printImage( const QImage& theImage, QWidget* theWidget )
+{
+ if ( theImage.isNull() )
+ 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 anOrientation = -1;
+
+ QPrinter aPrinter;
+
+ // restore settinds from previous launching
+
+ // printer name
+ if ( !aPrinterName.isEmpty() )
+ aPrinter.setPrinterName( aPrinterName );
+ else
+ {
+ // Nothing to do for the first printing. aPrinter contains default printer name by default
+ }
+
+ if ( anOrientation >= 0 )
+ aPrinter.setOrientation( (QPrinter::Orientation)anOrientation );
+ else
+ aPrinter.setOrientation( QPrinter::Landscape );
+
+
+ QPrintDialog printDlg( &aPrinter, theWidget );
+ printDlg.setPrintRange( QAbstractPrintDialog::AllPages );
+ if ( printDlg.exec() != QDialog::Accepted )
+ return;
+
+ // store printer settings for further starts
+ aPrinterName = aPrinter.printerName();
+ anOrientation = aPrinter.orientation();
+
+ int W, H;
+ QPainter aPainter;
+
+ // work arround for printing on real printer
+ if ( aPrinter.outputFileName().isEmpty() && aPrinter.orientation() == QPrinter::Landscape )
+ {
+ aPrinter.setFullPage( true );
+ // set paper orientation and rotate painter
+ aPrinter.setOrientation( QPrinter::Portrait );
+
+ W = aPrinter.height();
+ H = aPrinter.width();
+
+ int wBorder = aPrinter.paperRect().height() - W;
+ int hBorder = aPrinter.paperRect().width() - H;
+
+ aPainter.begin( &aPrinter );
+ aPainter.translate( QPoint( H + hBorder, wBorder ) );
+ aPainter.rotate( 90 );
+ }
+ else
+ {
+ aPrinter.setFullPage( false );
+ aPainter.begin( &aPrinter );
+ W = aPrinter.width();
+ H = aPrinter.height();
+ }
+
+ QImage anImage = theImage;
+ if ( anImage.width() > W || anImage.height() > H )
+ anImage = anImage.scaled( W, H, Qt::KeepAspectRatio, Qt::SmoothTransformation );
+
+ // place image in the center of page
+ int offsetW = ( W - anImage.width() ) / 2;
+ int offsetH = ( H - anImage.height() ) / 2;
+
+ aPainter.drawImage( offsetW, offsetH, anImage );
+
+ aPainter.end();
+}
+
/*!
Set or clear flag Qt::WDestructiveClose
*/
/*! Context menu requested for event \a e.
*/
-void SUIT_ViewWindow::contextMenuEvent ( QContextMenuEvent * e )
+void SUIT_ViewWindow::contextMenuEvent( QContextMenuEvent* e )
{
+ e->ignore();
+
+ QMainWindow::contextMenuEvent( e );
+
+ if ( e->isAccepted() )
+ return;
+
if ( e->reason() != QContextMenuEvent::Mouse )
emit contextMenuRequested( e );
}
// get file name
SUIT_Application* app = myManager->study()->application();
- QString fileName = app->getFileName( false, QString::null, filter(), tr( "TLT_DUMP_VIEW" ), 0 );
+ QString fileName = app->getFileName( false, QString(), filter(), tr( "TLT_DUMP_VIEW" ), 0 );
if ( !fileName.isEmpty() )
{
QString fmt = SUIT_Tools::extension( fileName ).toUpper();
}
/*!
- Prints given image
- \param theImage - the image to print
+ \return associated tool bar manager
*/
-void SUIT_ViewWindow::printImage( const QImage& theImage, QWidget* theWidget )
+QtxActionToolMgr* SUIT_ViewWindow::toolMgr() const
{
- if ( theImage.isNull() )
- 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 anOrientation = -1;
-
- QPrinter aPrinter;
-
- // restore settinds from previous launching
-
- // printer name
- if ( !aPrinterName.isEmpty() )
- aPrinter.setPrinterName( aPrinterName );
- else
- {
- // Nothing to do for the first printing. aPrinter contains default printer name by default
- }
-
- if ( anOrientation >= 0 )
- aPrinter.setOrientation( (QPrinter::Orientation)anOrientation );
- else
- aPrinter.setOrientation( QPrinter::Landscape );
-
-
- QPrintDialog printDlg( &aPrinter, theWidget );
- printDlg.setPrintRange( QAbstractPrintDialog::AllPages );
- if ( printDlg.exec() != QDialog::Accepted )
- return;
-
- // store printer settings for further starts
- aPrinterName = aPrinter.printerName();
- anOrientation = aPrinter.orientation();
-
- int W, H;
- QPainter aPainter;
-
- // work arround for printing on real printer
- if ( aPrinter.outputFileName().isEmpty() && aPrinter.orientation() == QPrinter::Landscape )
- {
- aPrinter.setFullPage( true );
- // set paper orientation and rotate painter
- aPrinter.setOrientation( QPrinter::Portrait );
-
- W = aPrinter.height();
- H = aPrinter.width();
-
- int wBorder = aPrinter.paperRect().height() - W;
- int hBorder = aPrinter.paperRect().width() - H;
-
- aPainter.begin( &aPrinter );
- aPainter.translate( QPoint( H + hBorder, wBorder ) );
- aPainter.rotate( 90 );
- }
- else
- {
- aPrinter.setFullPage( false );
- aPainter.begin( &aPrinter );
- W = aPrinter.width();
- H = aPrinter.height();
- }
-
- QImage anImage = theImage;
- if ( anImage.width() > W || anImage.height() > H )
- anImage = anImage.scaled( W, H, Qt::KeepAspectRatio, Qt::SmoothTransformation );
-
- // place image in the center of page
- int offsetW = ( W - anImage.width() ) / 2;
- int offsetH = ( H - anImage.height() ) / 2;
-
- aPainter.drawImage( offsetW, offsetH, anImage );
+ return myToolMgr;
+}
- aPainter.end();
+/*!
+ \return window unique identifier
+*/
+int SUIT_ViewWindow::getId() const
+{
+ return int(long(this));
}
#include "SUIT.h"
#include <QMainWindow>
-#include <QImage>
class SUIT_Desktop;
class SUIT_ViewManager;
+class QtxActionToolMgr;
+class QImage;
class SUIT_EXPORT SUIT_ViewWindow: public QMainWindow
{
virtual void setVisualParameters( const QString& parameters );
void setDestructiveClose( const bool );
+
+ int getId() const;
+
+ QtxActionToolMgr* toolMgr() const;
public slots:
virtual void onDumpView();
SUIT_Desktop* myDesktop;
SUIT_ViewManager* myManager;
+
+private:
+ QtxActionToolMgr* myToolMgr;
};
#endif // !defined(AFX_SUIT_VIEWWINDOW_H__82C3D51A_6F10_45B0_BCFE_3CB3EF596A4D__INCLUDED_)