Commit 2e35c738 authored by Jan Möbius's avatar Jan Möbius
Browse files

Made Paste View backward compatible

Fixed nasty resize bug, computing the wrong size for the splitter.

closes #981

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@14912 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 964eb9ac
...@@ -844,19 +844,20 @@ void CoreWidget::slotPasteViewAndWindow() ...@@ -844,19 +844,20 @@ void CoreWidget::slotPasteViewAndWindow()
//resize the toolbox and splitter //resize the toolbox and splitter
if (splitterWidth != -1) if (splitterWidth != -1)
{ {
QList<int> sizes = toolSplitter_->sizes(); QList<int> sizes;
unsigned sum_size = sizes[0]+sizes[1];
bool onRight = OpenFlipperSettings().value("Core/Gui/ToolBoxes/ToolBoxOnTheRight").toBool(); //std::cerr << "Sizes : " << size[0] << " " << size[1] << " " << sum_size << std::endl;
bool onRight = OpenFlipperSettings().value("Core/Gui/ToolBoxes/ToolBoxOnTheRight",true).toBool();
if (onRight) if (onRight)
{ {
sizes[1] = splitterWidth; sizes.push_back(size.width() - splitterWidth);
sizes[0] = sum_size - splitterWidth; sizes.push_back(splitterWidth);
} }
else else
{ {
sizes[0] = splitterWidth; sizes.push_back(splitterWidth);
sizes[1] = sum_size - splitterWidth; sizes.push_back(size.width() - splitterWidth);
} }
toolSplitter_->setSizes(sizes); toolSplitter_->setSizes(sizes);
...@@ -885,7 +886,7 @@ void CoreWidget::slotCopyView( ) { ...@@ -885,7 +886,7 @@ void CoreWidget::slotCopyView( ) {
size = QSize (width(),height()); size = QSize (width(),height());
int splitter_size = 0; int splitter_size = 0;
if (OpenFlipperSettings().value("Core/Gui/ToolBoxes/ToolBoxOnTheRight").toBool()) if (OpenFlipperSettings().value("Core/Gui/ToolBoxes/ToolBoxOnTheRight",true).toBool())
splitter_size = toolSplitter_->sizes()[1]; splitter_size = toolSplitter_->sizes()[1];
else else
splitter_size = toolSplitter_->sizes()[0]; splitter_size = toolSplitter_->sizes()[0];
......
...@@ -1048,40 +1048,92 @@ bool glViewer::decodeView(const QString& _view, QSize *_windowSize /*= NULL*/, i ...@@ -1048,40 +1048,92 @@ bool glViewer::decodeView(const QString& _view, QSize *_windowSize /*= NULL*/, i
ACG::GLMatrixd m, p; ACG::GLMatrixd m, p;
int pMode; int pMode;
// Check if the number of components matches the expected size // New version
if ( split.size() != 37 ) { if ( split.size() == 37 ) {
std::cerr << "Unable to paste view ... wrong parameter count!! is" << split.size() << std::endl;
return false; //*********************************************************
} // Parse the components
////////////////// // first, get the projection and the modelview matrices
// Parse the components //*********************************************************
// first, get the projection and the modelview matrices for (std::size_t i = 0; i < 4; ++i)
for (std::size_t i = 0; i < 4; ++i)
{
for (std::size_t j = 0; j < 4; ++j)
{ {
m(i,j) = split[i*4 + j].toDouble(); for (std::size_t j = 0; j < 4; ++j)
p(i,j) = split[i*4 + j +16].toDouble(); {
m(i,j) = split[i*4 + j].toDouble();
p(i,j) = split[i*4 + j +16].toDouble();
}
} }
}
//parse the window size if requested //*********************************************************
if (_windowSize) //parse the window size if requested
{ //*********************************************************
//restore the old window size if (_windowSize)
int w = split[32].toInt(); {
int h = split[33].toInt(); //restore the old window size
*_windowSize = QSize(w,h); int w = split[32].toInt();
} int h = split[33].toInt();
//parse the splitter width if requested *_windowSize = QSize(w,h);
if (_splitterWidth) }
{
*_splitterWidth = split[34].toInt(); //*********************************************************
} //parse the splitter width for the toolboxes if requested
//*********************************************************
if (_splitterWidth )
{
*_splitterWidth = split[34].toInt();
} else {
*_splitterWidth = -1;
}
pMode = split[35].toInt(); //*********************************************************
properties_.orthoWidth( split[36].toDouble() ); // Projection mode and orthogonal width
//*********************************************************
pMode = split[35].toInt();
properties_.orthoWidth( split[36].toDouble() );
} else if ( split.size() == 36 ) { // Old Version
//*********************************************************
// Parse the components
// first, get the projection and the modelview matrices
//*********************************************************
for (std::size_t i = 0; i < 4; ++i)
{
for (std::size_t j = 0; j < 4; ++j)
{
m(i,j) = split[i*4 + j].toDouble();
p(i,j) = split[i*4 + j +16].toDouble();
}
}
//*********************************************************
//parse the window size if requested
//*********************************************************
if (_windowSize)
{
//restore the old window size
int w = split[32].toInt();
int h = split[33].toInt();
*_windowSize = QSize(w,h);
}
//*********************************************************
// Return -1 to inform, that the value is unknown
//*********************************************************
*_splitterWidth = -1;
//*********************************************************
// Projection mode and orthogonal width
//*********************************************************
pMode = split[34].toInt();
properties_.orthoWidth( split[35].toDouble() );
} else { // Garbage ?!
std::cerr << "Unable to paste view ... wrong parameter count!! is" << split.size() << std::endl;
return false;
}
// Switch to our gl context // Switch to our gl context
makeCurrent(); makeCurrent();
......
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