LCOV - code coverage report
Current view: top level - svx/source/engine3d - extrud3d.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 82 0.0 %
Date: 2014-04-14 Functions: 0 17 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : 
      21             : #include "svx/svdstr.hrc"
      22             : #include "svx/svdglob.hxx"
      23             : #include <svx/svdpage.hxx>
      24             : #include "svx/globl3d.hxx"
      25             : #include <svx/extrud3d.hxx>
      26             : #include <svx/scene3d.hxx>
      27             : 
      28             : #include <svx/svxids.hrc>
      29             : #include <svx/xpoly.hxx>
      30             : #include <svx/svdopath.hxx>
      31             : #include <svx/svdmodel.hxx>
      32             : #include <svx/svx3ditems.hxx>
      33             : #include <svx/sdr/properties/e3dextrudeproperties.hxx>
      34             : #include <svx/sdr/contact/viewcontactofe3dextrude.hxx>
      35             : #include <basegfx/polygon/b2dpolypolygontools.hxx>
      36             : #include <basegfx/polygon/b2dpolygontools.hxx>
      37             : #include <basegfx/polygon/b3dpolygontools.hxx>
      38             : #include <basegfx/polygon/b3dpolypolygontools.hxx>
      39             : 
      40             : 
      41             : // DrawContact section
      42             : 
      43           0 : sdr::contact::ViewContact* E3dExtrudeObj::CreateObjectSpecificViewContact()
      44             : {
      45           0 :     return new sdr::contact::ViewContactOfE3dExtrude(*this);
      46             : }
      47             : 
      48             : 
      49             : 
      50           0 : sdr::properties::BaseProperties* E3dExtrudeObj::CreateObjectSpecificProperties()
      51             : {
      52           0 :     return new sdr::properties::E3dExtrudeProperties(*this);
      53             : }
      54             : 
      55             : 
      56             : 
      57           0 : TYPEINIT1(E3dExtrudeObj, E3dCompoundObject);
      58             : 
      59             : // Constructor creates a two cover surface PolyPolygon and (point-count 1) side
      60             : // surfaces rectangles from the passed PolyPolygon
      61             : 
      62           0 : E3dExtrudeObj::E3dExtrudeObj(E3dDefaultAttributes& rDefault, const basegfx::B2DPolyPolygon& rPP, double fDepth)
      63             : :   E3dCompoundObject(rDefault),
      64           0 :     maExtrudePolygon(rPP)
      65             : {
      66             :     // since the old class PolyPolygon3D did mirror the given PolyPolygons in Y, do the same here
      67           0 :     basegfx::B2DHomMatrix aMirrorY;
      68           0 :     aMirrorY.scale(1.0, -1.0);
      69           0 :     maExtrudePolygon.transform(aMirrorY);
      70             : 
      71             :     // Set Defaults
      72           0 :     SetDefaultAttributes(rDefault);
      73             : 
      74             :     // set extrude depth
      75           0 :     GetProperties().SetObjectItemDirect(Svx3DDepthItem((sal_uInt32)(fDepth + 0.5)));
      76           0 : }
      77             : 
      78           0 : E3dExtrudeObj::E3dExtrudeObj()
      79           0 : :   E3dCompoundObject()
      80             : {
      81             :     // Set Defaults
      82           0 :     E3dDefaultAttributes aDefault;
      83           0 :     SetDefaultAttributes(aDefault);
      84           0 : }
      85             : 
      86           0 : void E3dExtrudeObj::SetDefaultAttributes(E3dDefaultAttributes& rDefault)
      87             : {
      88           0 :     GetProperties().SetObjectItemDirect(Svx3DSmoothNormalsItem(rDefault.GetDefaultExtrudeSmoothed()));
      89           0 :     GetProperties().SetObjectItemDirect(Svx3DSmoothLidsItem(rDefault.GetDefaultExtrudeSmoothFrontBack()));
      90           0 :     GetProperties().SetObjectItemDirect(Svx3DCharacterModeItem(rDefault.GetDefaultExtrudeCharacterMode()));
      91           0 :     GetProperties().SetObjectItemDirect(Svx3DCloseFrontItem(rDefault.GetDefaultExtrudeCloseFront()));
      92           0 :     GetProperties().SetObjectItemDirect(Svx3DCloseBackItem(rDefault.GetDefaultExtrudeCloseBack()));
      93             : 
      94             :     // For extrudes use StdTexture in X and Y by default
      95           0 :     GetProperties().SetObjectItemDirect(Svx3DTextureProjectionXItem(1));
      96           0 :     GetProperties().SetObjectItemDirect(Svx3DTextureProjectionYItem(1));
      97           0 : }
      98             : 
      99           0 : sal_uInt16 E3dExtrudeObj::GetObjIdentifier() const
     100             : {
     101           0 :     return E3D_EXTRUDEOBJ_ID;
     102             : }
     103             : 
     104           0 : E3dExtrudeObj* E3dExtrudeObj::Clone() const
     105             : {
     106           0 :     return CloneHelper< E3dExtrudeObj >();
     107             : }
     108             : 
     109             : 
     110             : // Set local parameters with geometry re-creating
     111             : 
     112           0 : void E3dExtrudeObj::SetExtrudePolygon(const basegfx::B2DPolyPolygon &rNew)
     113             : {
     114           0 :     if(maExtrudePolygon != rNew)
     115             :     {
     116           0 :         maExtrudePolygon = rNew;
     117           0 :         ActionChanged();
     118             :     }
     119           0 : }
     120             : 
     121             : // Get the name of the object (singular)
     122             : 
     123           0 : OUString E3dExtrudeObj::TakeObjNameSingul() const
     124             : {
     125           0 :     OUStringBuffer sName(ImpGetResStr(STR_ObjNameSingulExtrude3d));
     126             : 
     127           0 :     OUString aName(GetName());
     128           0 :     if (!aName.isEmpty())
     129             :     {
     130           0 :         sName.append(' ');
     131           0 :         sName.append('\'');
     132           0 :         sName.append(aName);
     133           0 :         sName.append('\'');
     134             :     }
     135           0 :     return sName.makeStringAndClear();
     136             : }
     137             : 
     138             : // Get the name of the object (plural)
     139             : 
     140           0 : OUString E3dExtrudeObj::TakeObjNamePlural() const
     141             : {
     142           0 :     return ImpGetResStr(STR_ObjNamePluralExtrude3d);
     143             : }
     144             : 
     145           0 : bool E3dExtrudeObj::IsBreakObjPossible()
     146             : {
     147           0 :     return true;
     148             : }
     149             : 
     150           0 : SdrAttrObj* E3dExtrudeObj::GetBreakObj()
     151             : {
     152           0 :     basegfx::B3DPolyPolygon aFrontSide;
     153           0 :     basegfx::B3DPolyPolygon aBackSide;
     154             : 
     155           0 :     if(maExtrudePolygon.count())
     156             :     {
     157           0 :         basegfx::B2DPolyPolygon aTemp(maExtrudePolygon);
     158           0 :         aTemp.removeDoublePoints();
     159           0 :         aTemp = basegfx::tools::correctOrientations(aTemp);
     160           0 :         const basegfx::B2VectorOrientation aOrient = basegfx::tools::getOrientation(aTemp.getB2DPolygon(0L));
     161             : 
     162           0 :         if(basegfx::ORIENTATION_POSITIVE == aOrient)
     163             :         {
     164           0 :             aTemp.flip();
     165             :         }
     166             : 
     167           0 :         aFrontSide = basegfx::tools::createB3DPolyPolygonFromB2DPolyPolygon(aTemp);
     168             :     }
     169             : 
     170           0 :     if(aFrontSide.count())
     171             :     {
     172           0 :         aBackSide = aFrontSide;
     173             : 
     174           0 :         if(GetExtrudeDepth())
     175             :         {
     176           0 :             basegfx::B3DHomMatrix aTransform;
     177             : 
     178           0 :             if(100 != GetPercentBackScale())
     179             :             {
     180             :                 // scale polygon from center
     181           0 :                 const double fScaleFactor(GetPercentBackScale() / 100.0);
     182           0 :                 const basegfx::B3DRange aPolyPolyRange(basegfx::tools::getRange(aBackSide));
     183           0 :                 const basegfx::B3DPoint aCenter(aPolyPolyRange.getCenter());
     184             : 
     185           0 :                 aTransform.translate(-aCenter.getX(), -aCenter.getY(), -aCenter.getZ());
     186           0 :                 aTransform.scale(fScaleFactor, fScaleFactor, fScaleFactor);
     187           0 :                 aTransform.translate(aCenter.getX(), aCenter.getY(), aCenter.getZ());
     188             :             }
     189             : 
     190             :             // translate by extrude depth
     191           0 :             aTransform.translate(0.0, 0.0, (double)GetExtrudeDepth());
     192             : 
     193           0 :             aBackSide.transform(aTransform);
     194             :         }
     195             :     }
     196             : 
     197           0 :     if(aBackSide.count())
     198             :     {
     199             :     // create PathObj
     200           0 :         basegfx::B2DPolyPolygon aPoly = TransformToScreenCoor(aBackSide);
     201           0 :         SdrPathObj* pPathObj = new SdrPathObj(OBJ_PLIN, aPoly);
     202             : 
     203           0 :         if(pPathObj)
     204             :         {
     205           0 :             SfxItemSet aSet(GetObjectItemSet());
     206           0 :             aSet.Put(XLineStyleItem(XLINE_SOLID));
     207           0 :             pPathObj->SetMergedItemSet(aSet);
     208             :         }
     209             : 
     210           0 :         return pPathObj;
     211             :     }
     212             : 
     213           0 :     return 0;
     214             : }
     215             : 
     216             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10