51 #include "SlicePlugin.hh" 56 SlicePlugin::SlicePlugin() :
64 void SlicePlugin::initializePlugin(){
72 node_->setMultipassStatus(ACG::SceneGraph::BaseNode::NOPASS);
79 QButtonGroup* bbGroup =
new QButtonGroup();
80 bbGroup->setExclusive(
true );
81 bbGroup->addButton( tool_->radioAll );
82 bbGroup->addButton( tool_->radioTarget );
84 QButtonGroup* axisGroup =
new QButtonGroup();
85 axisGroup->setExclusive(
true );
86 axisGroup->addButton( tool_->radioX );
87 axisGroup->addButton( tool_->radioY );
88 axisGroup->addButton( tool_->radioZ );
90 tool_->radioAll->setChecked(
true );
91 tool_->radioX->setChecked(
true );
93 connect(tool_->radioAll, SIGNAL( released() ),
this, SLOT( updateSlice() ) );
94 connect(tool_->radioTarget, SIGNAL( released() ),
this, SLOT( updateSlice() ) );
95 connect(tool_->resetButton, SIGNAL( released() ),
this, SLOT( resetParameters() ) );
96 connect(tool_->enabled, SIGNAL( released() ),
this, SLOT( updateSlice() ) );
97 connect(tool_->radioX, SIGNAL( released() ),
this, SLOT( updateSlice() ) );
98 connect(tool_->radioY, SIGNAL( released() ),
this, SLOT( updateSlice() ) );
99 connect(tool_->radioZ, SIGNAL( released() ),
this, SLOT( updateSlice() ) );
100 connect(tool_->posSlider, SIGNAL( valueChanged(
int) ),
this, SLOT( updateSlice(
int) ) );
101 connect(tool_->sizeSlider, SIGNAL( valueChanged(
int) ),
this, SLOT( updateSlice(
int) ) );
103 toolIcon_ =
new QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"slice.png");
104 emit addToolbox( tr(
"Slice") , tool_, toolIcon_);
107 void SlicePlugin::resetParameters(){
108 tool_->posSlider->setValue(0);
109 tool_->sizeSlider->setValue(102);
113 void SlicePlugin::updateSlice(
int ){
117 void SlicePlugin::updateSlice(){
119 if ( tool_->enabled->isChecked() ) {
121 node_->setMultipassStatus(BaseNode::ALLPASSES);
124 node_->setMultipassStatus(ACG::SceneGraph::BaseNode::NOPASS);
127 if ( tool_->enabled->isChecked() ){
132 getBoundingBox( bbmin, bbmax);
135 ACG::Vec3f pos (center[0], center[1], center[2]);
142 eps = tool_->sizeSlider->value() / 100.0;
147 if (tool_->radioX->isChecked()){
149 eps *= (bbmax[0] - bbmin[0]);
150 offset = (bbmax[0] - bbmin[0]) * 0.5;
152 if (tool_->radioY->isChecked()){
154 eps *= (bbmax[1] - bbmin[1]);
155 offset = (bbmax[1] - bbmin[1]) * 0.5;
157 if (tool_->radioZ->isChecked()){
159 eps *= (bbmax[2] - bbmin[2]);
160 offset = (bbmax[2] - bbmin[2]) * 0.5;
163 pos += normal * ( (float)tool_->posSlider->value() / 100.0 ) * (offset + 0.1);
165 node_->set_plane(pos, normal, eps);
172 bool firstRound =
true;
176 if (tool_->radioTarget->isChecked())
187 o_it->getBoundingBox(cur_min, cur_max);
194 bbmin[0] = std::min( bbmin[0], cur_min[0]);
195 bbmin[1] = std::min( bbmin[1], cur_min[1]);
196 bbmin[2] = std::min( bbmin[2], cur_min[2]);
197 bbmax[0] = std::max( bbmax[0], cur_max[0]);
198 bbmax[1] = std::max( bbmax[1], cur_max[1]);
199 bbmax[2] = std::max( bbmax[2], cur_max[2]);
203 if ((bbmin[0] > bbmax[0]) || (bbmin[1] > bbmax[1]) || (bbmin[2] > bbmax[2]))
204 std::cerr <<
"Error while computing bounding box!";
208 #if QT_VERSION < 0x050000
QStringList IteratorRestriction
Iterable object range.
const QStringList TARGET_OBJECTS("target")
Iterable object range.
const QStringList ALL_OBJECTS
Iterable object range.
VectorT< float, 3 > Vec3f
const DataType DATA_ALL(UINT_MAX)
Identifier for all available objects.
Hide this node, but draw children.
void addObjectRenderingNode(ACG::SceneGraph::BaseNode *_node)
Add scenegraph node modifing object rendering.
DLLEXPORT ObjectIterator objectsEnd()
Return Iterator to Object End.