2 * Copyright (c) 1997 Silicon Graphics, Inc. All Rights Reserved.
3 * Copyright (c) 2009 Aconex. All Rights Reserved.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 #include <Inventor/nodes/SoBaseColor.h>
16 #include <Inventor/nodes/SoScale.h>
17 #include <Inventor/nodes/SoSeparator.h>
18 #include <Inventor/nodes/SoTranslation.h>
19 #include <Inventor/nodes/SoTransform.h>
21 #include "colorlist.h"
22 #include "defaultobj.h"
32 StackObj::StackObj(StackMod::Height height
,
35 const DefaultObj
&defaults
,
38 BaseObj::Alignment align
)
39 : ModObj(baseFlag
, defaults
, x
, y
, cols
, rows
, align
),
51 StackObj::finishedAdd()
55 BaseObj::addBase(_root
);
57 if (_metrics
.numMetrics() == 0) {
58 pmprintf("%s: Error: Stack object has no metrics\n",
63 SoScale
*blockScale
= new SoScale();
64 blockScale
->scaleFactor
.setValue(_length
, _maxHeight
, _length
);
65 _root
->addChild(blockScale
);
67 if (_metrics
.numMetrics()) {
68 const char *colName
= (const char *)_colors
.toLatin1();
69 const ColorSpec
*colSpec
= theColorLists
.list(colName
);
70 if (colSpec
!= NULL
) {
72 pmprintf("%s: Warning: Color scale ignored for stack object.\n",
76 if (pmDebug
& DBG_TRACE_APPL0
)
77 cerr
<< "StackObj::finishedAdd: Adding "
78 << colSpec
->_list
.length()
79 << " colors for " << _metrics
.numMetrics()
80 << " metrics" << endl
;
83 for (i
= 0; i
< colSpec
->_list
.size(); i
++)
84 _metrics
.add(*(colSpec
->_list
)[i
]);
88 pmprintf("%s: Warning: No colours specified for stack object, "
89 "defaulting to blue.\n", pmProgname
);
91 _metrics
.resolveColors(MetricList::perValue
);
94 if (pmDebug
& DBG_TRACE_APPL0
)
95 cerr
<< "StackObj::finishedAdd: metrics: " << endl
99 _stack
= new StackMod(&_metrics
, ViewObj::object(_shape
), _height
);
100 _root
->addChild(_stack
->root());
103 _stack
->setFillText((const char *)_text
.toLatin1());
105 BaseObj::add(_stack
);
106 ViewObj::theNumModObjects
++;
113 if (pmDebug
& DBG_TRACE_APPL0
)
114 cerr
<< name() << "has length " << _length
<< endl
;
117 _width
= baseWidth() + _length
;
118 _depth
= baseDepth() + _length
;
122 StackObj::setTran(float xTran
, float zTran
, int setWidth
, int setDepth
)
124 BaseObj::setBaseSize(width(), depth());
125 BaseObj::setTran(xTran
+ (width() / 2.0),
126 zTran
+ (depth() / 2.0),
131 operator<<(QTextStream
& os
, StackObj
const& rhs
)
138 StackObj::display(QTextStream
& os
) const
140 BaseObj::display(os
);
141 os
<< ", length = " << _length
<< ": ";
143 os
<< *_stack
<< endl
;
145 os
<< "stack undefined!" << endl
;