ShadowTl.cpp

Go to the documentation of this file.
00001 // $Id: ShadowTl.cpp 1282 2006-06-09 09:46:49Z alex $
00002 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
00003 ================================XARAHEADERSTART===========================
00004  
00005                Xara LX, a vector drawing and manipulation program.
00006                     Copyright (C) 1993-2006 Xara Group Ltd.
00007        Copyright on certain contributions may be held in joint with their
00008               respective authors. See AUTHORS file for details.
00009 
00010 LICENSE TO USE AND MODIFY SOFTWARE
00011 ----------------------------------
00012 
00013 This file is part of Xara LX.
00014 
00015 Xara LX is free software; you can redistribute it and/or modify it
00016 under the terms of the GNU General Public License version 2 as published
00017 by the Free Software Foundation.
00018 
00019 Xara LX and its component source files are distributed in the hope
00020 that it will be useful, but WITHOUT ANY WARRANTY; without even the
00021 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00022 See the GNU General Public License for more details.
00023 
00024 You should have received a copy of the GNU General Public License along
00025 with Xara LX (see the file GPL in the root directory of the
00026 distribution); if not, write to the Free Software Foundation, Inc., 51
00027 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00028 
00029 
00030 ADDITIONAL RIGHTS
00031 -----------------
00032 
00033 Conditional upon your continuing compliance with the GNU General Public
00034 License described above, Xara Group Ltd grants to you certain additional
00035 rights. 
00036 
00037 The additional rights are to use, modify, and distribute the software
00038 together with the wxWidgets library, the wxXtra library, and the "CDraw"
00039 library and any other such library that any version of Xara LX relased
00040 by Xara Group Ltd requires in order to compile and execute, including
00041 the static linking of that library to XaraLX. In the case of the
00042 "CDraw" library, you may satisfy obligation under the GNU General Public
00043 License to provide source code by providing a binary copy of the library
00044 concerned and a copy of the license accompanying it.
00045 
00046 Nothing in this section restricts any of the rights you have under
00047 the GNU General Public License.
00048 
00049 
00050 SCOPE OF LICENSE
00051 ----------------
00052 
00053 This license applies to this program (XaraLX) and its constituent source
00054 files only, and does not necessarily apply to other Xara products which may
00055 in part share the same code base, and are subject to their own licensing
00056 terms.
00057 
00058 This license does not apply to files in the wxXtra directory, which
00059 are built into a separate library, and are subject to the wxWindows
00060 license contained within that directory in the file "WXXTRA-LICENSE".
00061 
00062 This license does not apply to the binary libraries (if any) within
00063 the "libs" directory, which are subject to a separate license contained
00064 within that directory in the file "LIBS-LICENSE".
00065 
00066 
00067 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS
00068 ----------------------------------------------
00069 
00070 Subject to the terms of the GNU Public License (see above), you are
00071 free to do whatever you like with your modifications. However, you may
00072 (at your option) wish contribute them to Xara's source tree. You can
00073 find details of how to do this at:
00074   http://www.xaraxtreme.org/developers/
00075 
00076 Prior to contributing your modifications, you will need to complete our
00077 contributor agreement. This can be found at:
00078   http://www.xaraxtreme.org/developers/contribute/
00079 
00080 Please note that Xara will not accept modifications which modify any of
00081 the text between the start and end of this header (marked
00082 XARAHEADERSTART and XARAHEADEREND).
00083 
00084 
00085 MARKS
00086 -----
00087 
00088 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara
00089 designs are registered or unregistered trademarks, design-marks, and/or
00090 service marks of Xara Group Ltd. All rights in these marks are reserved.
00091 
00092 
00093       Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
00094                         http://www.xara.com/
00095 
00096 =================================XARAHEADEREND============================
00097  */
00098 // 
00099 #include "camtypes.h"
00100 #include "shadowtl.h"
00101 #include <objbase.h>
00102 #include <initguid.h>
00103 
00104 //#include "nodeattr.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00105 #include "lineattr.h"
00106 //#include "attrmgr.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00107 
00108 // Place any IMPLEMENT type statements here
00109 CC_IMPLEMENT_MEMDUMP(CCWobJob, CC_CLASS_MEMDUMP)
00110 
00111 // We want better memory tracking
00112 #define new CAM_DEBUG_NEW
00113 
00114 /*******************************************************************************
00115 
00116 >   class CShadowerFlat
00117 
00118     Author:     Harrison_Ainsworth (Xara Group Ltd) <camelotdev@xara.com>
00119     Created:    21/12/97
00120     Purpose:    COM interface for the flat shadow generation system.
00121                 ...
00122     See also:   ComShadowerFlat.cpp
00123 
00124 *******************************************************************************/
00125 
00126 interface IComShadowerFlat : public IUnknown
00127 {
00128 public:
00129     // set choices
00130     virtual void __stdcall SetChoicesToDefault() = 0;
00131 
00132     virtual void __stdcall SetChoices( const BOOL* MakeWallShadow, const AFloatPt01* Darkness01,
00133                                        const APixels* Blurriness, const ACoordPixels XYPosition,
00134                                        const ADegrees* Tilt, const AFloatPt01* YScale01 ) = 0;
00135 
00136     virtual void __stdcall SetBaseline( const AFloatPt01* Baseline ) = 0;
00137 
00138     // get choices
00139     virtual void __stdcall GetChoices( BOOL* MakeWallShadow, AFloatPt01* Darkness01, APixels* Blurriness,
00140                                        ACoordPixels XYPosition, ADegrees* Tilt, AFloatPt01* YScale01 ) const = 0;
00141 
00142     virtual void __stdcall GetBaseline( AFloatPt01* Baseline ) const = 0;
00143 
00144     // choices range queries
00145     virtual void __stdcall GetDarknessRange( AFloatPt01& Min, AFloatPt01& Max ) const = 0;
00146     virtual void __stdcall GetBlurrinessRange( APixels& Min, APixels& Max ) const = 0;
00147     virtual void __stdcall GetPositionRange( ACoordPixels Min, ACoordPixels Max ) const = 0;
00148     virtual void __stdcall GetProjectionRange( ADegrees& MinTilt, ADegrees& MaxTilt, AFloatPt01& MinYScale,
00149                                                AFloatPt01& MaxYScale ) const = 0;
00150     // alpha channel type switches
00151     virtual HRESULT __stdcall SwitchToTransparencyInsteadOfAlpha( BOOL YesOrNo ) = 0;
00152     virtual HRESULT __stdcall SwitchToUpsideDownPixelAddressing( BOOL YesOrNo ) = 0;
00153 
00154     // make shadow
00155     virtual HRESULT __stdcall InverseShadowBoundCalc( ACoordPixels UnshadowedWidHei, ACoordPixels UnshadowedPos,
00156                                                       const ACoordPixels& ShadowedWidHei,
00157                                                       const AFloatPt01* Baseline ) const = 0;
00158 
00159     virtual HRESULT __stdcall CalcShadowBound( ACoordPixels ShadowWidHei, ACoordPixels ShadowPos,
00160                                                const AAlphaChannel& TransparencyMap, const ACoordPixels& tWidHei,
00161                                                const ACoordPixels& tPos ) const = 0;
00162 
00163     virtual HRESULT __stdcall DrawShadow( const AAlphaChannel& ShadowMapOut, const ACoordPixels& sWidHei,
00164                                           const ACoordPixels& sPos, const AAlphaChannel& TransparencyMapIn,
00165                                           const ACoordPixels& tWidHei, const ACoordPixels& tPos ) const = 0;
00166 };
00167 
00168 // globally unique IDs ////////////////////////////////////////////////////////////////////////////
00169 const GUID CShadowerFlat::IID_IComShadowerFlat = 
00170                     { 0x326f6db0, 0x7b82, 0x11d1, { 0xac, 0xbf, 0x0, 0x20, 0xaf, 0xe1, 0x4b, 0x7d } };
00171                     // {326F6DB0-7B82-11d1-ACBF-0020AFE14B7D}
00172 
00173 const GUID CShadowerFlat::CLSID_CComShadowerFlat =
00174                     { 0x326f6db1, 0x7b82, 0x11d1, { 0xac, 0xbf, 0x0, 0x20, 0xaf, 0xe1, 0x4b, 0x7d } };
00175                     // {326F6DB1-7B82-11d1-ACBF-0020AFE14B7D}
00176 
00177 // standard object management /////////////////////////////////////////////////////////////////////
00178 CShadowerFlat::CShadowerFlat()
00179 {
00180     pShadower_m = NULL;
00181 }
00182 
00183 CShadowerFlat::~CShadowerFlat()
00184 {
00185     if( pShadower_m )
00186         pShadower_m->Release();
00187 }
00188 
00189 CShadowerFlat::CShadowerFlat( const CShadowerFlat& Other )
00190 {
00191     pShadower_m = NULL;
00192 }
00193 
00194 CShadowerFlat& CShadowerFlat::operator= ( const CShadowerFlat& Other )
00195 {
00196    return *this;
00197 }
00198 
00199 HRESULT CShadowerFlat::_Init_()
00200 {
00201     
00202     // if( pShadower_m )
00203     {
00204         // already initialised so drop out
00205         return S_OK;
00206     }
00207     
00208     HRESULT hr = ::CoCreateInstance( CLSID_CComShadowerFlat, NULL, CLSCTX_INPROC_SERVER, IID_IComShadowerFlat,
00209                                      (void**)&pShadower_m );
00210     if( FAILED( hr ) )
00211         return hr;
00212 
00213     pShadower_m->SwitchToTransparencyInsteadOfAlpha( FALSE );
00214     pShadower_m->SwitchToUpsideDownPixelAddressing( TRUE );
00215 
00216     return S_OK;
00217 }
00218 
00219 // set choices ////////////////////////////////////////////////////////////////////////////////////
00220 void CShadowerFlat::SetChoicesToDefault()
00221 {
00222     /*
00223     if( pShadower_m )
00224         pShadower_m->SetChoicesToDefault();
00225         */
00226 }
00227 
00228 void CShadowerFlat::SetChoices( const BOOL* MakeWallShadow, const AFloatPt01* Darkness01, const APixels* Blurriness,
00229                            const ACoordPixels XYPosition, const ADegrees* Tilt, const AFloatPt01* YScale01 )
00230 {
00231     /*
00232     if( pShadower_m )
00233         pShadower_m->SetChoices( MakeWallShadow, Darkness01, Blurriness, XYPosition, Tilt, YScale01 );
00234         */
00235 }
00236 
00237 void CShadowerFlat::SetBaseline( const AFloatPt01* Baseline )
00238 {
00239     /*
00240     if( pShadower_m )
00241         pShadower_m->SetBaseline( Baseline );
00242         */
00243 }
00244 
00245 // get choices ////////////////////////////////////////////////////////////////////////////////////
00246 void CShadowerFlat::GetChoices( BOOL* MakeWallShadow, AFloatPt01* Darkness01, APixels* Blurriness,
00247                            ACoordPixels XYPosition, ADegrees* Tilt, AFloatPt01* YScale01 ) const
00248 {
00249     /*
00250     if( pShadower_m )
00251         pShadower_m->GetChoices( MakeWallShadow, Darkness01, Blurriness, XYPosition, Tilt, YScale01 );
00252         */
00253 }
00254 
00255 void CShadowerFlat::GetBaseline( AFloatPt01* Baseline ) const
00256 {
00257     /*
00258     if( pShadower_m )
00259         pShadower_m->GetBaseline( Baseline );*/
00260 }
00261 
00262 // choices range queries //////////////////////////////////////////////////////////////////////////
00263 void CShadowerFlat::GetDarknessRange( AFloatPt01& Min, AFloatPt01& Max ) const
00264 {
00265     /*
00266     if( pShadower_m )
00267         pShadower_m->GetDarknessRange( Min, Max );
00268         */
00269 }
00270 
00271 void CShadowerFlat::GetBlurrinessRange( APixels& Min, APixels& Max ) const
00272 {
00273     /*
00274     if( pShadower_m )
00275         pShadower_m->GetBlurrinessRange( Min,  Max );
00276         */
00277 }
00278 
00279 void CShadowerFlat::GetPositionRange( ACoordPixels Min, ACoordPixels Max) const
00280 {
00281     /*
00282     if( pShadower_m )
00283         pShadower_m->GetPositionRange( Min, Max );
00284         */
00285 }
00286 
00287 void CShadowerFlat::GetProjectionRange( ADegrees& MinTilt, ADegrees& MaxTilt,
00288                                    AFloatPt01& MinYScale, AFloatPt01& MaxYScale ) const
00289 {
00290     /*
00291     if( pShadower_m )
00292         pShadower_m->GetProjectionRange( MinTilt, MaxTilt, MinYScale, MaxYScale );
00293         */
00294 }
00295 
00296 // alpha channel type switches ////////////////////////////////////////////////////////////////////
00297 HRESULT CShadowerFlat::SwitchToTransparencyInsteadOfAlpha( BOOL YesOrNo )
00298 {
00299     /*
00300     if( pShadower_m )
00301         return pShadower_m->SwitchToTransparencyInsteadOfAlpha( YesOrNo );
00302     else
00303         return E_FAIL;
00304         */
00305 
00306     return S_OK;
00307 }
00308 
00309 HRESULT CShadowerFlat::SwitchToUpsideDownPixelAddressing( BOOL YesOrNo )
00310 {
00311     /*
00312     if( pShadower_m )
00313         return pShadower_m->SwitchToUpsideDownPixelAddressing( YesOrNo );
00314     else
00315         return E_FAIL;
00316         */
00317     return S_OK;
00318 }
00319 
00320 // make shadow ////////////////////////////////////////////////////////////////////////////////////
00321 HRESULT CShadowerFlat::InverseShadowBoundCalc( ACoordPixels UnshadowedWidHei, ACoordPixels UnshadowedPos,
00322                                           const ACoordPixels& ShadowedWidHei, const AFloatPt01* Baseline ) const
00323 {
00324     /*
00325     if( pShadower_m )
00326         return pShadower_m->InverseShadowBoundCalc( UnshadowedWidHei, UnshadowedPos, ShadowedWidHei, Baseline );
00327     else
00328         return E_FAIL;
00329         */
00330 
00331     return S_OK;
00332 }
00333 
00334 HRESULT CShadowerFlat::CalcShadowBound( ACoordPixels ShadowWidHei, ACoordPixels ShadowPos, const AAlphaChannel& TransparencyIn,
00335                                    const ACoordPixels& tWidHei, const ACoordPixels& tPos ) const
00336 {
00337     /*
00338     if( pShadower_m )
00339         return pShadower_m->CalcShadowBound( ShadowWidHei, ShadowPos, TransparencyIn, tWidHei, tPos );
00340     else
00341         return E_FAIL;
00342         */
00343 
00344     return S_OK;
00345 }
00346 
00347 HRESULT CShadowerFlat::DrawShadow( const AAlphaChannel& ShadowOut, const ACoordPixels& sWidHei, const ACoordPixels& sPos,
00348                               const AAlphaChannel& TransparencyIn, const ACoordPixels& tWidHei, const ACoordPixels& tPos ) const
00349 {
00350     /*
00351     if( pShadower_m )
00352         return  pShadower_m->DrawShadow( ShadowOut, sWidHei, sPos, TransparencyIn, tWidHei, tPos );
00353     else
00354         return  E_FAIL;
00355         */
00356 
00357     return S_OK;
00358 }

Generated on Sat Nov 10 03:47:56 2007 for Camelot by  doxygen 1.4.4