42#include "QtPlaneSelect.hh"
44#include <ACG/Scenegraph/GlutPrimitiveNode.hh>
46#define PLUGINFUNCTIONS_C
49#include <ACG/QtWidgets/QtColorTranslator.hh>
64QtPlaneSelect::~QtPlaneSelect( )
73void QtPlaneSelect::slotKeyReleaseEvent(QKeyEvent* event)
75 if (event->key() == Qt::Key_Escape){
82 emit updateViewProxy( );
95 if (event->button() == Qt::RightButton){
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);
145 emit nodeVisChangedProxy(planeNode_->
id());
148 targetIdx_ = target_idx;
151 emit updateViewProxy( );
154 case QEvent::MouseMove:
160 emit updateViewProxy( );
164 case QEvent::MouseButtonRelease:
174 emit updateViewProxy( );
176 emit( signalTriggerCut( ) );
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.};
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);
Vec3d unproject(const Vec3d &_winPoint) const
unproject point in window coordinates _winPoint to world coordinates
Vec3d project(const Vec3d &_point) const
project point in world coordinates to window coordinates
int viewport_height() const
get viewport height
void setPlane(const ACG::Vec3d &_position, const ACG::Vec3d &_xDirection, const ACG::Vec3d &)
Set plane.
void setSize(double _xDirection, double _yDirection)
Set plane size.
void delete_subtree()
Delete the whole subtree of this node.
void show()
Show node: set status to Active.
auto length() const -> decltype(std::declval< VectorT< S, DIM > >().norm())
compute squared euclidean norm
auto normalize() -> decltype(*this/=std::declval< VectorT< S, DIM > >().norm())
void update()
updates the plane before the next render call
void slotMouseEvent(QMouseEvent *_event)
void setPlaneAndSize(const ACG::Vec3d &_sourcePoint3D, const ACG::Vec3d &_target2D)
@ PICK_FACE
picks faces (should be implemented for all nodes)
VectorT< double, 3 > Vec3d
double sceneRadius()
Returns the current scene radius from the active examiner widget.
ACG::SceneGraph::BaseNode * getRootNode()
Get the root node for data objects.
bool scenegraphPick(ACG::SceneGraph::PickTarget _pickTarget, const QPoint &_mousePos, size_t &_nodeIdx, size_t &_targetIdx, ACG::Vec3d *_hitPointPtr=0)
Execute picking operation on scenegraph.