47 const Vector3f&
getCenter()
const {
return center_; }
48 MRVIEWER_API
void setCenter(
const Vector3f& center );
68 virtual void init( std::shared_ptr<Object> parent ) = 0;
73 void hover() { hoveredControl_ = hover_( pickThrough_ ); }
90 controls_{ controls },
91 name_{ name }{ center_ = controls.
getCenter(); }
93 virtual std::string
name()
const override {
return name_; }
97 auto center = controls_.getCenter();
98 controls_.setCenter( center_ );
102 [[nodiscard]]
virtual size_t heapBytes()
const override {
return name_.capacity(); }
124 bool pickThrough_{
false };
144 MRVIEWER_API
void update(
const Box3f& box );
147 float radius{ -1.0f };
154 float coneRadiusFactor{ 1.35f };
156 float coneSizeFactor{ 2.2f };
158 float negativeLineExtension{ 1.15f };
160 float positiveLineExtension{ 1.3f };
162 std::array<
Color, size_t( Axis::Count )> rotationColors{ Color::red(),Color::green(),Color::blue() };
163 std::array<
Color, size_t( Axis::Count )> translationColors{ Color::red(),Color::green(),Color::blue() };
164 Color helperLineColor{ Color::black() };
165 Color activeLineColor{ Color::white() };
172 MRVIEWER_API
virtual void init( std::shared_ptr<Object> parent )
override;
173 MRVIEWER_API
virtual void update()
override;
175 virtual float getRadius()
const override {
return params_.radius; }
196 void resetSizeInPixel_();
198 MRVIEWER_API
virtual ControlBit hover_(
bool pickThrough )
override;
199 MRVIEWER_API
virtual void stopModify_()
override;
200 MRVIEWER_API
virtual void updateVisualTransformMode_(
ControlBit showMask,
ViewportMask viewportMask )
override;
205 std::array<std::shared_ptr<ObjectMesh>, size_t( Axis::Count )> translateControls_;
206 std::array<std::shared_ptr<ObjectMesh>, size_t( Axis::Count )> rotateControls_;
209 std::shared_ptr<ObjectLines> activeLine_;
210 std::array<std::shared_ptr<ObjectLines>, size_t( Axis::Count )> translateLines_;
211 std::array<std::shared_ptr<ObjectLines>, size_t( Axis::Count )> rotateLines_;
213 std::shared_ptr<ObjectMesh> hoveredObject_;
214 int findHoveredIndex_()
const;
215 void setActiveLineFromPoints_(
const Contour3f& points );
227 MRVIEWER_API
void create(
const Box3f& box,
const AffineXf3f& xf, std::shared_ptr<ITransformControls> controls = {} );
256 std::shared_ptr<ITransformControls>
getControls()
const {
return controls_; }
258 std::shared_ptr<T>
getControlsAs()
const {
return std::dynamic_pointer_cast< T >( controls_ ); }
282 void setAddXfCallback( std::function<
void(
const AffineXf3f& )> callback ) { addXfCallback_ = callback; }
285 void setApproveXfCallback( std::function<
bool(
const AffineXf3f& )> callback ) { approveXfCallback_ = callback; }
295 if ( widget_.controlsRoot_ )
297 xf_ = widget_.controlsRoot_->xfsForAllViewports();
298 scaledXf_ = widget_.scaledXf_;
302 virtual std::string
name()
const override
309 if ( !widget_.controlsRoot_ )
311 auto tmpXf = widget_.controlsRoot_->xfsForAllViewports();
312 widget_.controlsRoot_->setXfsForAllViewports( xf_ );
315 std::swap( scaledXf_, widget_.scaledXf_ );
320 return name_.capacity();
330 MRVIEWER_API
virtual bool onMouseDown_(
MouseButton button,
int modifier )
override;
331 MRVIEWER_API
virtual bool onMouseUp_(
MouseButton button,
int modifier )
override;
332 MRVIEWER_API
virtual bool onMouseMove_(
int mouse_x,
int mouse_y )
override;
333 MRVIEWER_API
virtual void preDraw_()
override;
334 MRVIEWER_API
virtual void postDraw_()
override;
336 void activeMove_(
bool press =
false );
338 void processScaling_(
Axis ax,
bool press );
339 void processTranslation_(
Axis ax,
bool press );
340 void processRotation_(
Axis ax,
bool press );
342 void setControlsXf_(
const AffineXf3f& xf,
bool updateScaled,
ViewportId id = {} );
344 std::weak_ptr<Object> visibilityParent_;
347 void addXf_(
const AffineXf3f& addXf );
351 std::shared_ptr<Object> controlsRoot_;
352 std::shared_ptr<ITransformControls> controls_;
354 AxisTransformMode axisTransformMode_{ AxisTranslation };
363 ActiveEditMode activeEditMode_{ TranslationMode };
367 Vector3f boxDiagonal_;
369 ViewportProperty<AffineXf3f> scaledXf_;
371 float currentScaling_ = 1.0f;
373 Vector3f prevScaling_;
374 Vector3f startTranslation_;
375 Vector3f prevTranslation_;
376 float accumShift_ = 0;
378 float startAngle_ = 0;
379 float accumAngle_ = 0;
381 ViewportProperty<ControlBit> transformModeMask_{ ControlBit::FullMask };
382 bool picked_{
false };
384 std::function<void(
float )> scaleTooltipCallback_;
385 std::function<void(
float )> translateTooltipCallback_;
386 std::function<void(
float )> rotateTooltipCallback_;
388 std::function<void()> startModifyCallback_;
389 std::function<void()> stopModifyCallback_;
390 std::function<void(
const AffineXf3f& )> addXfCallback_;
391 std::function<bool(
const AffineXf3f& )> approveXfCallback_;
392 bool approvedChange_ =
true;
393 boost::signals2::connection xfValidatorConnection_;
#define MR_MAKE_FLAG_OPERATORS(T)
Definition MRFlagOperators.h:6
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
auto width(const Box< V > &box)
returns size along x axis
Definition MRMesh/MRBox.h:247
@ None
special value not to limit path in one slice
Definition MRVoxelPath.h:33
Axis
Definition MRAxis.h:6
MouseButton
Definition MRMouse.h:9
std::function< ControlBit(const Vector3f ¢er, const AffineXf3f &xf, ViewportId)> TransformModesValidator
Definition MRObjectTransformWidget.h:37
LengthUnit
Definition MRUnits.h:24
ControlBit
Definition MRObjectTransformWidget.h:21
Contour3< float > Contour3f
Definition MRMesh/MRMeshFwd.h:299
Definition MRMesh/MRColor.h:9
Definition MRViewerEventsListener.h:29