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
30class FmFormModel;
31class FmFormPage;
32class E3dView;
33class E3dObject;
34class E3dScene;
35
37
39{
40protected:
41 std::unique_ptr<FmFormModel> mpModel;
43 std::unique_ptr<E3dView> mp3DView;
47
48 void Construct();
49
50public:
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;
94
95 void Construct2();
96 void ConstructLightObjects();
97 void AdaptToSelectedLight();
98 void TrySelection(Point aPosPixel);
99
100public:
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
151public:
152 SvxLightCtl3D(Svx3DLightControl& rLightControl, weld::Scale& rHori,
153 weld::Scale& rVert, weld::Button& rButton);
154
155 // check the selection for validity
156 void CheckSelection();
157
158 // bring further settings to the outside world
159 Svx3DLightControl& GetSvx3DLightControl() { return mrLightControl; }
160
161 // register user callback
162 void SetUserInteractiveChangeCallback(Link<SvxLightCtl3D*,void> aNew) { maUserInteractiveChangeCallback = aNew; }
163 void SetUserSelectionChangeCallback(Link<SvxLightCtl3D*,void> aNew) { maUserSelectionChangeCallback = aNew; }
164
165private:
166
167 DECL_DLLPRIVATE_LINK(InternalInteractiveChange, Svx3DLightControl*, void);
168 DECL_DLLPRIVATE_LINK(InternalSelectionChange, Svx3DLightControl*, void);
169 DECL_DLLPRIVATE_LINK(ScrollBarMove, weld::Scale&, void);
170 DECL_DLLPRIVATE_LINK(ButtonPress, weld::Button&, void);
171 DECL_DLLPRIVATE_LINK(KeyInput, const KeyEvent&, bool);
173
174 // initialize local parameters
175 void Init();
176
177 void move( double fDeltaHor, double fDeltaVer );
178};
179
180
181#endif // _SCH_DLGCTL3D_HXX
182
183/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Derived class of SdrView to edit 3D objects.
Definition: view3d.hxx:42
sal_uInt32 maSelectedLight
Definition: dlgctl3d.hxx:72
Link< Svx3DLightControl *, void > maChangeCallback
Definition: dlgctl3d.hxx:68
rtl::Reference< E3dObject > mpExpansionObject
Definition: dlgctl3d.hxx:75
void SetChangeCallback(Link< Svx3DLightControl *, void > aNew)
Definition: dlgctl3d.hxx:114
double mfSaveActionStartVer
Definition: dlgctl3d.hxx:88
Point maActionStartPoint
Definition: dlgctl3d.hxx:86
bool mbGeometrySelected
Definition: dlgctl3d.hxx:93
std::vector< E3dObject * > maLightObjects
Definition: dlgctl3d.hxx:78
void SetSelectionChangeCallback(Link< Svx3DLightControl *, void > aNew)
Definition: dlgctl3d.hxx:115
double mfSaveActionStartHor
Definition: dlgctl3d.hxx:87
double mfSaveActionStartRotZ
Definition: dlgctl3d.hxx:89
bool IsGeometrySelected() const
Definition: dlgctl3d.hxx:119
rtl::Reference< E3dObject > mpLampBottomObject
Definition: dlgctl3d.hxx:76
rtl::Reference< E3dObject > mpLampShaftObject
Definition: dlgctl3d.hxx:77
Link< Svx3DLightControl *, void > maSelectionChangeCallback
Definition: dlgctl3d.hxx:69
sal_uInt32 GetSelectedLight() const
Definition: dlgctl3d.hxx:131
SvxPreviewObjectType GetObjectType() const
Definition: dlgctl3d.hxx:60
std::unique_ptr< FmFormModel > mpModel
Definition: dlgctl3d.hxx:41
std::unique_ptr< E3dView > mp3DView
Definition: dlgctl3d.hxx:43
rtl::Reference< E3dObject > mp3DObj
Definition: dlgctl3d.hxx:45
rtl::Reference< E3dScene > mpScene
Definition: dlgctl3d.hxx:44
rtl::Reference< FmFormPage > mxFmPage
Definition: dlgctl3d.hxx:42
SvxPreviewObjectType mnObjectType
Definition: dlgctl3d.hxx:46
void SetUserSelectionChangeCallback(Link< SvxLightCtl3D *, void > aNew)
Definition: dlgctl3d.hxx:163
weld::Scale & mrHorScroller
Definition: dlgctl3d.hxx:143
Svx3DLightControl & mrLightControl
Definition: dlgctl3d.hxx:142
DECL_DLLPRIVATE_LINK(KeyInput, const KeyEvent &, bool)
DECL_DLLPRIVATE_LINK(InternalSelectionChange, Svx3DLightControl *, void)
Link< SvxLightCtl3D *, void > maUserSelectionChangeCallback
Definition: dlgctl3d.hxx:149
DECL_DLLPRIVATE_LINK(InternalInteractiveChange, Svx3DLightControl *, void)
Link< SvxLightCtl3D *, void > maUserInteractiveChangeCallback
Definition: dlgctl3d.hxx:148
weld::Button & mrSwitcher
Definition: dlgctl3d.hxx:145
DECL_DLLPRIVATE_LINK(ButtonPress, weld::Button &, void)
DECL_DLLPRIVATE_LINK(ScrollBarMove, weld::Scale &, void)
DECL_DLLPRIVATE_LINK(FocusIn, weld::Widget &, void)
weld::Scale & mrVerScroller
Definition: dlgctl3d.hxx:144
void SetUserInteractiveChangeCallback(Link< SvxLightCtl3D *, void > aNew)
Definition: dlgctl3d.hxx:162
Svx3DLightControl & GetSvx3DLightControl()
Definition: dlgctl3d.hxx:159
virtual void SetDrawingArea(weld::DrawingArea *pDrawingArea)
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect)=0
virtual bool MouseMove(const MouseEvent &)
virtual bool MouseButtonDown(const MouseEvent &)
virtual bool MouseButtonUp(const MouseEvent &)
virtual tools::Rectangle GetFocusRect()
void Init()
SvxPreviewObjectType
Definition: dlgctl3d.hxx:36
#define SVX_DLLPUBLIC
Definition: svxdllapi.h:28
#define SAL_WARN_UNUSED
void CheckSelection(struct ESelection &rSel, SvxTextForwarder const *pForwarder) noexcept