LCOV - code coverage report
Current view: top level - svx/source/dialog - dlgctl3d.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 609 0.0 %
Date: 2012-08-25 Functions: 0 52 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 1072 0.0 %

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

Generated by: LCOV version 1.10