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

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()*/ ...@@ -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) 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 // Remove the magic from the string
QString temp = _view; QString temp = _view;
temp.remove(0,sizeof(COPY_PASTE_VIEW_START_STRING)); temp.remove(0,sizeof(COPY_PASTE_VIEW_START_STRING));
...@@ -1140,9 +1136,6 @@ bool glViewer::decodeView(const QString& _view, QSize *_windowSize /*= NULL*/, ...@@ -1140,9 +1136,6 @@ bool glViewer::decodeView(const QString& _view, QSize *_windowSize /*= NULL*/,
//Split it into its components //Split it into its components
QStringList split = temp.split(QRegExp("[\\n\\s]"),QString::SkipEmptyParts); QStringList split = temp.split(QRegExp("[\\n\\s]"),QString::SkipEmptyParts);
ACG::GLMatrixd m, p;
int pMode;
// New version // New version
if ( split.size() >= 37 ) { if ( split.size() >= 37 ) {
...@@ -1181,7 +1174,7 @@ bool glViewer::decodeView(const QString& _view, QSize *_windowSize /*= NULL*/, ...@@ -1181,7 +1174,7 @@ bool glViewer::decodeView(const QString& _view, QSize *_windowSize /*= NULL*/,
// Projection mode and orthogonal width // Projection mode and orthogonal width
//********************************************************* //*********************************************************
pMode = split[35].toInt(); pMode = split[35].toInt();
properties_.orthoWidth( split[36].toDouble() ); ortho_width = split[36].toDouble();
if (_viewportSize && split.size() >= 39) { if (_viewportSize && split.size() >= 39) {
*_viewportSize = QSize(split[37].toInt(), split[38].toInt()); *_viewportSize = QSize(split[37].toInt(), split[38].toInt());
...@@ -1225,13 +1218,34 @@ bool glViewer::decodeView(const QString& _view, QSize *_windowSize /*= NULL*/, ...@@ -1225,13 +1218,34 @@ bool glViewer::decodeView(const QString& _view, QSize *_windowSize /*= NULL*/,
// Projection mode and orthogonal width // Projection mode and orthogonal width
//********************************************************* //*********************************************************
pMode = split[34].toInt(); pMode = split[34].toInt();
properties_.orthoWidth( split[35].toDouble() ); ortho_width = split[35].toDouble();
} else { // Garbage ?! } else { // Garbage ?!
std::cerr << "Unable to paste view ... wrong parameter count!! is" << split.size() << std::endl; std::cerr << "Unable to paste view ... wrong parameter count!! is" << split.size() << std::endl;
return false; 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 // Switch to our gl context
makeCurrent(); makeCurrent();
......
...@@ -290,6 +290,24 @@ public: ...@@ -290,6 +290,24 @@ public:
\note QSize(0,0) indicates that the window is maximized. \note QSize(0,0) indicates that the window is maximized.
*/ */
void encodeView(QString& _view, const QSize& _windowSize = QSize(-1,-1), const int _toolBarWidth = -1); 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(). /** Decode and apply text representation of view encoded by encodeView().
If \c _view was successfully decoded it will immediately be applied If \c _view was successfully decoded it will immediately be applied
and \c true is returned, \c false is returned else. 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