42 #include "QtPlaneSelect.hh" 44 #include <ACG/Scenegraph/GlutPrimitiveNode.hh> 46 #define PLUGINFUNCTIONS_C 49 #include <ACG/QtWidgets/QtColorTranslator.hh> 64 QtPlaneSelect::~QtPlaneSelect( )
73 void QtPlaneSelect::slotKeyReleaseEvent(QKeyEvent* event)
75 if (event->key() == Qt::Key_Escape){
78 planeNode_->delete_subtree( );
82 emit updateViewProxy( );
92 unsigned int height = glState.viewport_height();
95 if (event->button() == Qt::RightButton){
98 planeNode_->delete_subtree( );
102 emit updateViewProxy( );
111 switch( event->type() )
113 case QEvent::MouseButtonPress:
117 if ( event->button() != Qt::LeftButton )
121 size_t node_idx, target_idx;
135 if ( planeNode_ == 0 ) {
140 sourcePoint2D =
ACG::Vec3d(event->pos().x(), height -
event->pos().y() - 1.0, 0.0);
142 setPlaneAndSize(sourcePoint3D, sourcePoint2D);
145 emit nodeVisChangedProxy(planeNode_->id());
148 targetIdx_ = target_idx;
151 emit updateViewProxy( );
154 case QEvent::MouseMove:
158 setPlaneAndSize(sourcePoint3D,
ACG::Vec3d(event->pos().x(), height-
event->pos().y()-1.0, 0.0));
160 emit updateViewProxy( );
164 case QEvent::MouseButtonRelease:
170 planeNode_->delete_subtree( );
174 emit updateViewProxy( );
176 emit( signalTriggerCut( ) );
193 ACG::Vec3d source2D = glState.project( _sourcePoint3D );
201 constexpr
auto clamp_angle = M_PI / 12.;
202 const auto newTarget = _target2D - source2D;
203 const auto angle = std::atan2(newTarget[1], newTarget[0]);
204 const auto remainder = std::fmod(angle, clamp_angle);
207 double corrected_angle = .0;
208 if (remainder < clamp_angle / 2.)
209 corrected_angle = angle - remainder;
211 corrected_angle = angle + (clamp_angle - remainder);
213 const auto radius = diff.
length();
214 const auto newTarget2D =
ACG::Vec3d{std::round(radius * std::cos(corrected_angle)), std::round(radius * std::sin(corrected_angle)), 0.} + source2D;
215 const auto newDiff = source2D - newTarget2D;
216 ortho =
ACG::Vec3d{-newDiff[1], newDiff[0], 0.};
223 const auto left = glState.unproject(source2D + ortho * 10. +
ACG::Vec3d{0., 0., 0.});
224 const auto right = glState.unproject(source2D - ortho * 10. +
ACG::Vec3d{0., 0., 0.});
226 const auto leftvec = (left - sourcePoint3D).normalized();
227 const auto rightvec = (right - sourcePoint3D).normalized();
230 normal_ = cross(rightvec, leftvec);
236 const auto sourcePoint3Df(sourcePoint3D);
237 const auto normald(normal_);
238 plane_.setPlane(sourcePoint3Df,normald);
240 planeNode_->update();
bool scenegraphPick(ACG::SceneGraph::PickTarget _pickTarget, const QPoint &_mousePos, size_t &_nodeIdx, size_t &_targetIdx, ACG::Vec3d *_hitPointPtr=0)
Execute picking operation on scenegraph.
picks faces (should be implemented for all nodes)
ACG::SceneGraph::BaseNode * getRootNode()
Get the root node for data objects.
double sceneRadius()
Returns the current scene radius from the active examiner widget.
void setPlaneAndSize(const ACG::Vec3d &_sourcePoint3D, const ACG::Vec3d &_target2D)
void slotMouseEvent(QMouseEvent *_event)
auto length() const -> decltype(std::declval< VectorT< S, DIM >>().norm())
compute squared euclidean norm
VectorT< double, 3 > Vec3d