Commit 8a42cc4b authored by Matthias Möller's avatar Matthias Möller

add save/restore the height/width of the main window when copy/paste the View via ui

refs #375

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@14151 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 64510563
......@@ -832,11 +832,25 @@ void CoreWidget::delete_garbage() {
}
void CoreWidget::slotPasteView( ) {
examiner_widgets_[PluginFunctions::activeExaminer()]->actionPasteView();
QSize size = examiner_widgets_[PluginFunctions::activeExaminer()]->actionPasteView();
if (size == QSize(0,0))
{
showMaximized();
}
else
{
showNormal();
resizeApplication(size.width(),size.height());
}
}
void CoreWidget::slotCopyView( ) {
examiner_widgets_[PluginFunctions::activeExaminer()]->actionCopyView();
QSize size;
if (isMaximized())
size = QSize(0,0);
else
size = QSize (width(),height());
examiner_widgets_[PluginFunctions::activeExaminer()]->actionCopyView(size);
}
void CoreWidget::slotCoordSysVisibility(bool _visible){
......
......@@ -980,7 +980,7 @@ void glViewer::moveEvent (QGraphicsSceneMoveEvent *)
//-----------------------------------------------------------------------------
void glViewer::encodeView(QString& _view)
void glViewer::encodeView(QString& _view, const QSize& _windowSize /*= QSize()*/)
{
// Get current matrices
const ACG::GLMatrixd m = glstate_->modelview();
......@@ -1000,14 +1000,14 @@ void glViewer::encodeView(QString& _view)
_view += QString::number(p(3,0)) + " " + QString::number(p(3,1)) + " " + QString::number(p(3,2)) + " " + QString::number(p(3,3)) + "\n";
// add gl width/height, current projection Mode and the ortho mode width to output
_view += QString::number(glWidth()) + " " + QString::number(glHeight()) + " " + QString::number(projectionMode_) + " " + QString::number(properties_.orthoWidth()) + "\n";
_view += QString::number(_windowSize.width()) + " " + QString::number(_windowSize.height()) + " " + QString::number(projectionMode_) + " " + QString::number(properties_.orthoWidth()) + "\n";
}
//----------------------------------------------------------------------------
bool glViewer::decodeView(const QString& _view)
bool glViewer::decodeView(const QString& _view, QSize *_windowSize /*= NULL*/)
{
if (_view.left(sizeof(VIEW_MAGIC)-1) != QString(VIEW_MAGIC))
return false;
......@@ -1064,8 +1064,26 @@ bool glViewer::decodeView(const QString& _view)
p(3,2) = split[30].toDouble(&ok); if ( !ok ) { std::cerr << "Error in decoding View!" << std::endl; return false; }
p(3,3) = split[31].toDouble(&ok); if ( !ok ) { std::cerr << "Error in decoding View!" << std::endl; return false; }
//int w = split[32].toInt(&ok); if ( !ok ) { std::cerr << "Error in decoding View!" << std::endl; return false; }
//int h = split[33].toInt(&ok); if ( !ok ) { std::cerr << "Error in decoding View!" << std::endl; return false; }
if (_windowSize)
{
//restore the old window size
int w = split[32].toInt(&ok);
if ( !ok )
{
std::cerr << "No window size saved!" << std::endl;
w = 0;
}
int h = split[33].toInt(&ok);
if ( !ok )
{
std::cerr << "No window size saved!" << std::endl;
h = 0;
}
*_windowSize = QSize(w,h);
}
pMode = split[34].toInt(&ok); if ( !ok ) { std::cerr << "Error in decoding View!" << std::endl; return false; }
properties_.orthoWidth( split[35].toDouble(&ok) ); if ( !ok ) { std::cerr << "Error in decoding View!" << std::endl; return false; }
......@@ -1088,9 +1106,10 @@ bool glViewer::decodeView(const QString& _view)
//-----------------------------------------------------------------------------
void glViewer::actionCopyView()
void glViewer::actionCopyView(const QSize &_windowSize /*=QSize()*/)
{
QString view; encodeView(view);
QString view;
encodeView(view,_windowSize);
QApplication::clipboard()->setText(view);
}
......@@ -1098,10 +1117,13 @@ void glViewer::actionCopyView()
//-----------------------------------------------------------------------------
void glViewer::actionPasteView()
QSize glViewer::actionPasteView()
{
QString view; view=QApplication::clipboard()->text();
decodeView(view);
QString view;
view = QApplication::clipboard()->text();
QSize oldSize;
decodeView(view,&oldSize);
return oldSize;
}
......
......@@ -261,13 +261,19 @@ public:
/// map glarea coords to global coords
QPoint glMapToGlobal( const QPoint& _pos ) const;
/// convert current view to text representation
void encodeView(QString& _view);
/** convert current view to text representation
if saved, the old window size will be written into _windowSize
\note QSize(0,0) indicates that the window was maximized or the window size was not saved
*/
void encodeView(QString& _view, const QSize& _windowSize = QSize());
/** Decode and apply text representation of view encoded by encodeView().
If \c _view was successfully decoded it will immediately be applied
and \c true is returned, \c false is returned else.
You can save the current Window size via parameter _windowSize
\note QSize(0,0) indicates that the window is maximized.
*/
bool decodeView(const QString& _view);
bool decodeView(const QString& _view, QSize *_windowSize = NULL);
/// initialize modelview matrix to identity
void initModelviewMatrix();
......@@ -345,8 +351,14 @@ public slots:
virtual void setView( const ACG::GLMatrixd& _modelview,
const ACG::GLMatrixd& _inverse_modelview );
void actionPasteView();
void actionCopyView();
/** you get the older window size (if saved) back
\note QSize(0,0) indicates that the window was maximized or the window size was not saved
*/
QSize actionPasteView();
/** if you want to save the windowSize, use the parameter
\note QSize(0,0) indicates that the window is maximized
*/
void actionCopyView(const QSize &_windowSize = QSize());
//-------------------------------------------------------------- public signals
signals:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment