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
42 #include <OpenFlipper/widgets/coreWidget/CoreWidget.hh>
43
46 void CoreWidget::toggleLogger() {
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
68 void CoreWidget::showLogger(OpenFlipper::Options::LoggerState _state) {
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
80 slidingLogger_->attachWidget(logWidget_);
81
82 break;
83 }
84 case OpenFlipper::Options::Normal: {
85
86 slidingLogger_->detachWidget();
87
88 showLoggerInSplitView(true);
89
90 logWidget_->show();
91
92 break;
93 }
94 case OpenFlipper::Options::Hidden: {
95
96 if (loggerState_ == OpenFlipper::Options::InScene)
97 slidingLogger_->detachWidget();
98
99 showLoggerInSplitView(false);
100
101 break;
102 }
103 } // End switch
104
105 loggerState_ = _state;
106 }
107
108 //-----------------------------------------------------------------------------
109
110 void CoreWidget::showLoggerInSplitView(bool _show) {
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
151 void CoreWidget::updateInSceneLoggerGeometry() {
152
153 if(loggerState_ == OpenFlipper::Options::InScene) {
154 slidingLogger_->updateGeometry();
155 }
156 }
CoreWidget::logWidget_
LoggerWidget * logWidget_
Textedit at the bottom for log messages.
Definition: CoreWidget.hh:686
CoreWidget::splitter_
QSplitter * splitter_
Spliter between toplevel objects and the textedit at the bottom.
Definition: CoreWidget.hh:680
OpenFlipper::Options::LoggerState
LoggerState
State of the logging widget.
Definition: GlobalOptions.hh:562
CoreWidget.hh
CoreWidget::showLogger
void showLogger(OpenFlipper::Options::LoggerState _state)
Change visibility of the logger.
Definition: LoggerHandling.cc:68
CoreWidget::originalLoggerSize_
int originalLoggerSize_
Size of the logging window ( defaults to 240 )
Definition: CoreWidget.hh:689
QtSlideWindow::detachWidget
void detachWidget()
detach child widget
Definition: QtSlideWindow.cc:148
QtSlideWindow::updateGeometry
void updateGeometry()
recalculate geometry
Definition: QtSlideWindow.cc:378
CoreWidget::slidingLogger_
QtSlideWindow * slidingLogger_
Class that holds the animated log widget.
Definition: CoreWidget.hh:722
CoreWidget::updateInSceneLoggerGeometry
void updateInSceneLoggerGeometry()
Set in-scene logger geometry right.
Definition: LoggerHandling.cc:151
CoreWidget::loggerState_
OpenFlipper::Options::LoggerState loggerState_
Show logger in splitter or not.
Definition: CoreWidget.hh:568
CoreWidget::showLoggerInSplitView
void showLoggerInSplitView(bool _show)
Show logger in splitter or not.
Definition: LoggerHandling.cc:110
CoreWidget::toggleLogger
void toggleLogger()
Hide or show logging area.
Definition: LoggerHandling.cc:46
QtSlideWindow::attachWidget
void attachWidget(QWidget *_m)
attach a child widget
Definition: QtSlideWindow.cc:127