66 virtual void init( std::shared_ptr<Object> parent ) = 0;
71 void hover() { hoveredControl_ = hover_( pickThrough_ ); }
88 controls_{ controls },
89 name_{ name }{ center_ = controls.
getCenter(); }
91 virtual std::string
name()
const override {
return name_; }
95 auto center = controls_.getCenter();
96 controls_.setCenter( center_ );
100 [[nodiscard]]
virtual size_t heapBytes()
const override {
return name_.capacity(); }
122 bool pickThrough_{
false };
134 float radius{ -1.0f };
137 float coneRadiusFactor{ 1.35f };
139 float coneSizeFactor{ 2.2f };
141 float negativeLineExtension{ 1.15f };
143 float positiveLineExtension{ 1.3f };
145 std::array<
Color, size_t( Axis::Count )> rotationColors{ Color::red(),Color::green(),Color::blue() };
146 std::array<
Color, size_t( Axis::Count )> translationColors{ Color::red(),Color::green(),Color::blue() };
147 Color helperLineColor{ Color::black() };
148 Color activeLineColor{ Color::white() };
155 MRVIEWER_API
virtual void init( std::shared_ptr<Object> parent )
override;
156 MRVIEWER_API
virtual void update()
override;
158 virtual float getRadius()
const override {
return params_.radius; }
171 MRVIEWER_API
virtual ControlBit hover_(
bool pickThrough )
override;
172 MRVIEWER_API
virtual void stopModify_()
override;
173 MRVIEWER_API
virtual void updateVisualTransformMode_(
ControlBit showMask,
ViewportMask viewportMask )
override;
178 std::array<std::shared_ptr<ObjectMesh>, size_t( Axis::Count )> translateControls_;
179 std::array<std::shared_ptr<ObjectMesh>, size_t( Axis::Count )> rotateControls_;
182 std::shared_ptr<ObjectLines> activeLine_;
183 std::array<std::shared_ptr<ObjectLines>, size_t( Axis::Count )> translateLines_;
184 std::array<std::shared_ptr<ObjectLines>, size_t( Axis::Count )> rotateLines_;
186 std::shared_ptr<ObjectMesh> hoveredObject_;
187 int findHoveredIndex_()
const;
188 void setActiveLineFromPoints_(
const Contour3f& points );
200 MRVIEWER_API
void create(
const Box3f& box,
const AffineXf3f& xf, std::shared_ptr<ITransformControls> controls = {} );
229 std::shared_ptr<ITransformControls>
getControls()
const {
return controls_; }
231 std::shared_ptr<T>
getControlsAs()
const {
return std::dynamic_pointer_cast< T >( controls_ ); }
268 if ( widget_.controlsRoot_ )
270 xf_ = widget_.controlsRoot_->xfsForAllViewports();
271 scaledXf_ = widget_.scaledXf_;
275 virtual std::string
name()
const override
282 if ( !widget_.controlsRoot_ )
284 auto tmpXf = widget_.controlsRoot_->xfsForAllViewports();
285 widget_.controlsRoot_->setXfsForAllViewports( xf_ );
288 std::swap( scaledXf_, widget_.scaledXf_ );
293 return name_.capacity();
303 MRVIEWER_API
virtual bool onMouseDown_(
Viewer::MouseButton button,
int modifier )
override;
305 MRVIEWER_API
virtual bool onMouseMove_(
int mouse_x,
int mouse_y )
override;
306 MRVIEWER_API
virtual void preDraw_()
override;
307 MRVIEWER_API
virtual void postDraw_()
override;
309 void activeMove_(
bool press =
false );
311 void processScaling_(
Axis ax,
bool press );
312 void processTranslation_(
Axis ax,
bool press );
313 void processRotation_(
Axis ax,
bool press );
317 std::weak_ptr<Object> visibilityParent_;
324 std::shared_ptr<Object> controlsRoot_;
325 std::shared_ptr<ITransformControls> controls_;
327 AxisTransformMode axisTransformMode_{ AxisTranslation };
336 ActiveEditMode activeEditMode_{ TranslationMode };
342 ViewportProperty<AffineXf3f> scaledXf_;
344 float currentScaling_ = 1.0f;
349 float accumShift_ = 0;
351 float startAngle_ = 0;
352 float accumAngle_ = 0;
354 ViewportProperty<ControlBit> transformModeMask_{ ControlBit::FullMask };
355 bool picked_{
false };
357 std::function<void(
float )> scaleTooltipCallback_;
358 std::function<void(
float )> translateTooltipCallback_;
359 std::function<void(
float )> rotateTooltipCallback_;
361 std::function<void()> startModifyCallback_;
362 std::function<void()> stopModifyCallback_;
363 std::function<void(
const AffineXf3f& )> addXfCallback_;
364 std::function<bool(
const AffineXf3f& )> approveXfCallback_;
365 bool approvedChange_ =
true;
366 boost::signals2::connection xfValidatorConnection_;
#define MR_MAKE_FLAG_OPERATORS(T)
Definition MRFlagOperators.h:6
affine transformation: y = A*x + b, where A in VxV, and b in V
Definition MRDotNet/MRAffineXf.h:8
Definition MRHistoryAction.h:12
Type
Definition MRHistoryAction.h:19
Definition MRViewportId.h:16
stores mask of viewport unique identifiers
Definition MRViewportId.h:38
Definition MRViewportProperty.h:17
represents a 3-dimentional float-typed vector
Definition MRDotNet/MRVector3.h:8
auto width(const Box< V > &box)
returns size along x axis
Definition MRMesh/MRBox.h:230
@ None
special value not to limit path in one slice
Definition MRVoxelPath.h:33
Definition MRCameraOrientationPlugin.h:7
Axis
Definition MRAxis.h:6
MouseButton
Definition MRMouse.h:9
std::function< ControlBit(const Vector3f ¢er, const AffineXf3f &xf, ViewportId)> TransformModesValidator
Definition MRObjectTransformWidget.h:38
ControlBit
Definition MRObjectTransformWidget.h:22
Contour3< float > Contour3f
Definition MRMesh/MRMeshFwd.h:276
Definition MRViewerEventsListener.h:29