Developer Documentation
LoggerHandling.cc
1 /*===========================================================================*\
2 * *
3 * OpenFlipper *
4  * Copyright (c) 2001-2015, RWTH-Aachen University *
5  * Department of Computer Graphics and Multimedia *
6  * All rights reserved. *
7  * www.openflipper.org *
8  * *
9  *---------------------------------------------------------------------------*
10  * This file is part of OpenFlipper. *
11  *---------------------------------------------------------------------------*
12  * *
13  * Redistribution and use in source and binary forms, with or without *
14  * modification, are permitted provided that the following conditions *
15  * are met: *
16  * *
17  * 1. Redistributions of source code must retain the above copyright notice, *
18  * this list of conditions and the following disclaimer. *
19  * *
20  * 2. Redistributions in binary form must reproduce the above copyright *
21  * notice, this list of conditions and the following disclaimer in the *
22  * documentation and/or other materials provided with the distribution. *
23  * *
24  * 3. Neither the name of the copyright holder nor the names of its *
25  * contributors may be used to endorse or promote products derived from *
26  * this software without specific prior written permission. *
27  * *
28  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39 * *
40 \*===========================================================================*/
41 
43 
47 
48  switch (OpenFlipper::Options::loggerState()) {
49  case OpenFlipper::Options::InScene:
50  OpenFlipper::Options::loggerState(OpenFlipper::Options::Normal);
51  break;
52  case OpenFlipper::Options::Normal:
53  OpenFlipper::Options::loggerState(OpenFlipper::Options::Hidden);
54  break;
55  case OpenFlipper::Options::Hidden:
56  OpenFlipper::Options::loggerState(OpenFlipper::Options::InScene);
57  break;
58  }
59 
60  // Hide/Show Logger
61  showLogger(OpenFlipper::Options::loggerState());
62 }
63 
64 //-----------------------------------------------------------------------------
65 
69 
70  //Hide Logger
71  if (_state == loggerState_)
72  return;
73 
74  switch (_state) {
75  case OpenFlipper::Options::InScene: {
76 
77  showLoggerInSplitView(false);
78  logWidget_->resize(logWidget_->width(), originalLoggerSize_);
79 
81 
82  break;
83  }
84  case OpenFlipper::Options::Normal: {
85 
87 
89 
90  logWidget_->show();
91 
92  break;
93  }
94  case OpenFlipper::Options::Hidden: {
95 
96  if (loggerState_ == OpenFlipper::Options::InScene)
98 
99  showLoggerInSplitView(false);
100 
101  break;
102  }
103  } // End switch
104 
105  loggerState_ = _state;
106 }
107 
108 //-----------------------------------------------------------------------------
109 
111 
112  if(!_show) {
113 
114  QList<int> wsizes = splitter_->sizes();
115 
116  // Remember old size
117  if (loggerState_ == OpenFlipper::Options::Normal) {
118  if(wsizes.size() > 1) {
119  originalLoggerSize_ = wsizes[1];
120  } else {
121  originalLoggerSize_ = 240;
122  }
123  }
124 
125  if (originalLoggerSize_ == 0)
126  originalLoggerSize_ = 240;
127 
128  logWidget_->setParent(0);
129  wsizes[0] = 1;
130  splitter_->setSizes(wsizes);
131  } else {
132 
133  if (loggerState_ == OpenFlipper::Options::InScene)
134  originalLoggerSize_ = logWidget_->height();
135 
136  if (originalLoggerSize_ == 0)
137  originalLoggerSize_ = 240;
138 
139  logWidget_->setParent(splitter_);
140  splitter_->insertWidget(1, logWidget_);
141  QList<int> wsizes = splitter_->sizes();
142  int totalHeight = wsizes[0] + wsizes[1];
143  wsizes[1] = originalLoggerSize_;
144  wsizes[0] = totalHeight - originalLoggerSize_;
145  splitter_->setSizes(wsizes);
146  }
147 }
148 
149 //-----------------------------------------------------------------------------
150 
152 
153  if(loggerState_ == OpenFlipper::Options::InScene) {
155  }
156 }
QSplitter * splitter_
Spliter between toplevel objects and the textedit at the bottom.
Definition: CoreWidget.hh:680
void detachWidget()
detach child widget
void updateGeometry()
recalculate geometry
LoggerWidget * logWidget_
Textedit at the bottom for log messages.
Definition: CoreWidget.hh:686
void showLogger(OpenFlipper::Options::LoggerState _state)
Change visibility of the logger.
void toggleLogger()
Hide or show logging area.
LoggerState
State of the logging widget.
int originalLoggerSize_
Size of the logging window ( defaults to 240 )
Definition: CoreWidget.hh:689
void showLoggerInSplitView(bool _show)
Show logger in splitter or not.
void attachWidget(QWidget *_m)
attach a child widget
QtSlideWindow * slidingLogger_
Class that holds the animated log widget.
Definition: CoreWidget.hh:722
void updateInSceneLoggerGeometry()
Set in-scene logger geometry right.
OpenFlipper::Options::LoggerState loggerState_
Show logger in splitter or not.
Definition: CoreWidget.hh:568