45#include "SlicePlugin.hh"
50SlicePlugin::SlicePlugin() :
58SlicePlugin::~SlicePlugin()
63void SlicePlugin::initializePlugin(){
78 QButtonGroup* bbGroup =
new QButtonGroup();
79 bbGroup->setExclusive(
true );
80 bbGroup->addButton( tool_->radioAll );
81 bbGroup->addButton( tool_->radioTarget );
83 QButtonGroup* axisGroup =
new QButtonGroup();
84 axisGroup->setExclusive(
true );
85 axisGroup->addButton( tool_->radioX );
86 axisGroup->addButton( tool_->radioY );
87 axisGroup->addButton( tool_->radioZ );
89 tool_->radioAll->setChecked(
true );
90 tool_->radioX->setChecked(
true );
92 connect(tool_->radioAll, SIGNAL( released() ),
this, SLOT( updateSlice() ) );
93 connect(tool_->radioTarget, SIGNAL( released() ),
this, SLOT( updateSlice() ) );
94 connect(tool_->resetButton, SIGNAL( released() ),
this, SLOT( resetParameters() ) );
95 connect(tool_->enabled, SIGNAL( released() ),
this, SLOT( updateSlice() ) );
96 connect(tool_->radioX, SIGNAL( released() ),
this, SLOT( updateSlice() ) );
97 connect(tool_->radioY, SIGNAL( released() ),
this, SLOT( updateSlice() ) );
98 connect(tool_->radioZ, SIGNAL( released() ),
this, SLOT( updateSlice() ) );
99 connect(tool_->posSlider, SIGNAL( valueChanged(
int) ),
this, SLOT( updateSlice(
int) ) );
100 connect(tool_->sizeSlider, SIGNAL( valueChanged(
int) ),
this, SLOT( updateSlice(
int) ) );
102 toolIcon_ =
new QIcon(OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"slice.png");
103 emit addToolbox( tr(
"Slice") , tool_, toolIcon_);
106void SlicePlugin::resetParameters(){
107 tool_->posSlider->setValue(0);
108 tool_->sizeSlider->setValue(102);
112void SlicePlugin::updateSlice(
int ){
116void SlicePlugin::updateSlice(){
118 if ( tool_->enabled->isChecked() ) {
126 if ( tool_->enabled->isChecked() ){
131 getBoundingBox( bbmin, bbmax);
134 ACG::Vec3f pos (center[0], center[1], center[2]);
141 eps = tool_->sizeSlider->value() / 100.0;
146 if (tool_->radioX->isChecked()){
148 eps *= (bbmax[0] - bbmin[0]);
149 offset = (bbmax[0] - bbmin[0]) * 0.5;
151 if (tool_->radioY->isChecked()){
153 eps *= (bbmax[1] - bbmin[1]);
154 offset = (bbmax[1] - bbmin[1]) * 0.5;
156 if (tool_->radioZ->isChecked()){
158 eps *= (bbmax[2] - bbmin[2]);
159 offset = (bbmax[2] - bbmin[2]) * 0.5;
162 pos += normal * ( (float)tool_->posSlider->value() / 100.0 ) * (offset + 0.1);
171 bool firstRound =
true;
175 if (tool_->radioTarget->isChecked())
186 o_it->getBoundingBox(cur_min, cur_max);
193 bbmin[0] = std::min( bbmin[0], cur_min[0]);
194 bbmin[1] = std::min( bbmin[1], cur_min[1]);
195 bbmin[2] = std::min( bbmin[2], cur_min[2]);
196 bbmax[0] = std::max( bbmax[0], cur_max[0]);
197 bbmax[1] = std::max( bbmax[1], cur_max[1]);
198 bbmax[2] = std::max( bbmax[2], cur_max[2]);
202 if ((bbmin[0] > bbmax[0]) || (bbmin[1] > bbmax[1]) || (bbmin[2] > bbmax[2]))
203 std::cerr <<
"Error while computing bounding box!";
const DataType DATA_ALL(UINT_MAX)
Identifier for all available objects.
void setMultipassStatus(const MultipassBitMask _passStatus)
Set multipass settings for the nodes status functions.
@ HideNode
Hide this node, but draw children.
@ Active
Draw node & children.
void set_status(StatusMode _s)
Set the status of this node.
void set_plane(const Vec3f &_position, const Vec3f &_normal, float _eps=0.0)
set position and normal of plane
VectorT< float, 3 > Vec3f
void addObjectRenderingNode(ACG::SceneGraph::BaseNode *_node)
Add scenegraph node modifing object rendering.
DLLEXPORT ObjectIterator objectsEnd()
Return Iterator to Object End.
QStringList IteratorRestriction
Iterable object range.
const QStringList TARGET_OBJECTS("target")
Iterable object range.
const QStringList ALL_OBJECTS
Iterable object range.