47 const Vector3f&
getCenter()
const {
return center_; }
48 MRVIEWER_API
void setCenter(
const Vector3f& center );
65 virtual void init( std::shared_ptr<Object> parent ) = 0;
70 void hover() { hoveredControl_ = hover_( pickThrough_ ); }
80 virtual void updateRotation(
Axis ax,
const AffineXf3f& xf,
float startAngle,
float endAngle ) = 0;
87 controls_{ controls },
88 name_{ name }{ center_ = controls.
getCenter(); }
90 virtual std::string
name()
const override {
return name_; }
94 auto center = controls_.getCenter();
95 controls_.setCenter( center_ );
99 [[nodiscard]]
virtual size_t heapBytes()
const override {
return name_.capacity(); }
121 bool pickThrough_{
false };
132 MRVIEWER_API
void update(
const Box3f& box );
134 float radius{ -1.0f };
138 float coneRadiusFactor{ 1.35f };
140 float coneSizeFactor{ 2.2f };
142 float negativeLineExtension{ 1.15f };
144 float positiveLineExtension{ 1.3f };
146 std::array<
Color, size_t( Axis::Count )> rotationColors{ Color::red(),Color::green(),Color::blue() };
147 std::array<
Color, size_t( Axis::Count )> translationColors{ Color::red(),Color::green(),Color::blue() };
148 Color helperLineColor{ Color::black() };
149 Color activeLineColor{ Color::white() };
156 MRVIEWER_API
virtual void init( std::shared_ptr<Object> parent )
override;
157 MRVIEWER_API
virtual void update()
override;
159 virtual float getRadius()
const override {
return params_.radius; }
169 MRVIEWER_API
virtual void updateTranslation(
Axis ax,
const Vector3f& startMove,
const Vector3f& endMove )
override;
170 MRVIEWER_API
virtual void updateRotation(
Axis ax,
const AffineXf3f& xf,
float startAngle,
float endAngle )
override;
175 MRVIEWER_API
virtual ControlBit hover_(
bool pickThrough )
override;
176 MRVIEWER_API
virtual void stopModify_()
override;
177 MRVIEWER_API
virtual void updateVisualTransformMode_(
ControlBit showMask,
ViewportMask viewportMask )
override;
182 std::array<std::shared_ptr<ObjectMesh>, size_t( Axis::Count )> translateControls_;
183 std::array<std::shared_ptr<ObjectMesh>, size_t( Axis::Count )> rotateControls_;
186 std::shared_ptr<ObjectLines> activeLine_;
187 std::array<std::shared_ptr<ObjectLines>, size_t( Axis::Count )> translateLines_;
188 std::array<std::shared_ptr<ObjectLines>, size_t( Axis::Count )> rotateLines_;
190 std::shared_ptr<ObjectMesh> hoveredObject_;
191 int findHoveredIndex_()
const;
192 void setActiveLineFromPoints_(
const Contour3f& points );
204 MRVIEWER_API
void create(
const Box3f& box,
const AffineXf3f& xf, std::shared_ptr<ITransformControls> controls = {} );
233 std::shared_ptr<ITransformControls>
getControls()
const {
return controls_; }
235 std::shared_ptr<T>
getControlsAs()
const {
return std::dynamic_pointer_cast< T >( controls_ ); }
259 void setAddXfCallback( std::function<
void(
const AffineXf3f& )> callback ) { addXfCallback_ = callback; }
262 void setApproveXfCallback( std::function<
bool(
const AffineXf3f& )> callback ) { approveXfCallback_ = callback; }
272 if ( widget_.controlsRoot_ )
274 xf_ = widget_.controlsRoot_->xfsForAllViewports();
275 scaledXf_ = widget_.scaledXf_;
279 virtual std::string
name()
const override
286 if ( !widget_.controlsRoot_ )
288 auto tmpXf = widget_.controlsRoot_->xfsForAllViewports();
289 widget_.controlsRoot_->setXfsForAllViewports( xf_ );
292 std::swap( scaledXf_, widget_.scaledXf_ );
297 return name_.capacity();
307 MRVIEWER_API
virtual bool onMouseDown_(
MouseButton button,
int modifier )
override;
308 MRVIEWER_API
virtual bool onMouseUp_(
MouseButton button,
int modifier )
override;
309 MRVIEWER_API
virtual bool onMouseMove_(
int mouse_x,
int mouse_y )
override;
310 MRVIEWER_API
virtual void preDraw_()
override;
311 MRVIEWER_API
virtual void postDraw_()
override;
313 void activeMove_(
bool press =
false );
315 void processScaling_(
Axis ax,
bool press );
316 void processTranslation_(
Axis ax,
bool press );
317 void processRotation_(
Axis ax,
bool press );
319 void setControlsXf_(
const AffineXf3f& xf,
bool updateScaled,
ViewportId id = {} );
321 std::weak_ptr<Object> visibilityParent_;
324 void addXf_(
const AffineXf3f& addXf );
328 std::shared_ptr<Object> controlsRoot_;
329 std::shared_ptr<ITransformControls> controls_;
331 AxisTransformMode axisTransformMode_{ AxisTranslation };
340 ActiveEditMode activeEditMode_{ TranslationMode };
344 Vector3f boxDiagonal_;
346 ViewportProperty<AffineXf3f> scaledXf_;
348 float currentScaling_ = 1.0f;
350 Vector3f prevScaling_;
351 Vector3f startTranslation_;
352 Vector3f prevTranslation_;
353 float accumShift_ = 0;
355 float startAngle_ = 0;
356 float accumAngle_ = 0;
358 ViewportProperty<ControlBit> transformModeMask_{ ControlBit::FullMask };
359 bool picked_{
false };
361 std::function<void(
float )> scaleTooltipCallback_;
362 std::function<void(
float )> translateTooltipCallback_;
363 std::function<void(
float )> rotateTooltipCallback_;
365 std::function<void()> startModifyCallback_;
366 std::function<void()> stopModifyCallback_;
367 std::function<void(
const AffineXf3f& )> addXfCallback_;
368 std::function<bool(
const AffineXf3f& )> approveXfCallback_;
369 bool approvedChange_ =
true;
370 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
Definition MRCameraOrientationPlugin.h:8
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
ControlBit
Definition MRObjectTransformWidget.h:21
Contour3< float > Contour3f
Definition MRMesh/MRMeshFwd.h:277
Definition MRViewerEventsListener.h:29