Commit 7b028e69 authored by Hans-Christian Ebke's avatar Hans-Christian Ebke

Refactored glWidget::decodeView.


git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@19065 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 0f6f26c5
......@@ -1124,15 +1124,11 @@ void glViewer::encodeView(QString& _view, const QSize& _windowSize /*= QSize()*/
//----------------------------------------------------------------------------
bool glViewer::decodeView(const QString& _view, QSize *_windowSize /*= NULL*/,
bool glViewer::decodeView(const QString& _view,
ACG::GLMatrixd &m, ACG::GLMatrixd &p, int &pMode, double &ortho_width,
QSize *_windowSize /*= NULL*/,
int* _splitterWidth /*= NULL*/, QSize *_viewportSize)
{
if (_view.left(sizeof(COPY_PASTE_VIEW_START_STRING)-1) != QString(COPY_PASTE_VIEW_START_STRING))
{
std::cerr << "No View was copied." << std::endl;
return false;
}
// Remove the magic from the string
QString temp = _view;
temp.remove(0,sizeof(COPY_PASTE_VIEW_START_STRING));
......@@ -1140,9 +1136,6 @@ bool glViewer::decodeView(const QString& _view, QSize *_windowSize /*= NULL*/,
//Split it into its components
QStringList split = temp.split(QRegExp("[\\n\\s]"),QString::SkipEmptyParts);
ACG::GLMatrixd m, p;
int pMode;
// New version
if ( split.size() >= 37 ) {
......@@ -1181,7 +1174,7 @@ bool glViewer::decodeView(const QString& _view, QSize *_windowSize /*= NULL*/,
// Projection mode and orthogonal width
//*********************************************************
pMode = split[35].toInt();
properties_.orthoWidth( split[36].toDouble() );
ortho_width = split[36].toDouble();
if (_viewportSize && split.size() >= 39) {
*_viewportSize = QSize(split[37].toInt(), split[38].toInt());
......@@ -1225,13 +1218,34 @@ bool glViewer::decodeView(const QString& _view, QSize *_windowSize /*= NULL*/,
// Projection mode and orthogonal width
//*********************************************************
pMode = split[34].toInt();
properties_.orthoWidth( split[35].toDouble() );
ortho_width = split[35].toDouble();
} else { // Garbage ?!
std::cerr << "Unable to paste view ... wrong parameter count!! is" << split.size() << std::endl;
return false;
}
return true;
}
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))
{
std::cerr << "No View was copied." << std::endl;
return false;
}
ACG::GLMatrixd m, p;
int pMode;
double ortho_width;
if (!decodeView(_view, m, p, pMode, ortho_width,
_windowSize, _splitterWidth, _viewportSize))
return false;
properties_.orthoWidth(ortho_width);
// Switch to our gl context
makeCurrent();
......
......@@ -290,6 +290,24 @@ public:
\note QSize(0,0) indicates that the window is maximized.
*/
void encodeView(QString& _view, const QSize& _windowSize = QSize(-1,-1), const int _toolBarWidth = -1);
/** Decode text representation of view encoded by encodeView() into
the supplied output parameters.
If \c _view was successfully decoded \c true is returned, \c false is
returned otherwise.
You can save the current Window size via parameter _windowSize and one
splitter size via _splitterwidth
\note QSize(0,0) indicates that the window was maximized.
\note _splitterWidth is -1 if no splitterWidth was saved
*/
static bool decodeView(const QString& _view,
ACG::GLMatrixd &m, ACG::GLMatrixd &p, int &pMode, double &ortho_width,
QSize *_windowSize = NULL,
int* _splitterWidth = NULL, QSize *_viewportSize = NULL);
/** 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.
......
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