45 #include "SlicePlugin.hh" 50 SlicePlugin::SlicePlugin() :
58 void SlicePlugin::initializePlugin(){
66 node_->setMultipassStatus(ACG::SceneGraph::BaseNode::NOPASS);
73 QButtonGroup* bbGroup =
new QButtonGroup();
74 bbGroup->setExclusive(
true );
75 bbGroup->addButton( tool_->radioAll );
76 bbGroup->addButton( tool_->radioTarget );
78 QButtonGroup* axisGroup =
new QButtonGroup();
79 axisGroup->setExclusive(
true );
80 axisGroup->addButton( tool_->radioX );
81 axisGroup->addButton( tool_->radioY );
82 axisGroup->addButton( tool_->radioZ );
84 tool_->radioAll->setChecked(
true );
85 tool_->radioX->setChecked(
true );
87 connect(tool_->radioAll, SIGNAL( released() ),
this, SLOT( updateSlice() ) );
88 connect(tool_->radioTarget, SIGNAL( released() ),
this, SLOT( updateSlice() ) );
89 connect(tool_->resetButton, SIGNAL( released() ),
this, SLOT( resetParameters() ) );
90 connect(tool_->enabled, SIGNAL( released() ),
this, SLOT( updateSlice() ) );
91 connect(tool_->radioX, SIGNAL( released() ),
this, SLOT( updateSlice() ) );
92 connect(tool_->radioY, SIGNAL( released() ),
this, SLOT( updateSlice() ) );
93 connect(tool_->radioZ, SIGNAL( released() ),
this, SLOT( updateSlice() ) );
94 connect(tool_->posSlider, SIGNAL( valueChanged(
int) ),
this, SLOT( updateSlice(
int) ) );
95 connect(tool_->sizeSlider, SIGNAL( valueChanged(
int) ),
this, SLOT( updateSlice(
int) ) );
97 toolIcon_ =
new QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"slice.png");
98 emit addToolbox( tr(
"Slice") , tool_, toolIcon_);
101 void SlicePlugin::resetParameters(){
102 tool_->posSlider->setValue(0);
103 tool_->sizeSlider->setValue(102);
107 void SlicePlugin::updateSlice(
int ){
111 void SlicePlugin::updateSlice(){
113 if ( tool_->enabled->isChecked() ) {
115 node_->setMultipassStatus(BaseNode::ALLPASSES);
118 node_->setMultipassStatus(ACG::SceneGraph::BaseNode::NOPASS);
121 if ( tool_->enabled->isChecked() ){
126 getBoundingBox( bbmin, bbmax);
129 ACG::Vec3f pos (center[0], center[1], center[2]);
136 eps = tool_->sizeSlider->value() / 100.0;
141 if (tool_->radioX->isChecked()){
143 eps *= (bbmax[0] - bbmin[0]);
144 offset = (bbmax[0] - bbmin[0]) * 0.5;
146 if (tool_->radioY->isChecked()){
148 eps *= (bbmax[1] - bbmin[1]);
149 offset = (bbmax[1] - bbmin[1]) * 0.5;
151 if (tool_->radioZ->isChecked()){
153 eps *= (bbmax[2] - bbmin[2]);
154 offset = (bbmax[2] - bbmin[2]) * 0.5;
157 pos += normal * ( (float)tool_->posSlider->value() / 100.0 ) * (offset + 0.1);
159 node_->set_plane(pos, normal, eps);
166 bool firstRound =
true;
170 if (tool_->radioTarget->isChecked())
181 o_it->getBoundingBox(cur_min, cur_max);
188 bbmin[0] = std::min( bbmin[0], cur_min[0]);
189 bbmin[1] = std::min( bbmin[1], cur_min[1]);
190 bbmin[2] = std::min( bbmin[2], cur_min[2]);
191 bbmax[0] = std::max( bbmax[0], cur_max[0]);
192 bbmax[1] = std::max( bbmax[1], cur_max[1]);
193 bbmax[2] = std::max( bbmax[2], cur_max[2]);
197 if ((bbmin[0] > bbmax[0]) || (bbmin[1] > bbmax[1]) || (bbmin[2] > bbmax[2]))
198 std::cerr <<
"Error while computing bounding box!";
const QStringList ALL_OBJECTS
Iterable object range.
DLLEXPORT ObjectIterator objectsEnd()
Return Iterator to Object End.
VectorT< float, 3 > Vec3f
QStringList IteratorRestriction
Iterable object range.
const QStringList TARGET_OBJECTS("target")
Iterable object range.
void addObjectRenderingNode(ACG::SceneGraph::BaseNode *_node)
Add scenegraph node modifing object rendering.
Hide this node, but draw children.
const DataType DATA_ALL(UINT_MAX)
Identifier for all available objects.