-
Notifications
You must be signed in to change notification settings - Fork 0
/
MDIWindow.cxx
153 lines (123 loc) · 3.86 KB
/
MDIWindow.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#include "MDIWindow.h"
#include "View.h"
#include "DocumentCommon.h"
#include "ApplicationCommon.h"
#include <QFrame>
#include <QToolBar>
#include <QFileDialog>
#include <QMessageBox>
#include <QApplication>
#include <QDir>
#include <QFile>
#include <QFileInfo>
#include <QMainWindow>
#include <QVBoxLayout>
MDIWindow::MDIWindow(View* aView,
DocumentCommon* aDocument,
QWidget* parent,
Qt::WindowFlags wflags )
: QMainWindow( parent, wflags )
{
myView = aView;
myDocument = aDocument;
}
MDIWindow::MDIWindow( DocumentCommon* aDocument, QWidget* parent, Qt::WindowFlags wflags)
: QMainWindow( parent, wflags )
{
QFrame *vb = new QFrame( this );
QVBoxLayout *layout = new QVBoxLayout( vb );
layout->setMargin( 0 );
vb->setFrameStyle( QFrame::StyledPanel | QFrame::Sunken );
setCentralWidget( vb );
myDocument = aDocument;
myView = new View (myDocument->getContext(), vb);
layout->addWidget (myView);
connect( myView, SIGNAL( selectionChanged() ),
this, SIGNAL( selectionChanged() ) );
createViewActions();
createRaytraceActions();
resize( sizeHint() );
setFocusPolicy( Qt::StrongFocus );
}
MDIWindow::~MDIWindow()
{
}
DocumentCommon* MDIWindow::getDocument()
{
return myDocument;
}
void MDIWindow::closeEvent(QCloseEvent* )
{
emit sendCloseView(this);
}
void MDIWindow::fitAll()
{
myView->fitAll();
}
void MDIWindow::createViewActions()
{
// populate a tool bar with some actions
QToolBar* aToolBar = addToolBar( tr( "View Operations" ) );
QList<QAction*>* aList = myView->getViewActions();
aToolBar->addActions( *aList );
aToolBar->toggleViewAction()->setVisible(false);
aList->at(View::ViewHlrOffId)->setChecked( true );
}
void MDIWindow::createRaytraceActions()
{
// populate a tool bar with some actions
QToolBar* aToolBar = addToolBar( tr( "Ray-tracing Options" ) );
QList<QAction*>* aList = myView->getRaytraceActions();
aToolBar->addActions( *aList );
aToolBar->toggleViewAction()->setVisible (true);
aList->at (View::ToolRaytracingId)->setChecked (false);
aList->at (View::ToolShadowsId)->setChecked (true);
aList->at (View::ToolReflectionsId)->setChecked (true);
aList->at (View::ToolAntialiasingId)->setChecked (false);
}
void MDIWindow::onWindowActivated ()
{
getDocument()->getApplication()->onSelectionChanged();
}
void MDIWindow::dump()
{
QString datadir = (QString(qgetenv ("CASROOT").constData()) + "/../data/images");
static QString filter;
filter = "Images Files (*.bmp *.ppm *.png *.jpg *.tiff *.tga *.gif *.exr *.ps *.eps *.tex *.pdf *.svg *.pgf)";
QFileDialog fd ( 0 );
fd.setModal( true );
fd.setNameFilter ( filter );
fd.setWindowTitle( QObject::tr("INF_APP_EXPORT") );
fd.setFileMode( QFileDialog::AnyFile );
int ret = fd.exec();
/* update the desktop after the dialog is closed */
qApp->processEvents();
QStringList fileNames;
fileNames = fd.selectedFiles();
QString file ( (ret == QDialog::Accepted && !fileNames.isEmpty() )? fileNames[0] : QString::null);
if ( !file.isNull() )
{
QApplication::setOverrideCursor( Qt::WaitCursor );
if ( !QFileInfo( file ).completeSuffix().length() )
file += QString( ".bmp" );
bool res = myView->dump( (Standard_CString)file.toLatin1().constData() );
QApplication::restoreOverrideCursor();
if ( !res )
{
QWidgetList list = qApp->allWidgets();
QWidget* mainWidget;
for( int i = 0; i < list.size(); ++i )
{
if( qobject_cast<ApplicationCommonWindow*>( list.at( i ) ) )
mainWidget = qobject_cast<ApplicationCommonWindow*>( list.at( i ) );
}
QMessageBox::information ( mainWidget, QObject::tr("TIT_ERROR"), QObject::tr("INF_ERROR"), QObject::tr("BTN_OK"),
QString::null, QString::null, 0, 0 );
qApp->processEvents();
}
}
}
QSize MDIWindow::sizeHint() const
{
return QSize( 450, 300 );
}