From d00a8b05c057d9260c5a44408d9a815121ee6cba Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Thu, 6 Jun 2019 10:37:21 +0100 Subject: weld View3DDialog MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ifd689c54574c08f026f6760efb39b5f927cb2625 Reviewed-on: https://gerrit.libreoffice.org/73604 Tested-by: Jenkins Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- include/svx/colorbox.hxx | 1 + include/svx/dlgctl3d.hxx | 147 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 148 insertions(+) (limited to 'include') diff --git a/include/svx/colorbox.hxx b/include/svx/colorbox.hxx index a9b38b7612ba..ed4241fc3ad7 100644 --- a/include/svx/colorbox.hxx +++ b/include/svx/colorbox.hxx @@ -123,6 +123,7 @@ public: Color const & GetSelectEntryColor() const { return m_aSelectedColor.first; } NamedColor const & GetSelectedEntry() const { return m_aSelectedColor; } + void SelectEntry(const NamedColor& rColor); void SelectEntry(const Color& rColor); void SetNoSelection() { getColorWindow()->SetNoSelection(); } diff --git a/include/svx/dlgctl3d.hxx b/include/svx/dlgctl3d.hxx index 82f544031a55..bc105f18ed89 100644 --- a/include/svx/dlgctl3d.hxx +++ b/include/svx/dlgctl3d.hxx @@ -23,6 +23,8 @@ #include #include #include +#include +#include #include #include #include @@ -64,6 +66,34 @@ public: virtual void Set3DAttributes(const SfxItemSet& rAttr); }; +class SAL_WARN_UNUSED SVX_DLLPUBLIC PreviewControl3D : public weld::CustomWidgetController +{ +protected: + std::unique_ptr mpModel; + FmFormPage* mpFmPage; + std::unique_ptr mp3DView; + E3dScene* mpScene; + E3dObject* mp3DObj; + SvxPreviewObjectType mnObjectType; + + void Construct(); + +public: + PreviewControl3D(); + virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override; + virtual ~PreviewControl3D() override; + + virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override; + virtual bool MouseButtonDown( const MouseEvent& rMEvt ) override; + virtual void Resize() override; + + virtual void SetObjectType(SvxPreviewObjectType nType); + SvxPreviewObjectType GetObjectType() const { return mnObjectType; } + SfxItemSet const & Get3DAttributes() const; + virtual void Set3DAttributes(const SfxItemSet& rAttr); +}; + + class SAL_WARN_UNUSED SVX_DLLPUBLIC Svx3DLightControl : public Svx3DPreviewControl { // Callback for interactive changes @@ -134,6 +164,80 @@ public: basegfx::B3DVector GetLightDirection(sal_uInt32 nNum) const; }; +class SAL_WARN_UNUSED SVX_DLLPUBLIC LightControl3D : public PreviewControl3D +{ + // Callback for interactive changes + Link maChangeCallback; + Link maSelectionChangeCallback; + + // lights + sal_uInt32 maSelectedLight; + + // extra objects for light control + E3dObject* mpExpansionObject; + E3dObject* mpLampBottomObject; + E3dObject* mpLampShaftObject; + std::vector< E3dObject* > maLightObjects; + + // 3d rotations of object + double mfRotateX; + double mfRotateY; + double mfRotateZ; + + // interaction parameters + Point maActionStartPoint; + double mfSaveActionStartHor; + double mfSaveActionStartVer; + double mfSaveActionStartRotZ; + + bool mbMouseMoved : 1; + bool mbMouseCaptured : 1; + bool mbGeometrySelected : 1; + + void Construct2(); + void ConstructLightObjects(); + void AdaptToSelectedLight(); + void TrySelection(Point aPosPixel); + +public: + LightControl3D(); + + virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override; + virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override; + virtual tools::Rectangle GetFocusRect() override; + virtual bool MouseButtonDown(const MouseEvent& rMEvt) override; + virtual bool MouseMove( const MouseEvent& rMEvt ) override; + virtual bool MouseButtonUp( const MouseEvent& rMEvt ) override; + virtual void Resize() override; + + virtual void SetObjectType(SvxPreviewObjectType nType) override; + + // register user callback + void SetChangeCallback(Link aNew) { maChangeCallback = aNew; } + void SetSelectionChangeCallback(Link aNew) { maSelectionChangeCallback = aNew; } + + // selection checks + bool IsSelectionValid(); + bool IsGeometrySelected() { return mbGeometrySelected; } + + // get/set position of selected lamp in polar coordinates, Hor:[0..360.0[ and Ver:[-90..90] degrees + void GetPosition(double& rHor, double& rVer); + void SetPosition(double fHor, double fVer); + + // get/set rotation of 3D object + void SetRotation(double fRotX, double fRotY, double fRotZ); + void GetRotation(double& rRotX, double& rRotY, double& rRotZ); + + void SelectLight(sal_uInt32 nLightNumber); + virtual void Set3DAttributes(const SfxItemSet& rAttr) override; + sal_uInt32 GetSelectedLight() { return maSelectedLight; } + + // light data access + bool GetLightOnOff(sal_uInt32 nNum) const; + Color GetLightColor(sal_uInt32 nNum) const; + basegfx::B3DVector GetLightDirection(sal_uInt32 nNum) const; +}; + class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxLightCtl3D final : public Control { // local controls @@ -184,6 +288,49 @@ private: void move( double fDeltaHor, double fDeltaVer ); }; +class SAL_WARN_UNUSED SVX_DLLPUBLIC LightCtl3D +{ + // local controls + LightControl3D& mrLightControl; + weld::Scale& mrHorScroller; + weld::Scale& mrVerScroller; + weld::Button& mrSwitcher; + + // callback for interactive changes + Link maUserInteractiveChangeCallback; + Link maUserSelectionChangeCallback; + +public: + LightCtl3D(LightControl3D& rLightControl, weld::Scale& rHori, + weld::Scale& rVert, weld::Button& rButton); + ~LightCtl3D(); + + // check the selection for validity + void CheckSelection(); + + // bring further settings to the outside world + LightControl3D& GetSvx3DLightControl() { return mrLightControl; } + + // register user callback + void SetUserInteractiveChangeCallback(Link aNew) { maUserInteractiveChangeCallback = aNew; } + void SetUserSelectionChangeCallback(Link aNew) { maUserSelectionChangeCallback = aNew; } + +private: + + DECL_LINK(InternalInteractiveChange, LightControl3D*, void); + DECL_LINK(InternalSelectionChange, LightControl3D*, void); + DECL_LINK(ScrollBarMove, weld::Scale&, void); + DECL_LINK(ButtonPress, weld::Button&, void); + DECL_LINK(KeyInput, const KeyEvent&, bool); + DECL_LINK(FocusIn, weld::Widget&, void); + + // initialize local parameters + void Init(); + + void move( double fDeltaHor, double fDeltaVer ); +}; + + #endif // _SCH_DLGCTL3D_HXX /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit