Commit 13da1877 authored by Hans-Christian Ebke's avatar Hans-Christian Ebke

Improved view decoding.


git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@18672 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 5f2d3fd5
......@@ -896,7 +896,9 @@ void CoreWidget::slotSetViewAndWindowGeometry(QString view) {
QSize windowSize(0, 0);
int splitterWidth = 0;
examiner_widgets_[viewerId]->decodeView (view, &windowSize, &splitterWidth);
QSize viewportSize(0, 0);
examiner_widgets_[viewerId]->decodeView (
view, &windowSize, &splitterWidth, &viewportSize);
if (windowSize.height() != 0 && windowSize.width() != 0) {
if (windowSize.width() < 0) {
......@@ -926,6 +928,29 @@ void CoreWidget::slotSetViewAndWindowGeometry(QString view) {
}
toolSplitter_->setSizes(splitter_sizes);
}
/*
* Viewport size has precedence. Manipulate window size so that the
* viewport size is matched exactly.
*/
if (viewportSize.width() > 0 && viewportSize.height() > 0) {
const QSize cur_viewport_size = examiner_widgets_[viewerId]->size().toSize();
std::cout << "Stored viewport size is " << viewportSize.width()
<< " x " << viewportSize.height() << ". Actual size is"
<< cur_viewport_size.width() << " x "
<< cur_viewport_size.height() << "." << std::endl;
if (cur_viewport_size != viewportSize) {
std::cerr << "Stored viewport size is " << viewportSize.width()
<< " x " << viewportSize.height() << ". Actual size is"
<< cur_viewport_size.width() << " x "
<< cur_viewport_size.height()
<< ". Trying to adjust." << std::endl;
QSize diff = viewportSize - cur_viewport_size;
resize(size() + diff);
}
}
}
void CoreWidget::slotPasteViewAndWindow()
......
......@@ -1099,13 +1099,17 @@ void glViewer::encodeView(QString& _view, const QSize& _windowSize /*= QSize()*/
// add gl width/height, current projection Mode and the ortho mode width to output
_view += QString::number(_windowSize.width()) + " " + QString::number(_windowSize.height()) + " " + QString::number(_splitterWidth)+ " " + QString::number(projectionMode_) + " " + QString::number(properties_.orthoWidth()) + "\n";
// Add viewer size
_view += QString::fromUtf8("%1 %2\n").arg(size().width()).arg(size().height());
}
//----------------------------------------------------------------------------
bool glViewer::decodeView(const QString& _view, QSize *_windowSize /*= NULL*/, int* _splitterWidth /*= NULL*/)
bool glViewer::decodeView(const QString& _view, QSize *_windowSize /*= NULL*/,
int* _splitterWidth /*= NULL*/, QSize *_viewportSize)
{
if (_view.left(sizeof(COPY_PASTE_VIEW_START_STRING)-1) != QString(COPY_PASTE_VIEW_START_STRING))
{
......@@ -1124,7 +1128,7 @@ bool glViewer::decodeView(const QString& _view, QSize *_windowSize /*= NULL*/, i
int pMode;
// New version
if ( split.size() == 37 ) {
if ( split.size() >= 37 ) {
//*********************************************************
// Parse the components
......@@ -1163,6 +1167,10 @@ bool glViewer::decodeView(const QString& _view, QSize *_windowSize /*= NULL*/, i
pMode = split[35].toInt();
properties_.orthoWidth( split[36].toDouble() );
if (_viewportSize && split.size() >= 39) {
*_viewportSize = QSize(split[37].toInt(), split[38].toInt());
}
} else if ( split.size() == 36 ) { // Old Version
//*********************************************************
......
......@@ -316,7 +316,8 @@ public:
\note QSize(0,0) indicates that the window was maximized.
\note _splitterWidth is -1 if no splitterWidth was saved
*/
bool decodeView(const QString& _view, QSize *_windowSize = NULL, int* _toolBarWidth = NULL);
bool decodeView(const QString& _view, QSize *_windowSize = NULL,
int* _toolBarWidth = NULL, QSize *_viewportSize = NULL);
/// initialize modelview matrix to identity
void initModelviewMatrix();
......
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