1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
|
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: dlgctl3d.cxx,v $
* $Revision: 1.20.226.2 $
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_svx.hxx"
#include <svx/dlgctl3d.hxx>
#include <svx/dialogs.hrc>
#include <svx/view3d.hxx>
#include <svx/fmmodel.hxx>
#include <svl/itempool.hxx>
#include <svx/fmpage.hxx>
#include <svx/polysc3d.hxx>
#include <svx/sphere3d.hxx>
#include <svx/cube3d.hxx>
#include <vcl/svapp.hxx>
#include <svx/helperhittest3d.hxx>
#include <basegfx/polygon/b2dpolygontools.hxx>
#include <svx/polygn3d.hxx>
#include <svx/xlnclit.hxx>
#include <svx/xlnwtit.hxx>
#include "helpid.hrc"
#include <algorithm>
//////////////////////////////////////////////////////////////////////////////
Svx3DPreviewControl::Svx3DPreviewControl(Window* pParent, const ResId& rResId)
: Control(pParent, rResId),
mpModel(0),
mpFmPage(0),
mp3DView(0),
mpScene(0),
mp3DObj(0),
mnObjectType(PREVIEW_OBJECTTYPE_SPHERE)
{
Construct();
// do not paint background self, DrawingLayer paints this buffered and as page
SetControlBackground();
SetBackground();
}
Svx3DPreviewControl::Svx3DPreviewControl(Window* pParent, WinBits nStyle)
: Control(pParent, nStyle),
mpModel(0),
mpFmPage(0),
mp3DView(0),
mpScene(0),
mp3DObj(0),
mnObjectType(PREVIEW_OBJECTTYPE_SPHERE)
{
Construct();
// do not paint background self, DrawingLayer paints this buffered and as page
SetControlBackground();
SetBackground();
}
Svx3DPreviewControl::~Svx3DPreviewControl()
{
delete mp3DView;
delete mpModel;
}
void Svx3DPreviewControl::Construct()
{
// Do never mirror the preview window. This explicitly includes right
// to left writing environments.
EnableRTL (FALSE);
SetMapMode( MAP_100TH_MM );
// Model
mpModel = new FmFormModel();
mpModel->GetItemPool().FreezeIdRanges();
// Page
mpFmPage = new FmFormPage( *mpModel, NULL );
mpModel->InsertPage( mpFmPage, 0 );
// 3D View
mp3DView = new E3dView( mpModel, this );
mp3DView->SetBufferedOutputAllowed(true);
mp3DView->SetBufferedOverlayAllowed(true);
// 3D Scene
mpScene = new E3dPolyScene(mp3DView->Get3DDefaultAttributes());
// initially create object
SetObjectType(PREVIEW_OBJECTTYPE_SPHERE);
// camera and perspective
Camera3D& rCamera = (Camera3D&) mpScene->GetCamera();
const basegfx::B3DRange& rVolume = mpScene->GetBoundVolume();
double fW = rVolume.getWidth();
double fH = rVolume.getHeight();
double fCamZ = rVolume.getMaxZ() + ((fW + fH) / 2.0);
rCamera.SetAutoAdjustProjection(FALSE);
rCamera.SetViewWindow(- fW / 2, - fH / 2, fW, fH);
basegfx::B3DPoint aLookAt;
double fDefaultCamPosZ = mp3DView->GetDefaultCamPosZ();
basegfx::B3DPoint aCamPos(0.0, 0.0, fCamZ < fDefaultCamPosZ ? fDefaultCamPosZ : fCamZ);
rCamera.SetPosAndLookAt(aCamPos, aLookAt);
double fDefaultCamFocal = mp3DView->GetDefaultCamFocal();
rCamera.SetFocalLength(fDefaultCamFocal);
rCamera.SetDefaults(basegfx::B3DPoint(0.0, 0.0, fDefaultCamPosZ), aLookAt, fDefaultCamFocal);
mpScene->SetCamera( rCamera );
mpFmPage->InsertObject( mpScene );
basegfx::B3DHomMatrix aRotation;
aRotation.rotate(DEG2RAD( 25 ), 0.0, 0.0);
aRotation.rotate(0.0, DEG2RAD( 40 ), 0.0);
mpScene->SetTransform(aRotation * mpScene->GetTransform());
// invalidate SnapRects of objects
mpScene->SetRectsDirty();
SfxItemSet aSet( mpModel->GetItemPool(),
XATTR_LINESTYLE, XATTR_LINESTYLE,
XATTR_FILL_FIRST, XATTR_FILLBITMAP,
0, 0 );
aSet.Put( XLineStyleItem( XLINE_NONE ) );
aSet.Put( XFillStyleItem( XFILL_SOLID ) );
aSet.Put( XFillColorItem( String(), Color( COL_WHITE ) ) );
mpScene->SetMergedItemSet(aSet);
// PageView
SdrPageView* pPageView = mp3DView->ShowSdrPage( mpFmPage );
mp3DView->hideMarkHandles();
// mark scene
mp3DView->MarkObj( mpScene, pPageView );
}
void Svx3DPreviewControl::Resize()
{
// size of page
Size aSize( GetSizePixel() );
aSize = PixelToLogic( aSize );
mpFmPage->SetSize( aSize );
// set size
Size aObjSize( aSize.Width()*5/6, aSize.Height()*5/6 );
Point aObjPoint( (aSize.Width() - aObjSize.Width()) / 2,
(aSize.Height() - aObjSize.Height()) / 2);
Rectangle aRect( aObjPoint, aObjSize);
mpScene->SetSnapRect( aRect );
}
void Svx3DPreviewControl::Paint(const Rectangle& rRect)
{
mp3DView->CompleteRedraw(this, Region(rRect));
}
void Svx3DPreviewControl::MouseButtonDown(const MouseEvent& rMEvt)
{
Control::MouseButtonDown(rMEvt);
if( rMEvt.IsShift() && rMEvt.IsMod1() )
{
if(PREVIEW_OBJECTTYPE_SPHERE == GetObjectType())
{
SetObjectType(PREVIEW_OBJECTTYPE_CUBE);
}
else
{
SetObjectType(PREVIEW_OBJECTTYPE_SPHERE);
}
}
}
void Svx3DPreviewControl::SetObjectType(sal_uInt16 nType)
{
if( mnObjectType != nType || !mp3DObj)
{
SfxItemSet aSet(mpModel->GetItemPool(), SDRATTR_START, SDRATTR_END, 0, 0);
mnObjectType = nType;
if( mp3DObj )
{
aSet.Put(mp3DObj->GetMergedItemSet());
mpScene->Remove3DObj( mp3DObj );
delete mp3DObj;
mp3DObj = NULL;
}
switch( nType )
{
case PREVIEW_OBJECTTYPE_SPHERE:
{
mp3DObj = new E3dSphereObj(
mp3DView->Get3DDefaultAttributes(),
basegfx::B3DPoint( 0, 0, 0 ),
basegfx::B3DVector( 5000, 5000, 5000 ));
}
break;
case PREVIEW_OBJECTTYPE_CUBE:
{
mp3DObj = new E3dCubeObj(
mp3DView->Get3DDefaultAttributes(),
basegfx::B3DPoint( -2500, -2500, -2500 ),
basegfx::B3DVector( 5000, 5000, 5000 ));
}
break;
}
mpScene->Insert3DObj( mp3DObj );
mp3DObj->SetMergedItemSet(aSet);
Resize();
}
}
SfxItemSet Svx3DPreviewControl::Get3DAttributes() const
{
return mp3DObj->GetMergedItemSet();
}
void Svx3DPreviewControl::Set3DAttributes( const SfxItemSet& rAttr )
{
mp3DObj->SetMergedItemSet(rAttr, true);
Resize();
}
//////////////////////////////////////////////////////////////////////////////
#define RADIUS_LAMP_PREVIEW_SIZE (4500.0)
#define RADIUS_LAMP_SMALL (600.0)
#define RADIUS_LAMP_BIG (1000.0)
#define NO_LIGHT_SELECTED (0xffffffff)
#define MAX_NUMBER_LIGHTS (8)
Svx3DLightControl::Svx3DLightControl(Window* pParent, const ResId& rResId)
: Svx3DPreviewControl(pParent, rResId),
maUserInteractiveChangeCallback(),
maUserSelectionChangeCallback(),
maChangeCallback(),
maSelectionChangeCallback(),
maSelectedLight(NO_LIGHT_SELECTED),
mpExpansionObject(0),
mpLampBottomObject(0),
mpLampShaftObject(0),
maLightObjects(MAX_NUMBER_LIGHTS, (E3dObject*)0),
mfRotateX(-20.0),
mfRotateY(45.0),
mfRotateZ(0.0),
maActionStartPoint(),
mnInteractionStartDistance(5 * 5 * 2),
mfSaveActionStartHor(0.0),
mfSaveActionStartVer(0.0),
mfSaveActionStartRotZ(0.0),
mbMouseMoved(false),
mbGeometrySelected(false)
{
Construct2();
}
Svx3DLightControl::Svx3DLightControl(Window* pParent, WinBits nStyle)
: Svx3DPreviewControl(pParent, nStyle),
maUserInteractiveChangeCallback(),
maUserSelectionChangeCallback(),
maChangeCallback(),
maSelectionChangeCallback(),
maSelectedLight(NO_LIGHT_SELECTED),
mpExpansionObject(0),
mpLampBottomObject(0),
mpLampShaftObject(0),
maLightObjects(MAX_NUMBER_LIGHTS, (E3dObject*)0),
mfRotateX(-20.0),
mfRotateY(45.0),
mfRotateZ(0.0),
maActionStartPoint(),
mnInteractionStartDistance(5 * 5 * 2),
mfSaveActionStartHor(0.0),
mfSaveActionStartVer(0.0),
mfSaveActionStartRotZ(0.0),
mbMouseMoved(false),
mbGeometrySelected(false)
{
Construct2();
}
Svx3DLightControl::~Svx3DLightControl()
{
// SdrObjects like mpExpansionObject and mpLampBottomObject/mpLampShaftObject get deleted
// with deletion of the DrawingLayer and model
}
void Svx3DLightControl::Construct2()
{
{
// hide all page stuff, use control background (normally gray)
const Color aDialogColor(Application::GetSettings().GetStyleSettings().GetDialogColor());
mp3DView->SetPageVisible(false);
mp3DView->SetApplicationBackgroundColor(aDialogColor);
mp3DView->SetApplicationDocumentColor(aDialogColor);
}
{
// create invisible expansion object
const double fMaxExpansion(RADIUS_LAMP_BIG + RADIUS_LAMP_PREVIEW_SIZE);
mpExpansionObject = new E3dCubeObj(
mp3DView->Get3DDefaultAttributes(),
basegfx::B3DPoint(-fMaxExpansion, -fMaxExpansion, -fMaxExpansion),
basegfx::B3DVector(2.0 * fMaxExpansion, 2.0 * fMaxExpansion, 2.0 * fMaxExpansion));
mpScene->Insert3DObj( mpExpansionObject );
SfxItemSet aSet(mpModel->GetItemPool());
aSet.Put( XLineStyleItem( XLINE_NONE ) );
aSet.Put( XFillStyleItem( XFILL_NONE ) );
mpExpansionObject->SetMergedItemSet(aSet);
}
{
// create lamp control object (Yellow lined object)
// base circle
const basegfx::B2DPolygon a2DCircle(basegfx::tools::createPolygonFromCircle(basegfx::B2DPoint(0.0, 0.0), RADIUS_LAMP_PREVIEW_SIZE));
basegfx::B3DPolygon a3DCircle(basegfx::tools::createB3DPolygonFromB2DPolygon(a2DCircle));
basegfx::B3DHomMatrix aTransform;
aTransform.rotate(F_PI2, 0.0, 0.0);
aTransform.translate(0.0, -RADIUS_LAMP_PREVIEW_SIZE, 0.0);
a3DCircle.transform(aTransform);
// create object for it
mpLampBottomObject = new E3dPolygonObj(
mp3DView->Get3DDefaultAttributes(),
basegfx::B3DPolyPolygon(a3DCircle),
true);
mpScene->Insert3DObj( mpLampBottomObject );
// half circle with stand
basegfx::B2DPolygon a2DHalfCircle;
a2DHalfCircle.append(basegfx::B2DPoint(RADIUS_LAMP_PREVIEW_SIZE, 0.0));
a2DHalfCircle.append(basegfx::B2DPoint(RADIUS_LAMP_PREVIEW_SIZE, -RADIUS_LAMP_PREVIEW_SIZE));
a2DHalfCircle.append(basegfx::tools::createPolygonFromEllipseSegment(
basegfx::B2DPoint(0.0, 0.0), RADIUS_LAMP_PREVIEW_SIZE, RADIUS_LAMP_PREVIEW_SIZE, F_2PI - F_PI2, F_PI2));
basegfx::B3DPolygon a3DHalfCircle(basegfx::tools::createB3DPolygonFromB2DPolygon(a2DHalfCircle));
// create object for it
mpLampShaftObject = new E3dPolygonObj(
mp3DView->Get3DDefaultAttributes(),
basegfx::B3DPolyPolygon(a3DHalfCircle),
true);
mpScene->Insert3DObj( mpLampShaftObject );
// initially invisible
SfxItemSet aSet(mpModel->GetItemPool());
aSet.Put( XLineStyleItem( XLINE_NONE ) );
aSet.Put( XFillStyleItem( XFILL_NONE ) );
mpLampBottomObject->SetMergedItemSet(aSet);
mpLampShaftObject->SetMergedItemSet(aSet);
}
{
// change camera settings
Camera3D& rCamera = (Camera3D&) mpScene->GetCamera();
const basegfx::B3DRange& rVolume = mpScene->GetBoundVolume();
double fW = rVolume.getWidth();
double fH = rVolume.getHeight();
double fCamZ = rVolume.getMaxZ() + ((fW + fH) / 2.0);
rCamera.SetAutoAdjustProjection(FALSE);
rCamera.SetViewWindow(- fW / 2, - fH / 2, fW, fH);
basegfx::B3DPoint aLookAt;
double fDefaultCamPosZ = mp3DView->GetDefaultCamPosZ();
basegfx::B3DPoint aCamPos(0.0, 0.0, fCamZ < fDefaultCamPosZ ? fDefaultCamPosZ : fCamZ);
rCamera.SetPosAndLookAt(aCamPos, aLookAt);
double fDefaultCamFocal = mp3DView->GetDefaultCamFocal();
rCamera.SetFocalLength(fDefaultCamFocal);
rCamera.SetDefaults(basegfx::B3DPoint(0.0, 0.0, fDefaultCamPosZ), aLookAt, fDefaultCamFocal);
mpScene->SetCamera( rCamera );
basegfx::B3DHomMatrix aNeutral;
mpScene->SetTransform(aNeutral);
}
// invalidate SnapRects of objects
mpScene->SetRectsDirty();
}
void Svx3DLightControl::ConstructLightObjects()
{
for(sal_uInt32 a(0); a < MAX_NUMBER_LIGHTS; a++)
{
// get rid of evtl. existing light object
if(maLightObjects[a])
{
mpScene->Remove3DObj(maLightObjects[a]);
delete maLightObjects[a];
maLightObjects[a] = 0;
}
if(GetLightOnOff(a))
{
const bool bIsSelectedLight(a == maSelectedLight);
basegfx::B3DVector aDirection(GetLightDirection(a));
aDirection.normalize();
aDirection *= RADIUS_LAMP_PREVIEW_SIZE;
const double fLampSize(bIsSelectedLight ? RADIUS_LAMP_BIG : RADIUS_LAMP_SMALL);
E3dObject* pNewLight = new E3dSphereObj(
mp3DView->Get3DDefaultAttributes(),
basegfx::B3DPoint( 0, 0, 0 ),
basegfx::B3DVector( fLampSize, fLampSize, fLampSize));
mpScene->Insert3DObj(pNewLight);
basegfx::B3DHomMatrix aTransform;
aTransform.translate(aDirection.getX(), aDirection.getY(), aDirection.getZ());
pNewLight->SetTransform(aTransform);
SfxItemSet aSet(mpModel->GetItemPool());
aSet.Put( XLineStyleItem( XLINE_NONE ) );
aSet.Put( XFillStyleItem( XFILL_SOLID ) );
aSet.Put( XFillColorItem(String(), GetLightColor(a)));
pNewLight->SetMergedItemSet(aSet);
maLightObjects[a] = pNewLight;
}
}
}
void Svx3DLightControl::AdaptToSelectedLight()
{
if(NO_LIGHT_SELECTED == maSelectedLight)
{
// make mpLampBottomObject/mpLampShaftObject invisible
SfxItemSet aSet(mpModel->GetItemPool());
aSet.Put( XLineStyleItem( XLINE_NONE ) );
aSet.Put( XFillStyleItem( XFILL_NONE ) );
mpLampBottomObject->SetMergedItemSet(aSet);
mpLampShaftObject->SetMergedItemSet(aSet);
}
else
{
basegfx::B3DVector aDirection(GetLightDirection(maSelectedLight));
aDirection.normalize();
// make mpLampBottomObject/mpLampShaftObject visible (yellow hairline)
SfxItemSet aSet(mpModel->GetItemPool());
aSet.Put( XLineStyleItem( XLINE_SOLID ) );
aSet.Put( XLineColorItem(String(), COL_YELLOW));
aSet.Put( XLineWidthItem(0));
aSet.Put( XFillStyleItem( XFILL_NONE ) );
mpLampBottomObject->SetMergedItemSet(aSet);
mpLampShaftObject->SetMergedItemSet(aSet);
// adapt transformation of mpLampShaftObject
basegfx::B3DHomMatrix aTransform;
double fRotateY(0.0);
if(!basegfx::fTools::equalZero(aDirection.getZ()) || !basegfx::fTools::equalZero(aDirection.getX()))
{
fRotateY = atan2(-aDirection.getZ(), aDirection.getX());
}
aTransform.rotate(0.0, fRotateY, 0.0);
mpLampShaftObject->SetTransform(aTransform);
// adapt transformation of selected light
E3dObject* pSelectedLight = maLightObjects[sal_Int32(maSelectedLight)];
if(pSelectedLight)
{
aTransform.identity();
aTransform.translate(
aDirection.getX() * RADIUS_LAMP_PREVIEW_SIZE,
aDirection.getY() * RADIUS_LAMP_PREVIEW_SIZE,
aDirection.getZ() * RADIUS_LAMP_PREVIEW_SIZE);
pSelectedLight->SetTransform(aTransform);
}
}
}
void Svx3DLightControl::TrySelection(Point aPosPixel)
{
if(mpScene)
{
const Point aPosLogic(PixelToLogic(aPosPixel));
const basegfx::B2DPoint aPoint(aPosLogic.X(), aPosLogic.Y());
std::vector< const E3dCompoundObject* > aResult;
getAllHit3DObjectsSortedFrontToBack(aPoint, *mpScene, aResult);
if(aResult.size())
{
// take the frontmost one
const E3dCompoundObject* pResult = aResult[0];
if(pResult == mp3DObj)
{
if(!mbGeometrySelected)
{
mbGeometrySelected = true;
maSelectedLight = NO_LIGHT_SELECTED;
ConstructLightObjects();
AdaptToSelectedLight();
Invalidate();
if(maSelectionChangeCallback.IsSet())
{
maSelectionChangeCallback.Call(this);
}
}
}
else
{
sal_uInt32 aNewSelectedLight(NO_LIGHT_SELECTED);
for(sal_uInt32 a(0); a < MAX_NUMBER_LIGHTS; a++)
{
if(maLightObjects[a] && maLightObjects[a] == pResult)
{
aNewSelectedLight = a;
}
}
if(aNewSelectedLight != maSelectedLight)
{
SelectLight(aNewSelectedLight);
if(maSelectionChangeCallback.IsSet())
{
maSelectionChangeCallback.Call(this);
}
}
}
}
}
}
void Svx3DLightControl::Paint(const Rectangle& rRect)
{
Svx3DPreviewControl::Paint(rRect);
}
void Svx3DLightControl::MouseButtonDown( const MouseEvent& rMEvt )
{
bool bCallParent(true);
// switch state
if(rMEvt.IsLeft())
{
if(IsSelectionValid() || mbGeometrySelected)
{
mbMouseMoved = false;
bCallParent = false;
maActionStartPoint = rMEvt.GetPosPixel();
StartTracking();
}
else
{
// Einfacher Click ohne viel Bewegen, versuche eine
// Selektion
TrySelection(rMEvt.GetPosPixel());
bCallParent = false;
}
}
// call parent
if(bCallParent)
{
Svx3DPreviewControl::MouseButtonDown(rMEvt);
}
}
void Svx3DLightControl::Tracking( const TrackingEvent& rTEvt )
{
if(rTEvt.IsTrackingEnded())
{
if(rTEvt.IsTrackingCanceled())
{
if(mbMouseMoved)
{
// interrupt tracking
mbMouseMoved = false;
if(mbGeometrySelected)
{
SetRotation(mfSaveActionStartVer, mfSaveActionStartHor, mfSaveActionStartRotZ);
}
else
{
SetPosition(mfSaveActionStartHor, mfSaveActionStartVer);
}
if(maChangeCallback.IsSet())
{
maChangeCallback.Call(this);
}
}
}
else
{
const MouseEvent& rMEvt = rTEvt.GetMouseEvent();
if(mbMouseMoved)
{
// was change dinteractively
}
else
{
// simple click without much movement, try selection
TrySelection(rMEvt.GetPosPixel());
}
}
}
else
{
const MouseEvent& rMEvt = rTEvt.GetMouseEvent();
Point aDeltaPos = rMEvt.GetPosPixel() - maActionStartPoint;
if(!mbMouseMoved)
{
if(sal_Int32(aDeltaPos.X() * aDeltaPos.X() + aDeltaPos.Y() * aDeltaPos.Y()) > mnInteractionStartDistance)
{
if(mbGeometrySelected)
{
GetRotation(mfSaveActionStartVer, mfSaveActionStartHor, mfSaveActionStartRotZ);
}
else
{
// intercation start, save values
GetPosition(mfSaveActionStartHor, mfSaveActionStartVer);
}
mbMouseMoved = true;
}
}
if(mbMouseMoved)
{
if(mbGeometrySelected)
{
double fNewRotX = mfSaveActionStartVer - ((double)aDeltaPos.Y() * F_PI180);
double fNewRotY = mfSaveActionStartHor + ((double)aDeltaPos.X() * F_PI180);
// cut horizontal
while(fNewRotY < 0.0)
{
fNewRotY += F_2PI;
}
while(fNewRotY >= F_2PI)
{
fNewRotY -= F_2PI;
}
// cut vertical
if(fNewRotX < -F_PI2)
{
fNewRotX = -F_PI2;
}
if(fNewRotX > F_PI2)
{
fNewRotX = F_PI2;
}
SetRotation(fNewRotX, fNewRotY, mfSaveActionStartRotZ);
if(maChangeCallback.IsSet())
{
maChangeCallback.Call(this);
}
}
else
{
// interaction in progress
double fNewPosHor = mfSaveActionStartHor + ((double)aDeltaPos.X());
double fNewPosVer = mfSaveActionStartVer - ((double)aDeltaPos.Y());
// cut horizontal
while(fNewPosHor < 0.0)
{
fNewPosHor += 360.0;
}
while(fNewPosHor >= 360.0)
{
fNewPosHor -= 360.0;
}
// cut vertical
if(fNewPosVer < -90.0)
{
fNewPosVer = -90.0;
}
if(fNewPosVer > 90.0)
{
fNewPosVer = 90.0;
}
SetPosition(fNewPosHor, fNewPosVer);
if(maChangeCallback.IsSet())
{
maChangeCallback.Call(this);
}
}
}
}
}
void Svx3DLightControl::Resize()
{
// set size of page
const Size aSize(PixelToLogic(GetSizePixel()));
mpFmPage->SetSize(aSize);
// set position and size of scene
mpScene->SetSnapRect(Rectangle(Point(0, 0), aSize));
}
void Svx3DLightControl::SetObjectType(sal_uInt16 nType)
{
// call parent
Svx3DPreviewControl::SetObjectType(nType);
// apply object rotation
if(mp3DObj)
{
basegfx::B3DHomMatrix aObjectRotation;
aObjectRotation.rotate(mfRotateX, mfRotateY, mfRotateZ);
mp3DObj->SetTransform(aObjectRotation);
}
}
bool Svx3DLightControl::IsSelectionValid()
{
if((NO_LIGHT_SELECTED != maSelectedLight) && (GetLightOnOff(maSelectedLight)))
{
return true;
}
return false;
}
void Svx3DLightControl::GetPosition(double& rHor, double& rVer)
{
if(IsSelectionValid())
{
basegfx::B3DVector aDirection(GetLightDirection(maSelectedLight));
aDirection.normalize();
rHor = atan2(-aDirection.getX(), -aDirection.getZ()) + F_PI; // 0..2PI
rVer = atan2(aDirection.getY(), aDirection.getXZLength()); // -PI2..PI2
rHor /= F_PI180; // 0..360.0
rVer /= F_PI180; // -90.0..90.0
}
if(IsGeometrySelected())
{
rHor = mfRotateY;
rVer = mfRotateX;
}
}
void Svx3DLightControl::SetPosition(double fHor, double fVer)
{
if(IsSelectionValid())
{
// set selected light's direction
fHor = (fHor * F_PI180) - F_PI; // -PI..PI
fVer *= F_PI180; // -PI2..PI2
basegfx::B3DVector aDirection(cos(fVer) * -sin(fHor), sin(fVer), cos(fVer) * -cos(fHor));
aDirection.normalize();
if(!aDirection.equal(GetLightDirection(maSelectedLight)))
{
// set changed light direction at SdrScene
SfxItemSet aSet(mpModel->GetItemPool());
switch(maSelectedLight)
{
case 0: aSet.Put(Svx3DLightDirection1Item(aDirection)); break;
case 1: aSet.Put(Svx3DLightDirection2Item(aDirection)); break;
case 2: aSet.Put(Svx3DLightDirection3Item(aDirection)); break;
case 3: aSet.Put(Svx3DLightDirection4Item(aDirection)); break;
case 4: aSet.Put(Svx3DLightDirection5Item(aDirection)); break;
case 5: aSet.Put(Svx3DLightDirection6Item(aDirection)); break;
case 6: aSet.Put(Svx3DLightDirection7Item(aDirection)); break;
default:
case 7: aSet.Put(Svx3DLightDirection8Item(aDirection)); break;
}
mpScene->SetMergedItemSet(aSet);
// correct 3D light's and LampFrame's geometries
AdaptToSelectedLight();
Invalidate();
}
}
if(IsGeometrySelected())
{
if(mfRotateX != fVer || mfRotateY != fHor)
{
mfRotateX = fVer;
mfRotateY = fHor;
if(mp3DObj)
{
basegfx::B3DHomMatrix aObjectRotation;
aObjectRotation.rotate(mfRotateX, mfRotateY, mfRotateZ);
mp3DObj->SetTransform(aObjectRotation);
Invalidate();
}
}
}
}
void Svx3DLightControl::SetRotation(double fRotX, double fRotY, double fRotZ)
{
if(IsGeometrySelected())
{
if(fRotX != mfRotateX || fRotY != mfRotateY || fRotZ != mfRotateZ)
{
mfRotateX = fRotX;
mfRotateY = fRotY;
mfRotateZ = fRotZ;
if(mp3DObj)
{
basegfx::B3DHomMatrix aObjectRotation;
aObjectRotation.rotate(mfRotateX, mfRotateY, mfRotateZ);
mp3DObj->SetTransform(aObjectRotation);
Invalidate();
}
}
}
}
void Svx3DLightControl::GetRotation(double& rRotX, double& rRotY, double& rRotZ)
{
rRotX = mfRotateX;
rRotY = mfRotateY;
rRotZ = mfRotateZ;
}
void Svx3DLightControl::Set3DAttributes( const SfxItemSet& rAttr )
{
// call parent
Svx3DPreviewControl::Set3DAttributes(rAttr);
if(maSelectedLight != NO_LIGHT_SELECTED && !GetLightOnOff(maSelectedLight))
{
// selected light is no more active, select new one
maSelectedLight = NO_LIGHT_SELECTED;
}
// local updates
ConstructLightObjects();
AdaptToSelectedLight();
Invalidate();
}
void Svx3DLightControl::SelectLight(sal_uInt32 nLightNumber)
{
if(nLightNumber > 7)
{
nLightNumber = NO_LIGHT_SELECTED;
}
if(NO_LIGHT_SELECTED != nLightNumber)
{
if(!GetLightOnOff(nLightNumber))
{
nLightNumber = NO_LIGHT_SELECTED;
}
}
if(nLightNumber != maSelectedLight)
{
maSelectedLight = nLightNumber;
mbGeometrySelected = false;
ConstructLightObjects();
AdaptToSelectedLight();
Invalidate();
}
}
bool Svx3DLightControl::GetLightOnOff(sal_uInt32 nNum) const
{
if(nNum <= 7)
{
const SfxItemSet aLightItemSet(Get3DAttributes());
switch(nNum)
{
case 0 : return ((const Svx3DLightOnOff1Item&)aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTON_1)).GetValue();
case 1 : return ((const Svx3DLightOnOff2Item&)aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTON_2)).GetValue();
case 2 : return ((const Svx3DLightOnOff3Item&)aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTON_3)).GetValue();
case 3 : return ((const Svx3DLightOnOff4Item&)aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTON_4)).GetValue();
case 4 : return ((const Svx3DLightOnOff5Item&)aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTON_5)).GetValue();
case 5 : return ((const Svx3DLightOnOff6Item&)aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTON_6)).GetValue();
case 6 : return ((const Svx3DLightOnOff7Item&)aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTON_7)).GetValue();
case 7 : return ((const Svx3DLightOnOff8Item&)aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTON_8)).GetValue();
}
}
return false;
}
Color Svx3DLightControl::GetLightColor(sal_uInt32 nNum) const
{
if(nNum <= 7)
{
const SfxItemSet aLightItemSet(Get3DAttributes());
switch(nNum)
{
case 0 : return ((const Svx3DLightcolor1Item&)aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTCOLOR_1)).GetValue();
case 1 : return ((const Svx3DLightcolor2Item&)aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTCOLOR_2)).GetValue();
case 2 : return ((const Svx3DLightcolor3Item&)aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTCOLOR_3)).GetValue();
case 3 : return ((const Svx3DLightcolor4Item&)aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTCOLOR_4)).GetValue();
case 4 : return ((const Svx3DLightcolor5Item&)aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTCOLOR_5)).GetValue();
case 5 : return ((const Svx3DLightcolor6Item&)aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTCOLOR_6)).GetValue();
case 6 : return ((const Svx3DLightcolor7Item&)aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTCOLOR_7)).GetValue();
case 7 : return ((const Svx3DLightcolor8Item&)aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTCOLOR_8)).GetValue();
}
}
return Color(COL_BLACK);
}
basegfx::B3DVector Svx3DLightControl::GetLightDirection(sal_uInt32 nNum) const
{
if(nNum <= 7)
{
const SfxItemSet aLightItemSet(Get3DAttributes());
switch(nNum)
{
case 0 : return ((const Svx3DLightDirection1Item&)aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_1)).GetValue();
case 1 : return ((const Svx3DLightDirection2Item&)aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_2)).GetValue();
case 2 : return ((const Svx3DLightDirection3Item&)aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_3)).GetValue();
case 3 : return ((const Svx3DLightDirection4Item&)aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_4)).GetValue();
case 4 : return ((const Svx3DLightDirection5Item&)aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_5)).GetValue();
case 5 : return ((const Svx3DLightDirection6Item&)aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_6)).GetValue();
case 6 : return ((const Svx3DLightDirection7Item&)aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_7)).GetValue();
case 7 : return ((const Svx3DLightDirection8Item&)aLightItemSet.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_8)).GetValue();
}
}
return basegfx::B3DVector();
}
//////////////////////////////////////////////////////////////////////////////
SvxLightCtl3D::SvxLightCtl3D( Window* pParent, const ResId& rResId)
: Control(pParent, rResId),
maLightControl(this, 0),
maHorScroller(this, WB_HORZ | WB_DRAG),
maVerScroller(this, WB_VERT | WB_DRAG),
maSwitcher(this, 0)
{
// init members
Init();
}
SvxLightCtl3D::SvxLightCtl3D( Window* pParent, WinBits nStyle )
: Control(pParent, nStyle),
maLightControl(this, 0),
maHorScroller(this, WB_HORZ | WB_DRAG),
maVerScroller(this, WB_VERT | WB_DRAG),
maSwitcher(this, 0)
{
// init members
Init();
}
void SvxLightCtl3D::Init()
{
// #i58240# set HelpIDs for scrollbars and switcher
maHorScroller.SetHelpId(HID_CTRL3D_HSCROLL);
maVerScroller.SetHelpId(HID_CTRL3D_VSCROLL);
maSwitcher.SetHelpId(HID_CTRL3D_SWITCHER);
// Light preview
maLightControl.Show();
maLightControl.SetChangeCallback( LINK(this, SvxLightCtl3D, InternalInteractiveChange) );
maLightControl.SetSelectionChangeCallback( LINK(this, SvxLightCtl3D, InternalSelectionChange) );
// Horiz Scrollbar
maHorScroller.Show();
maHorScroller.SetRange(Range(0, 36000));
maHorScroller.SetLineSize(100);
maHorScroller.SetPageSize(1000);
maHorScroller.SetScrollHdl( LINK(this, SvxLightCtl3D, ScrollBarMove) );
// Vert Scrollbar
maVerScroller.Show();
maVerScroller.SetRange(Range(0, 18000));
maVerScroller.SetLineSize(100);
maVerScroller.SetPageSize(1000);
maVerScroller.SetScrollHdl( LINK(this, SvxLightCtl3D, ScrollBarMove) );
// Switch Button
maSwitcher.Show();
maSwitcher.SetClickHdl( LINK(this, SvxLightCtl3D, ButtonPress) );
// check selection
CheckSelection();
// new layout
NewLayout();
}
SvxLightCtl3D::~SvxLightCtl3D()
{
}
void SvxLightCtl3D::Resize()
{
// call parent
Control::Resize();
// new layout
NewLayout();
}
void SvxLightCtl3D::NewLayout()
{
// Layout members
const Size aSize(GetOutputSizePixel());
const sal_Int32 nScrollSize(maHorScroller.GetSizePixel().Height());
// Preview control
Point aPoint(0, 0);
Size aDestSize(aSize.Width() - nScrollSize, aSize.Height() - nScrollSize);
maLightControl.SetPosSizePixel(aPoint, aDestSize);
// hor scrollbar
aPoint.Y() = aSize.Height() - nScrollSize;
aDestSize.Height() = nScrollSize;
maHorScroller.SetPosSizePixel(aPoint, aDestSize);
// vert scrollbar
aPoint.X() = aSize.Width() - nScrollSize;
aPoint.Y() = 0;
aDestSize.Width() = nScrollSize;
aDestSize.Height() = aSize.Height() - nScrollSize;
maVerScroller.SetPosSizePixel(aPoint, aDestSize);
// button
aPoint.Y() = aSize.Height() - nScrollSize;
aDestSize.Height() = nScrollSize;
maSwitcher.SetPosSizePixel(aPoint, aDestSize);
}
void SvxLightCtl3D::CheckSelection()
{
const bool bSelectionValid(maLightControl.IsSelectionValid() || maLightControl.IsGeometrySelected());
maHorScroller.Enable(bSelectionValid);
maVerScroller.Enable(bSelectionValid);
if(bSelectionValid)
{
double fHor, fVer;
maLightControl.GetPosition(fHor, fVer);
maHorScroller.SetThumbPos( INT32(fHor * 100.0) );
maVerScroller.SetThumbPos( 18000 - INT32((fVer + 90.0) * 100.0) );
}
}
void SvxLightCtl3D::move( double fDeltaHor, double fDeltaVer )
{
double fHor, fVer;
maLightControl.GetPosition(fHor, fVer);
fHor += fDeltaHor;
fVer += fDeltaVer;
if( fVer > 90.0 )
return;
if ( fVer < -90.0 )
return;
maLightControl.SetPosition(fHor, fVer);
maHorScroller.SetThumbPos( INT32(fHor * 100.0) );
maVerScroller.SetThumbPos( 18000 - INT32((fVer + 90.0) * 100.0) );
if(maUserInteractiveChangeCallback.IsSet())
{
maUserInteractiveChangeCallback.Call(this);
}
}
void SvxLightCtl3D::KeyInput( const KeyEvent& rKEvt )
{
const KeyCode aCode(rKEvt.GetKeyCode());
if( aCode.GetModifier() )
{
Control::KeyInput( rKEvt );
return;
}
switch ( aCode.GetCode() )
{
case KEY_SPACE:
{
break;
}
case KEY_LEFT:
{
move( -4.0, 0.0 ); // #i58242# changed move direction in X
break;
}
case KEY_RIGHT:
{
move( 4.0, 0.0 ); // #i58242# changed move direction in X
break;
}
case KEY_UP:
{
move( 0.0, 4.0 );
break;
}
case KEY_DOWN:
{
move( 0.0, -4.0 );
break;
}
case KEY_PAGEUP:
{
sal_Int32 nLight(maLightControl.GetSelectedLight() - 1);
while((nLight >= 0) && !maLightControl.GetLightOnOff(nLight))
{
nLight--;
}
if(nLight < 0)
{
nLight = 7;
while((nLight >= 0) && !maLightControl.GetLightOnOff(nLight))
{
nLight--;
}
}
if(nLight >= 0)
{
maLightControl.SelectLight(nLight);
CheckSelection();
if(maUserSelectionChangeCallback.IsSet())
{
maUserSelectionChangeCallback.Call(this);
}
}
break;
}
case KEY_PAGEDOWN:
{
sal_Int32 nLight(maLightControl.GetSelectedLight() - 1);
while(nLight <= 7 && !maLightControl.GetLightOnOff(nLight))
{
nLight++;
}
if(nLight > 7)
{
nLight = 0;
while(nLight <= 7 && !maLightControl.GetLightOnOff(nLight))
{
nLight++;
}
}
if(nLight <= 7)
{
maLightControl.SelectLight(nLight);
CheckSelection();
if(maUserSelectionChangeCallback.IsSet())
{
maUserSelectionChangeCallback.Call(this);
}
}
break;
}
default:
{
Control::KeyInput( rKEvt );
break;
}
}
}
void SvxLightCtl3D::GetFocus()
{
Control::GetFocus();
if(HasFocus() && IsEnabled())
{
CheckSelection();
Size aFocusSize = maLightControl.GetOutputSizePixel();
aFocusSize.Width() -= 4;
aFocusSize.Height() -= 4;
Rectangle aFocusRect( Point( 2, 2 ), aFocusSize );
aFocusRect = maLightControl.PixelToLogic( aFocusRect );
maLightControl.ShowFocus( aFocusRect );
}
}
void SvxLightCtl3D::LoseFocus()
{
Control::LoseFocus();
maLightControl.HideFocus();
}
IMPL_LINK( SvxLightCtl3D, ScrollBarMove, void*, EMPTYARG)
{
const sal_Int32 nHor(maHorScroller.GetThumbPos());
const sal_Int32 nVer(maVerScroller.GetThumbPos());
maLightControl.SetPosition(
((double)nHor) / 100.0,
((double)((18000 - nVer) - 9000)) / 100.0);
if(maUserInteractiveChangeCallback.IsSet())
{
maUserInteractiveChangeCallback.Call(this);
}
return 0;
}
IMPL_LINK( SvxLightCtl3D, ButtonPress, void*, EMPTYARG)
{
if(PREVIEW_OBJECTTYPE_SPHERE == GetSvx3DLightControl().GetObjectType())
{
GetSvx3DLightControl().SetObjectType(PREVIEW_OBJECTTYPE_CUBE);
}
else
{
GetSvx3DLightControl().SetObjectType(PREVIEW_OBJECTTYPE_SPHERE);
}
return 0;
}
IMPL_LINK( SvxLightCtl3D, InternalInteractiveChange, void*, EMPTYARG)
{
double fHor, fVer;
maLightControl.GetPosition(fHor, fVer);
maHorScroller.SetThumbPos( INT32(fHor * 100.0) );
maVerScroller.SetThumbPos( 18000 - INT32((fVer + 90.0) * 100.0) );
if(maUserInteractiveChangeCallback.IsSet())
{
maUserInteractiveChangeCallback.Call(this);
}
return 0;
}
IMPL_LINK( SvxLightCtl3D, InternalSelectionChange, void*, EMPTYARG)
{
CheckSelection();
if(maUserSelectionChangeCallback.IsSet())
{
maUserSelectionChangeCallback.Call(this);
}
return 0;
}
//////////////////////////////////////////////////////////////////////////////
// eof
|