LibreOffice Module svx (master)  1
dlgctl3d.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #ifndef INCLUDED_SVX_DLGCTL3D_HXX
21 #define INCLUDED_SVX_DLGCTL3D_HXX
22 
23 #include <vcl/customweld.hxx>
24 #include <vcl/weld.hxx>
25 #include <svl/itemset.hxx>
26 #include <svx/svxdllapi.h>
28 #include <memory>
29 
30 class FmFormModel;
31 class FmFormPage;
32 class E3dView;
33 class E3dObject;
34 class E3dScene;
35 
37 
39 {
40 protected:
41  std::unique_ptr<FmFormModel> mpModel;
43  std::unique_ptr<E3dView> mp3DView;
47 
48  void Construct();
49 
50 public:
52  virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
53  virtual ~Svx3DPreviewControl() override;
54 
55  virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
56  virtual bool MouseButtonDown( const MouseEvent& rMEvt ) override;
57  virtual void Resize() override;
58 
59  virtual void SetObjectType(SvxPreviewObjectType nType);
60  SvxPreviewObjectType GetObjectType() const { return mnObjectType; }
61  SfxItemSet const & Get3DAttributes() const;
62  virtual void Set3DAttributes(const SfxItemSet& rAttr);
63 };
64 
66 {
67  // Callback for interactive changes
70 
71  // lights
72  sal_uInt32 maSelectedLight;
73 
74  // extra objects for light control
78  std::vector< E3dObject* > maLightObjects;
79 
80  // 3d rotations of object
81  double mfRotateX;
82  double mfRotateY;
83  double mfRotateZ;
84 
85  // interaction parameters
90 
91  bool mbMouseMoved : 1;
92  bool mbMouseCaptured : 1;
93  bool mbGeometrySelected : 1;
94 
95  void Construct2();
96  void ConstructLightObjects();
97  void AdaptToSelectedLight();
98  void TrySelection(Point aPosPixel);
99 
100 public:
102 
103  virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
104  virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override;
105  virtual tools::Rectangle GetFocusRect() override;
106  virtual bool MouseButtonDown(const MouseEvent& rMEvt) override;
107  virtual bool MouseMove( const MouseEvent& rMEvt ) override;
108  virtual bool MouseButtonUp( const MouseEvent& rMEvt ) override;
109  virtual void Resize() override;
110 
111  virtual void SetObjectType(SvxPreviewObjectType nType) override;
112 
113  // register user callback
114  void SetChangeCallback(Link<Svx3DLightControl*,void> aNew) { maChangeCallback = aNew; }
115  void SetSelectionChangeCallback(Link<Svx3DLightControl*,void> aNew) { maSelectionChangeCallback = aNew; }
116 
117  // selection checks
118  bool IsSelectionValid();
119  bool IsGeometrySelected() const { return mbGeometrySelected; }
120 
121  // get/set position of selected lamp in polar coordinates, Hor:[0..360.0[ and Ver:[-90..90] degrees
122  void GetPosition(double& rHor, double& rVer);
123  void SetPosition(double fHor, double fVer);
124 
125  // get/set rotation of 3D object
126  void SetRotation(double fRotX, double fRotY, double fRotZ);
127  void GetRotation(double& rRotX, double& rRotY, double& rRotZ);
128 
129  void SelectLight(sal_uInt32 nLightNumber);
130  virtual void Set3DAttributes(const SfxItemSet& rAttr) override;
131  sal_uInt32 GetSelectedLight() const { return maSelectedLight; }
132 
133  // light data access
134  bool GetLightOnOff(sal_uInt32 nNum) const;
135  Color GetLightColor(sal_uInt32 nNum) const;
136  basegfx::B3DVector GetLightDirection(sal_uInt32 nNum) const;
137 };
138 
140 {
141  // local controls
146 
147  // callback for interactive changes
150 
151 public:
152  SvxLightCtl3D(Svx3DLightControl& rLightControl, weld::Scale& rHori,
153  weld::Scale& rVert, weld::Button& rButton);
154  ~SvxLightCtl3D();
155 
156  // check the selection for validity
157  void CheckSelection();
158 
159  // bring further settings to the outside world
160  Svx3DLightControl& GetSvx3DLightControl() { return mrLightControl; }
161 
162  // register user callback
163  void SetUserInteractiveChangeCallback(Link<SvxLightCtl3D*,void> aNew) { maUserInteractiveChangeCallback = aNew; }
164  void SetUserSelectionChangeCallback(Link<SvxLightCtl3D*,void> aNew) { maUserSelectionChangeCallback = aNew; }
165 
166 private:
167 
168  DECL_LINK(InternalInteractiveChange, Svx3DLightControl*, void);
169  DECL_LINK(InternalSelectionChange, Svx3DLightControl*, void);
170  DECL_LINK(ScrollBarMove, weld::Scale&, void);
171  DECL_LINK(ButtonPress, weld::Button&, void);
172  DECL_LINK(KeyInput, const KeyEvent&, bool);
173  DECL_LINK(FocusIn, weld::Widget&, void);
174 
175  // initialize local parameters
176  void Init();
177 
178  void move( double fDeltaHor, double fDeltaVer );
179 };
180 
181 
182 #endif // _SCH_DLGCTL3D_HXX
183 
184 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::unique_ptr< E3dView > mp3DView
Definition: dlgctl3d.hxx:43
E3dScene * mpScene
Definition: dlgctl3d.hxx:44
void SetUserInteractiveChangeCallback(Link< SvxLightCtl3D *, void > aNew)
Definition: dlgctl3d.hxx:163
weld::Scale & mrVerScroller
Definition: dlgctl3d.hxx:144
void Init()
Point maActionStartPoint
Definition: dlgctl3d.hxx:86
Link< SvxLightCtl3D *, void > maUserInteractiveChangeCallback
Definition: dlgctl3d.hxx:148
double mfSaveActionStartVer
Definition: dlgctl3d.hxx:88
bool IsGeometrySelected() const
Definition: dlgctl3d.hxx:119
virtual bool MouseButtonUp(const MouseEvent &)
void SetUserSelectionChangeCallback(Link< SvxLightCtl3D *, void > aNew)
Definition: dlgctl3d.hxx:164
weld::Scale & mrHorScroller
Definition: dlgctl3d.hxx:143
virtual bool MouseMove(const MouseEvent &)
virtual void Set3DAttributes(const SfxItemSet &rAttr)
Definition: dlgctl3d.cxx:232
#define SVX_DLLPUBLIC
Definition: svxdllapi.h:28
sal_uInt32 GetSelectedLight() const
Definition: dlgctl3d.hxx:131
Link< Svx3DLightControl *, void > maSelectionChangeCallback
Definition: dlgctl3d.hxx:69
E3dObject * mp3DObj
Definition: dlgctl3d.hxx:45
bool mbMouseCaptured
Link< Svx3DLightControl *, void > maChangeCallback
Definition: dlgctl3d.hxx:68
void SetSelectionChangeCallback(Link< Svx3DLightControl *, void > aNew)
Definition: dlgctl3d.hxx:115
E3dObject * mpLampShaftObject
Definition: dlgctl3d.hxx:77
Link< SvxLightCtl3D *, void > maUserSelectionChangeCallback
Definition: dlgctl3d.hxx:149
std::unique_ptr< FmFormModel > mpModel
Definition: dlgctl3d.hxx:41
std::vector< E3dObject * > maLightObjects
Definition: dlgctl3d.hxx:78
E3dObject * mpLampBottomObject
Definition: dlgctl3d.hxx:76
Svx3DLightControl & GetSvx3DLightControl()
Definition: dlgctl3d.hxx:160
virtual tools::Rectangle GetFocusRect()
virtual void Resize() override
Definition: dlgctl3d.cxx:142
sal_uInt32 maSelectedLight
Definition: dlgctl3d.hxx:72
Svx3DLightControl & mrLightControl
Definition: dlgctl3d.hxx:142
FmFormPage * mpFmPage
Definition: dlgctl3d.hxx:42
#define SAL_WARN_UNUSED
double mfSaveActionStartHor
Definition: dlgctl3d.hxx:87
void CheckSelection(struct ESelection &rSel, SvxTextForwarder const *pForwarder)
Derived class of SdrView to edit 3D objects.
Definition: view3d.hxx:41
weld::Button & mrSwitcher
Definition: dlgctl3d.hxx:145
virtual void SetObjectType(SvxPreviewObjectType nType)
Definition: dlgctl3d.cxx:178
virtual bool MouseButtonDown(const MouseEvent &)
virtual void SetDrawingArea(weld::DrawingArea *pDrawingArea) override
Definition: dlgctl3d.cxx:55
virtual void SetDrawingArea(weld::DrawingArea *pDrawingArea)
E3dObject * mpExpansionObject
Definition: dlgctl3d.hxx:75
SvxPreviewObjectType GetObjectType() const
Definition: dlgctl3d.hxx:60
SvxPreviewObjectType mnObjectType
Definition: dlgctl3d.hxx:46
double mfSaveActionStartRotZ
Definition: dlgctl3d.hxx:89
void SetChangeCallback(Link< Svx3DLightControl *, void > aNew)
Definition: dlgctl3d.hxx:114
SvxPreviewObjectType
Definition: dlgctl3d.hxx:36
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect)=0
virtual bool MouseButtonDown(const MouseEvent &rMEvt) override
Definition: dlgctl3d.cxx:162
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
Definition: dlgctl3d.cxx:157