1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_SVX_DLGCTL3D_HXX
21 #define INCLUDED_SVX_DLGCTL3D_HXX
23 #include <vcl/customweld.hxx>
24 #include <vcl/weld.hxx>
25 #include <svl/itemset.hxx>
26 #include <svx/svxdllapi.h>
27 #include <svx/obj3d.hxx>
28 #include <basegfx/vector/b3dvector.hxx>
37 enum class SvxPreviewObjectType
{ SPHERE
, CUBE
};
39 class SAL_WARN_UNUSED
UNLESS_MERGELIBS(SVX_DLLPUBLIC
) Svx3DPreviewControl
: public weld::CustomWidgetController
42 std::unique_ptr
<FmFormModel
> mpModel
;
43 rtl::Reference
<FmFormPage
> mxFmPage
;
44 std::unique_ptr
<E3dView
> mp3DView
;
45 rtl::Reference
<E3dScene
> mpScene
;
46 rtl::Reference
<E3dObject
> mp3DObj
;
47 SvxPreviewObjectType mnObjectType
;
52 Svx3DPreviewControl();
53 virtual void SetDrawingArea(weld::DrawingArea
* pDrawingArea
) override
;
54 virtual ~Svx3DPreviewControl() override
;
56 virtual void Paint( vcl::RenderContext
& rRenderContext
, const tools::Rectangle
& rRect
) override
;
57 virtual bool MouseButtonDown( const MouseEvent
& rMEvt
) override
;
58 virtual void Resize() override
;
60 virtual void SetObjectType(SvxPreviewObjectType nType
);
61 SvxPreviewObjectType
GetObjectType() const { return mnObjectType
; }
62 SfxItemSet
const & Get3DAttributes() const;
63 virtual void Set3DAttributes(const SfxItemSet
& rAttr
);
67 class SAL_WARN_UNUSED
UNLESS_MERGELIBS(SVX_DLLPUBLIC
) Svx3DLightControl final
: public Svx3DPreviewControl
69 // Callback for interactive changes
70 Link
<Svx3DLightControl
*,void> maChangeCallback
;
71 Link
<Svx3DLightControl
*,void> maSelectionChangeCallback
;
74 sal_uInt32 maSelectedLight
;
76 // extra objects for light control
77 rtl::Reference
<E3dObject
> mpExpansionObject
;
78 rtl::Reference
<E3dObject
> mpLampBottomObject
;
79 rtl::Reference
<E3dObject
> mpLampShaftObject
;
80 std::vector
< E3dObject
* > maLightObjects
;
82 // 3d rotations of object
87 // interaction parameters
88 Point maActionStartPoint
;
89 double mfSaveActionStartHor
;
90 double mfSaveActionStartVer
;
91 double mfSaveActionStartRotZ
;
93 bool mbMouseMoved
: 1;
94 bool mbMouseCaptured
: 1;
95 bool mbGeometrySelected
: 1;
98 void ConstructLightObjects();
99 void AdaptToSelectedLight();
100 void TrySelection(Point aPosPixel
);
105 virtual void SetDrawingArea(weld::DrawingArea
* pDrawingArea
) override
;
106 virtual void Paint(vcl::RenderContext
& rRenderContext
, const tools::Rectangle
& rRect
) override
;
107 virtual tools::Rectangle
GetFocusRect() override
;
108 virtual bool MouseButtonDown(const MouseEvent
& rMEvt
) override
;
109 virtual bool MouseMove( const MouseEvent
& rMEvt
) override
;
110 virtual bool MouseButtonUp( const MouseEvent
& rMEvt
) override
;
111 virtual void Resize() override
;
113 virtual void SetObjectType(SvxPreviewObjectType nType
) override
;
115 // register user callback
116 void SetChangeCallback(Link
<Svx3DLightControl
*,void> aNew
) { maChangeCallback
= aNew
; }
117 void SetSelectionChangeCallback(Link
<Svx3DLightControl
*,void> aNew
) { maSelectionChangeCallback
= aNew
; }
120 bool IsSelectionValid();
121 bool IsGeometrySelected() const { return mbGeometrySelected
; }
123 // get/set position of selected lamp in polar coordinates, Hor:[0..360.0[ and Ver:[-90..90] degrees
124 void GetPosition(double& rHor
, double& rVer
);
125 void SetPosition(double fHor
, double fVer
);
127 // get/set rotation of 3D object
128 void SetRotation(double fRotX
, double fRotY
, double fRotZ
);
129 void GetRotation(double& rRotX
, double& rRotY
, double& rRotZ
);
131 void SelectLight(sal_uInt32 nLightNumber
);
132 virtual void Set3DAttributes(const SfxItemSet
& rAttr
) override
;
133 sal_uInt32
GetSelectedLight() const { return maSelectedLight
; }
136 bool GetLightOnOff(sal_uInt32 nNum
) const;
137 Color
GetLightColor(sal_uInt32 nNum
) const;
138 basegfx::B3DVector
GetLightDirection(sal_uInt32 nNum
) const;
141 class SAL_WARN_UNUSED
UNLESS_MERGELIBS(SVX_DLLPUBLIC
) SvxLightCtl3D
144 Svx3DLightControl
& mrLightControl
;
145 weld::Scale
& mrHorScroller
;
146 weld::Scale
& mrVerScroller
;
147 weld::Button
& mrSwitcher
;
149 // callback for interactive changes
150 Link
<SvxLightCtl3D
*,void> maUserInteractiveChangeCallback
;
151 Link
<SvxLightCtl3D
*,void> maUserSelectionChangeCallback
;
154 SvxLightCtl3D(Svx3DLightControl
& rLightControl
, weld::Scale
& rHori
,
155 weld::Scale
& rVert
, weld::Button
& rButton
);
157 // check the selection for validity
158 void CheckSelection();
160 // bring further settings to the outside world
161 Svx3DLightControl
& GetSvx3DLightControl() { return mrLightControl
; }
163 // register user callback
164 void SetUserInteractiveChangeCallback(Link
<SvxLightCtl3D
*,void> aNew
) { maUserInteractiveChangeCallback
= aNew
; }
165 void SetUserSelectionChangeCallback(Link
<SvxLightCtl3D
*,void> aNew
) { maUserSelectionChangeCallback
= aNew
; }
169 DECL_DLLPRIVATE_LINK(InternalInteractiveChange
, Svx3DLightControl
*, void);
170 DECL_DLLPRIVATE_LINK(InternalSelectionChange
, Svx3DLightControl
*, void);
171 DECL_DLLPRIVATE_LINK(ScrollBarMove
, weld::Scale
&, void);
172 DECL_DLLPRIVATE_LINK(ButtonPress
, weld::Button
&, void);
173 DECL_DLLPRIVATE_LINK(KeyInput
, const KeyEvent
&, bool);
174 DECL_DLLPRIVATE_LINK(FocusIn
, weld::Widget
&, void);
176 // initialize local parameters
179 void move( double fDeltaHor
, double fDeltaVer
);
183 #endif // _SCH_DLGCTL3D_HXX
185 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */