1 /* This file is part of Shapes.
3 * Shapes is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
8 * Shapes is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with Shapes. If not, see <http://www.gnu.org/licenses/>.
16 * Copyright 2008 Henrik Tidefelt
21 #include "Shapes_Ast_decls.h"
22 #include "Shapes_Kernel_decls.h"
23 #include "Shapes_Lang_decls.h"
24 #include "Shapes_Lang_decls.h"
28 #include "environment.h"
29 #include "pdfstructure.h"
30 #include "elementarylength.h"
31 #include "concretecolors.h"
44 class DynamicBindings
: public Lang::Value
47 typedef std::map
< Kernel::DynamicEnvironmentKeyType
, std::pair
< Kernel::VariableHandle
, const Ast::DynamicBindingExpression
* > > MapType
;
49 virtual ~DynamicBindings( );
51 virtual void bind( MapType
& bindings
, Kernel::SystemDynamicVariables
** sysBindings
) const = 0;
55 class DynamicBindingsNull
: public DynamicBindings
58 DynamicBindingsNull( );
59 virtual ~DynamicBindingsNull( );
60 virtual void bind( MapType
& bindings
, Kernel::SystemDynamicVariables
** sysBindings
) const;
61 virtual void show( std::ostream
& os
) const;
62 virtual void gcMark( Kernel::GCMarkedSet
& marked
);
65 class DynamicBindingsPair
: public DynamicBindings
68 RefCountPtr
< const Lang::DynamicBindings
> car_
;
69 RefCountPtr
< const Lang::DynamicBindings
> cdr_
;
71 DynamicBindingsPair( const RefCountPtr
< const Lang::DynamicBindings
> & car
, const RefCountPtr
< const Lang::DynamicBindings
> & cdr
, bool override
= false );
72 virtual ~DynamicBindingsPair( );
73 virtual void bind( MapType
& bindings
, Kernel::SystemDynamicVariables
** sysBindings
) const;
74 virtual void show( std::ostream
& os
) const;
75 virtual void gcMark( Kernel::GCMarkedSet
& marked
);
78 class UserDynamicBinding
: public DynamicBindings
80 Kernel::DynamicEnvironmentKeyType key_
;
81 const Ast::PlacedIdentifier
* id_
;
82 const Ast::DynamicBindingExpression
* bindingExpr_
;
83 Kernel::VariableHandle var_
;
85 UserDynamicBinding( const Kernel::DynamicEnvironmentKeyType
& key
, const Ast::PlacedIdentifier
* id
, const Ast::DynamicBindingExpression
* bindingExpr
, const Kernel::VariableHandle
& var
);
86 virtual ~UserDynamicBinding( );
87 virtual void bind( MapType
& bindings
, Kernel::SystemDynamicVariables
** sysBindings
) const;
88 virtual void show( std::ostream
& os
) const;
89 virtual void gcMark( Kernel::GCMarkedSet
& marked
);
92 class WidthBinding
: public DynamicBindings
94 const Ast::DynamicBindingExpression
* bindingExpr_
;
95 Concrete::Length val_
;
96 const Ast::PlacedIdentifier
* id_
;
98 WidthBinding( const Ast::PlacedIdentifier
* id
, const Ast::DynamicBindingExpression
* bindingExpr
, Concrete::Length val
);
99 virtual ~WidthBinding( );
100 virtual void bind( MapType
& bindings
, Kernel::SystemDynamicVariables
** sysBindings
) const;
101 virtual void show( std::ostream
& os
) const;
102 virtual void gcMark( Kernel::GCMarkedSet
& marked
);
105 class MiterLimitBinding
: public DynamicBindings
107 const Ast::DynamicBindingExpression
* bindingExpr_
;
109 const Ast::PlacedIdentifier
* id_
;
111 MiterLimitBinding( const Ast::PlacedIdentifier
* id
, const Ast::DynamicBindingExpression
* bindingExpr
, double val
);
112 virtual ~MiterLimitBinding( );
113 virtual void bind( MapType
& bindings
, Kernel::SystemDynamicVariables
** sysBindings
) const;
114 virtual void show( std::ostream
& os
) const;
115 virtual void gcMark( Kernel::GCMarkedSet
& marked
);
118 class Color
: public Lang::Value
123 static RefCountPtr
< const Lang::Class
> TypeID
;
124 static RefCountPtr
< const char > staticTypeName( );
125 virtual void setStroking( std::ostream
& os
) const = 0;
126 virtual void setNonStroking( std::ostream
& os
) const = 0;
127 virtual RefCountPtr
< SimplePDF::PDF_Vector
> componentVector( ) const = 0;
128 virtual void gcMark( Kernel::GCMarkedSet
& marked
){ };
132 class Gray
: public Color
134 Concrete::Gray components_
;
136 Gray( const Concrete::Gray
& components
);
139 virtual void show( std::ostream
& os
) const;
140 virtual void setStroking( std::ostream
& os
) const;
141 virtual void setNonStroking( std::ostream
& os
) const;
142 virtual RefCountPtr
< SimplePDF::PDF_Vector
> componentVector( ) const;
143 const Concrete::Gray
& components( ) const { return components_
; };
147 class RGB
: public Color
149 Concrete::RGB components_
;
151 RGB( const Concrete::RGB
& components
);
154 virtual void show( std::ostream
& os
) const;
155 virtual void setStroking( std::ostream
& os
) const;
156 virtual void setNonStroking( std::ostream
& os
) const;
157 virtual RefCountPtr
< SimplePDF::PDF_Vector
> componentVector( ) const;
158 const Concrete::RGB
& components( ) const { return components_
; };
162 class CMYK
: public Color
164 Concrete::CMYK components_
;
166 CMYK( const Concrete::CMYK
& components
);
169 virtual void show( std::ostream
& os
) const;
170 virtual void setStroking( std::ostream
& os
) const;
171 virtual void setNonStroking( std::ostream
& os
) const;
172 virtual RefCountPtr
< SimplePDF::PDF_Vector
> componentVector( ) const;
173 const Concrete::CMYK
& components( ) const { return components_
; };
177 class StrokingBinding
: public DynamicBindings
179 const Ast::DynamicBindingExpression
* bindingExpr_
;
180 RefCountPtr
< const Lang::Color
> color_
;
181 const Ast::PlacedIdentifier
* id_
;
183 StrokingBinding( const Ast::PlacedIdentifier
* id
, const Ast::DynamicBindingExpression
* bindingExpr
, RefCountPtr
< const Lang::Color
> color
);
184 virtual ~StrokingBinding( );
185 virtual void bind( MapType
& bindings
, Kernel::SystemDynamicVariables
** sysBindings
) const;
186 virtual void show( std::ostream
& os
) const;
187 virtual void gcMark( Kernel::GCMarkedSet
& marked
);
190 class NonStrokingBinding
: public DynamicBindings
192 const Ast::DynamicBindingExpression
* bindingExpr_
;
193 RefCountPtr
< const Lang::Color
> color_
;
194 const Ast::PlacedIdentifier
* id_
;
196 NonStrokingBinding( const Ast::PlacedIdentifier
* id
, const Ast::DynamicBindingExpression
* bindingExpr
, RefCountPtr
< const Lang::Color
> color
);
197 virtual ~NonStrokingBinding( );
198 virtual void bind( MapType
& bindings
, Kernel::SystemDynamicVariables
** sysBindings
) const;
199 virtual void show( std::ostream
& os
) const;
200 virtual void gcMark( Kernel::GCMarkedSet
& marked
);
203 class Alpha
: public Lang::NoOperatorOverloadValue
208 Alpha( bool isShape
, double a
);
210 static void applyGraphicsState( std::ostream
& os
, SimplePDF::PDF_Resources
* resources
, const Lang::Alpha
& self
, bool isStroking
);
212 virtual void gcMark( Kernel::GCMarkedSet
& marked
){ };
215 static std::map
< double, RefCountPtr
< SimplePDF::PDF_Object
> > strokingShapeResourcemap
;
216 static std::map
< double, RefCountPtr
< SimplePDF::PDF_Object
> > strokingOpacityResourcemap
;
217 static std::map
< double, RefCountPtr
< SimplePDF::PDF_Object
> > nonStrokingShapeResourcemap
;
218 static std::map
< double, RefCountPtr
< SimplePDF::PDF_Object
> > nonStrokingOpacityResourcemap
;
221 class AlphaBinding
: public DynamicBindings
223 const Ast::DynamicBindingExpression
* bindingExpr_
;
224 RefCountPtr
< const Lang::Alpha
> alpha_
;
226 const Ast::PlacedIdentifier
* id_
;
228 AlphaBinding( const Ast::PlacedIdentifier
* id
, const Ast::DynamicBindingExpression
* bindingExpr
, const RefCountPtr
< const Lang::Alpha
> & alpha
, bool isStroking
);
229 virtual ~AlphaBinding( );
230 virtual void bind( MapType
& bindings
, Kernel::SystemDynamicVariables
** sysBindings
) const;
231 virtual void show( std::ostream
& os
) const;
232 virtual void gcMark( Kernel::GCMarkedSet
& marked
);
235 class SoftMask
: public Lang::NoOperatorOverloadValue
238 typedef enum { ALPHA
, LUMINOSITY
} SubType
;
239 RefCountPtr
< SimplePDF::PDF_Object
> graphicsStateResource_
;
241 SoftMask( ); // this yields the None soft mask
242 SoftMask( SubType subType
, const RefCountPtr
< const Lang::TransparencyGroup
> & tpGroup
, const RefCountPtr
< const Lang::Color
> & background
, const RefCountPtr
< const Lang::PDF_Function
> & transfer
);
243 virtual ~SoftMask( );
245 virtual void gcMark( Kernel::GCMarkedSet
& marked
){ };
248 class Dash
: public Lang::Value
253 RefCountPtr
< std::list
< Concrete::Length
> > mem_
;
254 std::list
< Concrete::Length
>::const_iterator begin_
;
255 std::list
< Concrete::Length
>::const_iterator end_
;
257 std::list
< Concrete::Length
>::const_iterator i_
;
259 Concrete::Length length_
;
261 Iterator( RefCountPtr
< std::list
< Concrete::Length
> > pattern
, double scale
, std::list
< Concrete::Length
>::const_iterator i
, bool on
, Concrete::Length length
);
262 Iterator
& operator ++ ( );
264 Concrete::Length
getLength( ) const;
267 RefCountPtr
< std::list
< Concrete::Length
> > pattern_
;
268 Concrete::Length phase_
;
270 Concrete::Length myLength_
;
273 Dash( RefCountPtr
< std::list
< Concrete::Length
> > pattern
, Concrete::Length phase
, double scale
);
274 Dash( RefCountPtr
< std::list
< Concrete::Length
> > pattern
, Concrete::Length phase
, double scale
, Concrete::Length length
); // length must be the sum of pattern
277 void setDash( std::ostream
& os
) const;
278 RefCountPtr
< SimplePDF::PDF_Vector
> getDashArray( ) const;
279 RefCountPtr
< const Lang::Dash
> scaled( double factor
) const;
280 RefCountPtr
< const Lang::Dash
> shifted( Concrete::Length dist
) const;
281 Concrete::Length
length( ) const;
282 bool isSolid( ) const;
283 Iterator
begin( ) const;
284 virtual void gcMark( Kernel::GCMarkedSet
& marked
){ };
288 class DashBinding
: public DynamicBindings
290 const Ast::DynamicBindingExpression
* bindingExpr_
;
291 RefCountPtr
< const Lang::Dash
> dash_
;
292 const Ast::PlacedIdentifier
* id_
;
294 DashBinding( const Ast::PlacedIdentifier
* id
, const Ast::DynamicBindingExpression
* bindingExpr
, RefCountPtr
< const Lang::Dash
> dash
);
295 virtual ~DashBinding( );
296 virtual void bind( MapType
& bindings
, Kernel::SystemDynamicVariables
** sysBindings
) const;
297 virtual void show( std::ostream
& os
) const;
298 virtual void gcMark( Kernel::GCMarkedSet
& marked
);
301 class CapStyle
: public Lang::NoOperatorOverloadValue
304 typedef enum { CAP_BUTT
= 0, CAP_ROUND
, CAP_SQUARE
, CAP_SAME
, CAP_UNDEFINED
} ValueType
;
306 CapStyle( const ValueType
& cap
);
308 virtual void gcMark( Kernel::GCMarkedSet
& marked
){ };
311 class CapStyleBinding
: public DynamicBindings
313 const Ast::DynamicBindingExpression
* bindingExpr_
;
314 Lang::CapStyle::ValueType cap_
;
315 const Ast::PlacedIdentifier
* id_
;
317 CapStyleBinding( const Ast::PlacedIdentifier
* id
, const Ast::DynamicBindingExpression
* bindingExpr
, const Lang::CapStyle::ValueType
& cap
);
318 virtual ~CapStyleBinding( );
319 virtual void bind( MapType
& bindings
, Kernel::SystemDynamicVariables
** sysBindings
) const;
320 virtual void show( std::ostream
& os
) const;
321 virtual void gcMark( Kernel::GCMarkedSet
& marked
);
324 class JoinStyle
: public Lang::NoOperatorOverloadValue
327 typedef enum { JOIN_MITER
= 0, JOIN_ROUND
, JOIN_BEVEL
, JOIN_SAME
, JOIN_UNDEFINED
} ValueType
;
329 JoinStyle( const ValueType
& join
);
331 virtual void gcMark( Kernel::GCMarkedSet
& marked
){ };
334 class JoinStyleBinding
: public DynamicBindings
336 const Ast::DynamicBindingExpression
* bindingExpr_
;
337 Lang::JoinStyle::ValueType join_
;
338 const Ast::PlacedIdentifier
* id_
;
340 JoinStyleBinding( const Ast::PlacedIdentifier
* id
, const Ast::DynamicBindingExpression
* bindingExpr
, const Lang::JoinStyle::ValueType
& join
);
341 virtual ~JoinStyleBinding( );
342 virtual void bind( MapType
& bindings
, Kernel::SystemDynamicVariables
** sysBindings
) const;
343 virtual void show( std::ostream
& os
) const;
344 virtual void gcMark( Kernel::GCMarkedSet
& marked
);
347 class BlendMode
: public Lang::NoOperatorOverloadValue
351 NORMAL
= 0, MULTIPLY
, SCREEN
, OVERLAY
, DARKEN
, LIGHTEN
, COLOR_DODGE
, COLOR_BURN
, HARD_LIGHT
, SOFT_LIGHT
, DIFFERENCE
, EXCLUSION
,
352 HUE
, SATURATION
, COLOR
, LUMINOSITY
, BLEND_SAME
, BLEND_UNDEFINED
} ValueType
;
354 BlendMode( const ValueType
& mode
);
356 virtual void gcMark( Kernel::GCMarkedSet
& marked
){ };
357 static void applyGraphicsState( std::ostream
& os
, SimplePDF::PDF_Resources
* resources
, const ValueType
& mode
);
359 static std::map
< ValueType
, RefCountPtr
< SimplePDF::PDF_Object
> > resourceMap
;
362 class BlendModeBinding
: public DynamicBindings
364 const Ast::DynamicBindingExpression
* bindingExpr_
;
365 Lang::BlendMode::ValueType blend_
;
366 const Ast::PlacedIdentifier
* id_
;
368 BlendModeBinding( const Ast::PlacedIdentifier
* id
, const Ast::DynamicBindingExpression
* bindingExpr
, const Lang::BlendMode::ValueType
& blend
);
369 virtual ~BlendModeBinding( );
370 virtual void bind( MapType
& bindings
, Kernel::SystemDynamicVariables
** sysBindings
) const;
371 virtual void show( std::ostream
& os
) const;
372 virtual void gcMark( Kernel::GCMarkedSet
& marked
);
375 // Currently, color space is not part of the graphics state; it's only used for blending in transparency groups.
376 // However, since it can be part of the graphcs state, the definition is placed here anyway.
377 // The related dynamic binding classes are found in dynamicenvironment.h
378 class ColorSpace
: public Lang::NoOperatorOverloadValue
382 virtual ~ColorSpace( );
384 virtual RefCountPtr
< SimplePDF::PDF_Name
> name( ) const = 0;
385 virtual bool isInherent( ) const { return false; }
386 virtual bool isBlendable( ) const { return false; }
387 virtual bool containsColor( const Lang::Color
* col
) const = 0;
388 virtual size_t numberOfComponents( ) const = 0;
389 virtual void show( std::ostream
& os
) const;
390 virtual void gcMark( Kernel::GCMarkedSet
& marked
){ };
393 class InheritedColorSpace
: public Lang::ColorSpace
396 InheritedColorSpace( );
397 ~InheritedColorSpace( );
398 virtual bool isInherent( ) const { return true; }
399 virtual bool isBlendable( ) const { return true; }
400 virtual bool containsColor( const Lang::Color
* col
) const;
401 virtual RefCountPtr
< SimplePDF::PDF_Name
> name( ) const;
402 virtual size_t numberOfComponents( ) const;
403 virtual void gcMark( Kernel::GCMarkedSet
& marked
){ };
407 class DeviceColorSpace
: public Lang::ColorSpace
409 RefCountPtr
< const SimplePDF::PDF_Name
> space_
;
410 size_t numberOfComponents_
;
412 DeviceColorSpace( const char * spaceName
, size_t numOfComponents
);
413 ~DeviceColorSpace( );
414 virtual bool isBlendable( ) const { return true; }
415 virtual bool containsColor( const Lang::Color
* col
) const;
416 virtual RefCountPtr
< SimplePDF::PDF_Name
> name( ) const;
417 virtual size_t numberOfComponents( ) const;
418 virtual void gcMark( Kernel::GCMarkedSet
& marked
){ };
422 DeviceColorSpace
< C
>::DeviceColorSpace( const char * spaceName
, size_t numOfComponents
)
423 : space_( RefCountPtr
< SimplePDF::PDF_Name
>( new SimplePDF::PDF_Name( spaceName
) ) ),
424 numberOfComponents_( numOfComponents
)
428 DeviceColorSpace
< C
>::~DeviceColorSpace
< C
>( )
432 RefCountPtr
< SimplePDF::PDF_Name
>
433 DeviceColorSpace
< C
>::name( ) const
435 return space_
.unconst_cast
< SimplePDF::PDF_Name
>( );
440 DeviceColorSpace
< C
>::numberOfComponents( ) const
442 return numberOfComponents_
;
447 DeviceColorSpace
< C
>::containsColor( const Lang::Color
* col
) const
449 return dynamic_cast< const C
* >( col
) != 0;
457 class UserDynamicVariableProperties
: public Kernel::DynamicVariableProperties
459 Kernel::DynamicEnvironmentKeyType key_
;
460 RefCountPtr
< const Lang::Function
> filter_
;
461 Kernel::VariableHandle defaultVal_
;
463 UserDynamicVariableProperties( const Ast::PlacedIdentifier
* id
, const Kernel::DynamicEnvironmentKeyType
& key
, const RefCountPtr
< const Lang::Function
> & filter
, const Kernel::VariableHandle
& defaultVal
);
464 virtual ~UserDynamicVariableProperties( );
466 virtual Kernel::VariableHandle
fetch( const Kernel::PassedDyn
& dyn
) const;
467 virtual void makeBinding( Kernel::VariableHandle val
, const Ast::DynamicBindingExpression
* bindingExpr
, Kernel::EvalState
* evalState
) const;
470 class UserDynamicStateProperties
: public Kernel::DynamicStateProperties
472 // Kernel::DynamicEnvironmentKeyType key_; /* Commented out to quiet compiler warning about unused member. */
473 Kernel::PassedEnv defaultStateEnv_
;
474 Kernel::PassedDyn defaultStateDyn_
;
475 Ast::StateReference
* defaultState_
;
477 UserDynamicStateProperties( const Ast::PlacedIdentifier
* id
, const Kernel::PassedEnv
& defaultStateEnv
, Kernel::PassedDyn defaultStateDyn
, Ast::StateReference
* defaultState
);
478 // UserDynamicStateProperties( const Ast::PlacedIdentifier * id, const Kernel::DynamicEnvironmentKeyType & key, const Kernel::PassedEnv & defaultStateEnv, Kernel::PassedDyn defaultStateDyn, Ast::StateReference * defaultState );
479 virtual ~UserDynamicStateProperties( );
481 virtual Kernel::StateHandle
fetch( const Kernel::PassedDyn
& dyn
) const;
482 virtual void makeBinding( Kernel::StateHandle val
, const Ast::DynamicStateBindingExpression
* bindingExpr
, Kernel::EvalState
* evalState
) const;
485 class WidthDynamicVariableProperties
: public Kernel::DynamicVariableProperties
488 WidthDynamicVariableProperties( const Ast::PlacedIdentifier
* id
);
489 virtual ~WidthDynamicVariableProperties( );
490 virtual Kernel::VariableHandle
fetch( const Kernel::PassedDyn
& dyn
) const;
491 virtual void makeBinding( Kernel::VariableHandle val
, const Ast::DynamicBindingExpression
* bindingExpr
, Kernel::EvalState
* evalState
) const;
493 class MiterLimitDynamicVariableProperties
: public Kernel::DynamicVariableProperties
496 MiterLimitDynamicVariableProperties( const Ast::PlacedIdentifier
* id
);
497 virtual ~MiterLimitDynamicVariableProperties( );
498 virtual Kernel::VariableHandle
fetch( const Kernel::PassedDyn
& dyn
) const;
499 virtual void makeBinding( Kernel::VariableHandle val
, const Ast::DynamicBindingExpression
* bindingExpr
, Kernel::EvalState
* evalState
) const;
502 class StrokingDynamicVariableProperties
: public Kernel::DynamicVariableProperties
505 StrokingDynamicVariableProperties( const Ast::PlacedIdentifier
* id
);
506 virtual ~StrokingDynamicVariableProperties( );
507 virtual Kernel::VariableHandle
fetch( const Kernel::PassedDyn
& dyn
) const;
508 virtual void makeBinding( Kernel::VariableHandle val
, const Ast::DynamicBindingExpression
* bindingExpr
, Kernel::EvalState
* evalState
) const;
510 class NonStrokingDynamicVariableProperties
: public Kernel::DynamicVariableProperties
513 NonStrokingDynamicVariableProperties( const Ast::PlacedIdentifier
* id
);
514 virtual ~NonStrokingDynamicVariableProperties( );
515 virtual Kernel::VariableHandle
fetch( const Kernel::PassedDyn
& dyn
) const;
516 virtual void makeBinding( Kernel::VariableHandle val
, const Ast::DynamicBindingExpression
* bindingExpr
, Kernel::EvalState
* evalState
) const;
518 class AlphaDynamicVariableProperties
: public Kernel::DynamicVariableProperties
522 AlphaDynamicVariableProperties( const Ast::PlacedIdentifier
* id
, bool isStroking
);
523 virtual ~AlphaDynamicVariableProperties( );
524 virtual Kernel::VariableHandle
fetch( const Kernel::PassedDyn
& dyn
) const;
525 virtual void makeBinding( Kernel::VariableHandle val
, const Ast::DynamicBindingExpression
* bindingExpr
, Kernel::EvalState
* evalState
) const;
528 class DashDynamicVariableProperties
: public Kernel::DynamicVariableProperties
531 DashDynamicVariableProperties( const Ast::PlacedIdentifier
* id
);
532 virtual ~DashDynamicVariableProperties( );
533 virtual Kernel::VariableHandle
fetch( const Kernel::PassedDyn
& dyn
) const;
534 virtual void makeBinding( Kernel::VariableHandle val
, const Ast::DynamicBindingExpression
* bindingExpr
, Kernel::EvalState
* evalState
) const;
536 class CapStyleDynamicVariableProperties
: public Kernel::DynamicVariableProperties
539 CapStyleDynamicVariableProperties( const Ast::PlacedIdentifier
* id
);
540 virtual ~CapStyleDynamicVariableProperties( );
541 virtual Kernel::VariableHandle
fetch( const Kernel::PassedDyn
& dyn
) const;
542 virtual void makeBinding( Kernel::VariableHandle val
, const Ast::DynamicBindingExpression
* bindingExpr
, Kernel::EvalState
* evalState
) const;
544 class JoinStyleDynamicVariableProperties
: public Kernel::DynamicVariableProperties
547 JoinStyleDynamicVariableProperties( const Ast::PlacedIdentifier
* id
);
548 virtual ~JoinStyleDynamicVariableProperties( );
549 virtual Kernel::VariableHandle
fetch( const Kernel::PassedDyn
& dyn
) const;
550 virtual void makeBinding( Kernel::VariableHandle val
, const Ast::DynamicBindingExpression
* bindingExpr
, Kernel::EvalState
* evalState
) const;
552 class BlendModeDynamicVariableProperties
: public Kernel::DynamicVariableProperties
555 BlendModeDynamicVariableProperties( const Ast::PlacedIdentifier
* id
);
556 virtual ~BlendModeDynamicVariableProperties( );
557 virtual Kernel::VariableHandle
fetch( const Kernel::PassedDyn
& dyn
) const;
558 virtual void makeBinding( Kernel::VariableHandle val
, const Ast::DynamicBindingExpression
* bindingExpr
, Kernel::EvalState
* evalState
) const;
564 RefCountPtr
< const Lang::Color
> strokingColor_
; // Use Gray( -1 ) for no-op, and NullPtr for undefined
565 RefCountPtr
< const Lang::Color
> nonStrokingColor_
; // Use Gray( -1 ) for no-op, and NullPtr for undefined
566 Concrete::Length width_
; // Use negative value for no-op, and NAN for undefined
567 Lang::CapStyle::ValueType cap_
;
568 Lang::JoinStyle::ValueType join_
;
569 double miterLimit_
; // Use negative value for no-op, and NAN for undefined
570 RefCountPtr
< const Lang::Dash
> dash_
; // (Dash with negative scale is no-op.) Use NullPtr for undefined
571 Lang::BlendMode::ValueType blend_
;
572 bool alphaIsShape_
; // See below.
573 RefCountPtr
< const Lang::Alpha
> strokingAlpha_
; // Use negative value for no-op, NAN for undefined
574 RefCountPtr
< const Lang::Alpha
> nonStrokingAlpha_
; // Use negative value for no-op, NAN for undefined
577 explicit GraphicsState( const Kernel::GraphicsState
& orig
); // explicit, since reference counting shall be used in most cases
578 GraphicsState( const Kernel::GraphicsState
& newValues
, const Kernel::GraphicsState
& oldValues
);
579 GraphicsState( bool setDefaults
);
582 bool synchStrokingColor( std::ostream
& os
, const GraphicsState
* ref
, SimplePDF::PDF_Resources
* resources
, bool force
= false );
583 bool synchNonStrokingColor( std::ostream
& os
, const GraphicsState
* ref
, SimplePDF::PDF_Resources
* resources
, bool force
= false );
584 bool synchStrokingAlpha( std::ostream
& os
, const GraphicsState
* ref
, SimplePDF::PDF_Resources
* resources
, bool force
= false );
585 bool synchNonStrokingAlpha( std::ostream
& os
, const GraphicsState
* ref
, SimplePDF::PDF_Resources
* resources
, bool force
= false );
586 bool synchWidth( std::ostream
& os
, const GraphicsState
* ref
, SimplePDF::PDF_Resources
* resources
, bool force
= false );
587 bool synchCap( std::ostream
& os
, const GraphicsState
* ref
, SimplePDF::PDF_Resources
* resources
, bool force
= false );
588 bool synchJoin( std::ostream
& os
, const GraphicsState
* ref
, SimplePDF::PDF_Resources
* resources
, bool force
= false );
589 bool synchMiterLimit( std::ostream
& os
, const GraphicsState
* ref
, SimplePDF::PDF_Resources
* resources
, bool force
= false );
590 bool synchDash( std::ostream
& os
, const GraphicsState
* ref
, SimplePDF::PDF_Resources
* resources
, bool force
= false );
591 bool synchBlend( std::ostream
& os
, const GraphicsState
* ref
, SimplePDF::PDF_Resources
* resources
, bool force
= false );
593 bool synchForStroke( std::ostream
& os
, const GraphicsState
* ref
, SimplePDF::PDF_Resources
* resources
, bool force
= false );
594 bool synchForNonStroke( std::ostream
& os
, const GraphicsState
* ref
, SimplePDF::PDF_Resources
* resources
, bool force
= false );
596 bool synchStrokingColorWithNonStrokingColor( std::ostream
& os
, SimplePDF::PDF_Resources
* resources
, Concrete::Length width
= Concrete::Length( std::numeric_limits
< double >::signaling_NaN( ) ) );
598 void print( std::ostream
& os
, const std::string
& indentation
) const;
603 /* Since it is not easy to determine from the PDF documentation that the text state is also
604 * affected by the q-Q pair, the text state was originally not saved here.
605 * However, this generated bad results on all tested PDF viewers when a transform
606 * was applied to a Clipped2D object, and it was concluded that with respect to q-Q, there
607 * is no difference between text and graphics states.
609 Kernel::GraphicsState
* graphicsState_
;
610 Kernel::GraphicsState
* graphicsEnterState_
;
611 Kernel::TextState
* textState_
;
612 Kernel::TextState
* textEnterState_
;
616 Auto_qQ( Kernel::GraphicsState
* graphicsState
, Kernel::TextState
* textState
, std::ostream
& os
, bool active
= true );