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, 2010 Henrik Tidefelt
21 #include "Shapes_Helpers_decls.h"
23 #include "shapestypes.h"
24 #include "shapesexceptions.h"
28 #include "angleselect.h"
31 #include "shapescore.h"
32 #include "simplepdfo.h"
34 #include "pdffunctiontypes.h"
40 using namespace Shapes
;
44 Lang::DynamicBindings::DynamicBindings( )
46 Lang::DynamicBindings::~DynamicBindings( )
49 RefCountPtr
< const Lang::Class
> Lang::DynamicBindings::TypeID( new Lang::SystemFinalClass( strrefdup( "DynamicBindings" ) ) );
50 TYPEINFOIMPL( DynamicBindings
);
51 DISPATCHIMPL( DynamicBindings
);
54 Lang::DynamicBindingsPair::DynamicBindingsPair( const RefCountPtr
< const Lang::DynamicBindings
> & car
, const RefCountPtr
< const Lang::DynamicBindings
> & cdr
, bool override
)
55 : override_( override
), car_( car
), cdr_( cdr
)
58 Lang::DynamicBindingsPair::~DynamicBindingsPair( )
62 Lang::DynamicBindingsPair::bind( MapType
& bindings
, Kernel::SystemDynamicVariables
** sysBindings
) const
66 cdr_
->bind( bindings
, sysBindings
);
68 Kernel::SystemDynamicVariables
* carSysBindings
= 0;
69 car_
->bind( carBindings
, & carSysBindings
);
71 if( bindings
.empty( ) )
73 bindings
.swap( carBindings
);
77 MapType::iterator dst
= bindings
.begin( );
78 /* Merge the MapType bindings */
79 for( MapType::const_iterator src
= carBindings
.begin( ); src
!= carBindings
.end( ); )
81 if( src
->first
< dst
->first
)
83 bindings
.insert( dst
, *src
);
87 if( src
->first
> dst
->first
)
89 dst
= bindings
.lower_bound( src
->first
);
90 if( dst
== bindings
.end( ) )
92 for( ; src
!= carBindings
.end( ); ++src
)
94 bindings
.insert( bindings
.end( ), *src
);
98 continue; /* Should we do something more clever here? */
100 /* If we reach here, the bindings appeared in both maps, and we ignore that in the car part. */
105 if( carSysBindings
!= 0 )
107 if( *sysBindings
== 0 )
109 *sysBindings
= carSysBindings
;
113 /* Merge the SystemDynamicVariables bindings */
114 (*sysBindings
)->addFrom( *carSysBindings
);
115 delete carSysBindings
;
121 car_
->bind( bindings
, sysBindings
);
122 cdr_
->bind( bindings
, sysBindings
);
127 Lang::DynamicBindingsPair::show( std::ostream
& os
) const
129 bool showCar
= false;
130 if( dynamic_cast< const Lang::DynamicBindingsNull
* >( car_
.getPtr( ) ) == 0 )
135 if( dynamic_cast< const Lang::DynamicBindingsNull
* >( cdr_
.getPtr( ) ) == 0 )
146 Lang::DynamicBindingsPair::gcMark( Kernel::GCMarkedSet
& marked
)
148 const_cast< Lang::DynamicBindings
* >( car_
.getPtr( ) )->gcMark( marked
);
149 const_cast< Lang::DynamicBindings
* >( cdr_
.getPtr( ) )->gcMark( marked
);
153 Lang::DynamicBindingsNull::DynamicBindingsNull( )
156 Lang::DynamicBindingsNull::~DynamicBindingsNull( )
160 Lang::DynamicBindingsNull::bind( MapType
& bindings
, Kernel::SystemDynamicVariables
** sysBindings
) const
165 Lang::DynamicBindingsNull::show( std::ostream
& os
) const
167 os
<< "@(an empty set of dynamic bindings)" ;
171 Lang::DynamicBindingsNull::gcMark( Kernel::GCMarkedSet
& marked
)
176 Lang::UserDynamicBinding::UserDynamicBinding( const Kernel::DynamicEnvironmentKeyType
& key
, const Ast::PlacedIdentifier
* id
, const Ast::DynamicBindingExpression
* bindingExpr
, const Kernel::VariableHandle
& var
)
177 : key_( key
), id_( id
), bindingExpr_( bindingExpr
), var_( var
)
180 Lang::UserDynamicBinding::~UserDynamicBinding( )
184 Lang::UserDynamicBinding::bind( MapType
& bindings
, Kernel::SystemDynamicVariables
** sysBindings
) const
186 MapType::iterator i
= bindings
.find( key_
);
187 if( i
!= bindings
.end( ) )
189 throw Exceptions::MultipleDynamicBind( id_
, bindingExpr_
->idLoc( ), i
->second
.second
->idLoc( ) );
191 bindings
.insert( MapType::value_type( key_
, MapType::value_type::second_type( var_
, bindingExpr_
) ) );
195 Lang::UserDynamicBinding::show( std::ostream
& os
) const
197 os
<< Interaction::DYNAMIC_VARIABLE_PREFIX
<< id_
<< ":" ;
200 var_
->getUntyped( )->show( os
);
209 Lang::UserDynamicBinding::gcMark( Kernel::GCMarkedSet
& marked
)
211 var_
->gcMark( marked
);
220 class UserDynamicBindingContinuation
: public Kernel::Continuation
222 Kernel::DynamicEnvironmentKeyType key_
;
223 const Ast::PlacedIdentifier
* id_
;
224 const Ast::DynamicBindingExpression
* bindingExpr_
;
225 Kernel::ContRef cont_
;
227 UserDynamicBindingContinuation( const Ast::SourceLocation
& traceLoc
, const Kernel::DynamicEnvironmentKeyType
& key
, const Ast::PlacedIdentifier
* id
, const Ast::DynamicBindingExpression
* bindingExpr
, const Kernel::ContRef
& cont
)
228 : Kernel::Continuation( traceLoc
), key_( key
), id_( id
), bindingExpr_( bindingExpr
), cont_( cont
)
230 virtual ~UserDynamicBindingContinuation( )
232 virtual void takeHandle( Kernel::VariableHandle val
, Kernel::EvalState
* evalState
, bool dummy
) const
234 cont_
->takeValue( Kernel::ValueRef( new Lang::UserDynamicBinding( key_
, id_
, bindingExpr_
, val
) ),
237 virtual Kernel::ContRef
up( ) const
241 virtual RefCountPtr
< const char > description( ) const
243 return strrefdup( "make user dynamic binding" );
245 virtual void gcMark( Kernel::GCMarkedSet
& marked
)
247 cont_
->gcMark( marked
);
255 Kernel::UserDynamicVariableProperties::UserDynamicVariableProperties( const Ast::PlacedIdentifier
* id
, const Kernel::DynamicEnvironmentKeyType
& key
, const RefCountPtr
< const Lang::Function
> & filter
, const Kernel::VariableHandle
& defaultVal
)
256 : DynamicVariableProperties( id
), key_( key
), filter_( filter
), defaultVal_( defaultVal
)
259 Kernel::UserDynamicVariableProperties::~UserDynamicVariableProperties( )
262 Kernel::VariableHandle
263 Kernel::UserDynamicVariableProperties::fetch( const Kernel::PassedDyn
& dyn
) const
267 return dyn
->getVarHandle( key_
);
269 catch( const NonLocalExit::DynamicBindingNotFound
& ball
)
276 Kernel::UserDynamicVariableProperties::makeBinding( Kernel::VariableHandle val
, const Ast::DynamicBindingExpression
* bindingExpr
, Kernel::EvalState
* evalState
) const
278 if( filter_
== Lang::THE_IDENTITY
)
280 Kernel::ContRef cont
= evalState
->cont_
;
281 cont
->takeValue( Kernel::ValueRef( new Lang::UserDynamicBinding( key_
, id_
, bindingExpr
, val
) ),
286 evalState
->cont_
= Kernel::ContRef( new Kernel::UserDynamicBindingContinuation( bindingExpr
->exprLoc( ), key_
, id_
, bindingExpr
, evalState
->cont_
) );
288 filter_
->call( filter_
, evalState
, val
, bindingExpr
->exprLoc( ) );
292 Kernel::UserDynamicStateProperties::UserDynamicStateProperties( const Ast::PlacedIdentifier
* id
, const Kernel::PassedEnv
& defaultStateEnv
, Kernel::PassedDyn defaultStateDyn
, Ast::StateReference
* defaultState
)
293 : DynamicStateProperties( id
),
295 defaultStateEnv_( defaultStateEnv
), defaultStateDyn_( defaultStateDyn
), defaultState_( defaultState
)
298 Kernel::UserDynamicStateProperties::~UserDynamicStateProperties( )
302 Kernel::UserDynamicStateProperties::fetch( const Kernel::PassedDyn
& dyn
) const
306 throw Exceptions::NotImplemented( "Fetching dynamic states" );
307 // return dyn->getStateHandle( key_ );
309 catch( const NonLocalExit::DynamicBindingNotFound
& ball
)
311 return defaultState_
->getHandle( defaultStateEnv_
, defaultStateDyn_
);
316 Kernel::UserDynamicStateProperties::makeBinding( Kernel::StateHandle val
, const Ast::DynamicStateBindingExpression
* bindingExpr
, Kernel::EvalState
* evalState
) const
318 throw Exceptions::NotImplemented( "Creation of dynamic state bindings" );
323 Lang::WidthBinding::WidthBinding( const Ast::PlacedIdentifier
* id
, const Ast::DynamicBindingExpression
* bindingExpr
, Concrete::Length val
)
324 : bindingExpr_( bindingExpr
), val_( val
), id_( id
)
327 Lang::WidthBinding::~WidthBinding( )
331 Lang::WidthBinding::bind( MapType
& bindings
, Kernel::SystemDynamicVariables
** sysBindings
) const
333 if( *sysBindings
== 0 )
335 *sysBindings
= new Kernel::SystemDynamicVariables( );
336 Kernel::GraphicsState
* newState
= new Kernel::GraphicsState( );
337 newState
->width_
= val_
;
338 (*sysBindings
)->graphicsState_
= RefCountPtr
< const Kernel::GraphicsState
>( newState
);
342 if( (*sysBindings
)->graphicsState_
== NullPtr
< const Kernel::GraphicsState
>( ) )
344 Kernel::GraphicsState
* newState
= new Kernel::GraphicsState( );
345 newState
->width_
= val_
;
346 (*sysBindings
)->graphicsState_
= RefCountPtr
< const Kernel::GraphicsState
>( newState
);
350 Kernel::GraphicsState
* newState
= new Kernel::GraphicsState( *((*sysBindings
)->graphicsState_
) );
352 if( ! IS_NAN( newState
->width_
) )
354 throw Exceptions::MultipleDynamicBind( id_
, bindingExpr_
->idLoc( ), Ast::THE_UNKNOWN_LOCATION
);
357 newState
->width_
= val_
;
358 (*sysBindings
)->graphicsState_
= RefCountPtr
< const Kernel::GraphicsState
>( newState
);
362 Lang::WidthBinding::show( std::ostream
& os
) const
364 os
<< Interaction::DYNAMIC_VARIABLE_PREFIX
<< id_
<< ":"
365 << double( val_
.offtype
< 1, 0 >( ) ) * Interaction::displayUnitFactor
<< Interaction::displayUnitName
;
369 Lang::WidthBinding::gcMark( Kernel::GCMarkedSet
& marked
)
374 Kernel::WidthDynamicVariableProperties::WidthDynamicVariableProperties( const Ast::PlacedIdentifier
* id
)
375 : Kernel::DynamicVariableProperties( id
)
378 Kernel::WidthDynamicVariableProperties::~WidthDynamicVariableProperties( )
381 Kernel::VariableHandle
382 Kernel::WidthDynamicVariableProperties::fetch( const Kernel::PassedDyn
& dyn
) const
384 RefCountPtr
< const Kernel::GraphicsState
> graphicsState
= dyn
->getGraphicsState( );
385 return Kernel::VariableHandle( new Kernel::Variable( RefCountPtr
< const Lang::Value
>( new Lang::Length( graphicsState
->width_
) ) ) );
389 Kernel::WidthDynamicVariableProperties::makeBinding( Kernel::VariableHandle val
, const Ast::DynamicBindingExpression
* bindingExpr
, Kernel::EvalState
* evalState
) const
393 RefCountPtr
< const Lang::Length
> len
= val
->tryVal
< const Lang::Length
>( );
394 if( len
->getScalar( ) < 0 )
396 throw Exceptions::OutOfRange( bindingExpr
->exprLoc( ), strrefdup( "The length must be non-negative." ) );
398 Kernel::ContRef cont
= evalState
->cont_
;
399 cont
->takeValue( Kernel::ValueRef( new Lang::WidthBinding( id_
, bindingExpr
, len
->get( ) ) ),
403 catch( const NonLocalExit::NotThisType
& ball
)
410 RefCountPtr
< const Lang::Void
> dummy
= val
->tryVal
< const Lang::Void
>( );
411 Kernel::ContRef cont
= evalState
->cont_
;
412 cont
->takeValue( Kernel::ValueRef( new Lang::WidthBinding( id_
, bindingExpr
, Concrete::Length( -1 ) ) ),
416 catch( const NonLocalExit::NotThisType
& ball
)
421 throw Exceptions::TypeMismatch( bindingExpr
->exprLoc( ), val
->getUntyped( )->getTypeName( ), Helpers::typeSetString( Lang::Length::staticTypeName( ), Lang::Void::staticTypeName( ) ) );
425 Lang::MiterLimitBinding::MiterLimitBinding( const Ast::PlacedIdentifier
* id
, const Ast::DynamicBindingExpression
* bindingExpr
, double val
)
426 : bindingExpr_( bindingExpr
), val_( val
), id_( id
)
429 Lang::MiterLimitBinding::~MiterLimitBinding( )
433 Lang::MiterLimitBinding::bind( MapType
& bindings
, Kernel::SystemDynamicVariables
** sysBindings
) const
435 if( *sysBindings
== 0 )
437 *sysBindings
= new Kernel::SystemDynamicVariables( );
438 Kernel::GraphicsState
* newState
= new Kernel::GraphicsState( );
439 newState
->miterLimit_
= val_
;
440 (*sysBindings
)->graphicsState_
= RefCountPtr
< const Kernel::GraphicsState
>( newState
);
444 if( (*sysBindings
)->graphicsState_
== NullPtr
< const Kernel::GraphicsState
>( ) )
446 Kernel::GraphicsState
* newState
= new Kernel::GraphicsState( );
447 newState
->miterLimit_
= val_
;
448 (*sysBindings
)->graphicsState_
= RefCountPtr
< const Kernel::GraphicsState
>( newState
);
452 Kernel::GraphicsState
* newState
= new Kernel::GraphicsState( *((*sysBindings
)->graphicsState_
) );
454 if( ! IS_NAN( newState
->miterLimit_
) )
456 throw Exceptions::MultipleDynamicBind( id_
, bindingExpr_
->idLoc( ), Ast::THE_UNKNOWN_LOCATION
);
459 newState
->miterLimit_
= val_
;
460 (*sysBindings
)->graphicsState_
= RefCountPtr
< const Kernel::GraphicsState
>( newState
);
464 Lang::MiterLimitBinding::show( std::ostream
& os
) const
466 os
<< Interaction::DYNAMIC_VARIABLE_PREFIX
<< id_
<< ":" ;
473 Lang::THE_VOID
->show( os
);
478 Lang::MiterLimitBinding::gcMark( Kernel::GCMarkedSet
& marked
)
483 Kernel::MiterLimitDynamicVariableProperties::MiterLimitDynamicVariableProperties( const Ast::PlacedIdentifier
* id
)
484 : Kernel::DynamicVariableProperties( id
)
487 Kernel::MiterLimitDynamicVariableProperties::~MiterLimitDynamicVariableProperties( )
490 Kernel::VariableHandle
491 Kernel::MiterLimitDynamicVariableProperties::fetch( const Kernel::PassedDyn
& dyn
) const
493 RefCountPtr
< const Kernel::GraphicsState
> graphicsState
= dyn
->getGraphicsState( );
494 return Kernel::VariableHandle( new Kernel::Variable( RefCountPtr
< const Lang::Value
>( new Lang::Float( graphicsState
->miterLimit_
) ) ) );
498 Kernel::MiterLimitDynamicVariableProperties::makeBinding( Kernel::VariableHandle val
, const Ast::DynamicBindingExpression
* bindingExpr
, Kernel::EvalState
* evalState
) const
502 double lim
= val
->tryVal
< const Lang::Float
>( )->val_
;
505 throw Exceptions::OutOfRange( bindingExpr
->exprLoc( ), strrefdup( "The miter limit must be at least 1. Change the join style rather than the miter limit if you always want bevel joins." ) );
507 Kernel::ContRef cont
= evalState
->cont_
;
508 cont
->takeValue( Kernel::ValueRef( new Lang::MiterLimitBinding( id_
, bindingExpr
, lim
) ),
512 catch( const NonLocalExit::NotThisType
& ball
)
519 RefCountPtr
< const Lang::Void
> dummy
= val
->tryVal
< const Lang::Void
>( );
520 Kernel::ContRef cont
= evalState
->cont_
;
521 cont
->takeValue( Kernel::ValueRef( new Lang::MiterLimitBinding( id_
, bindingExpr
, -1 ) ),
525 catch( const NonLocalExit::NotThisType
& ball
)
530 throw Exceptions::TypeMismatch( bindingExpr
->exprLoc( ), val
->getUntyped( )->getTypeName( ), Helpers::typeSetString( Lang::Float::staticTypeName( ), Lang::Void::staticTypeName( ) ) );
534 Lang::CapStyle::CapStyle( const Lang::CapStyle::ValueType
& cap
)
538 RefCountPtr
< const Lang::Class
> Lang::CapStyle::TypeID( new Lang::SystemFinalClass( strrefdup( "CapStyle" ) ) );
539 TYPEINFOIMPL( CapStyle
);
542 Lang::JoinStyle::JoinStyle( const Lang::JoinStyle::ValueType
& join
)
546 RefCountPtr
< const Lang::Class
> Lang::JoinStyle::TypeID( new Lang::SystemFinalClass( strrefdup( "JoinStyle" ) ) );
547 TYPEINFOIMPL( JoinStyle
);
550 Lang::BlendMode::BlendMode( const Lang::BlendMode::ValueType
& mode
)
554 RefCountPtr
< const Lang::Class
> Lang::BlendMode::TypeID( new Lang::SystemFinalClass( strrefdup( "BlendMode" ) ) );
555 TYPEINFOIMPL( BlendMode
);
557 std::map
< Lang::BlendMode::ValueType
, RefCountPtr
< SimplePDF::PDF_Object
> > Lang::BlendMode::resourceMap
;
560 Lang::BlendMode::applyGraphicsState( std::ostream
& os
, SimplePDF::PDF_Resources
* resources
, const Lang::BlendMode::ValueType
& mode
)
562 typedef typeof resourceMap MapType
;
563 MapType::const_iterator i
= resourceMap
.find( mode
);
564 if( i
!= resourceMap
.end( ) )
566 os
<< resources
->nameofGraphicsState( i
->second
) << " gs " ;
570 RefCountPtr
< SimplePDF::PDF_Dictionary
> dic
;
571 (*dic
)[ "Type" ] = SimplePDF::newName( "ExtGState" );
573 RefCountPtr
< SimplePDF::PDF_Object
> indirection
= SimplePDF::indirect( dic
, & Kernel::theIndirectObjectCount
);
574 resourceMap
.insert( MapType::value_type( mode
, indirection
) );
578 (*dic
)[ "BM" ] = SimplePDF::newName( "Normal" );
581 (*dic
)[ "BM" ] = SimplePDF::newName( "Multiply" );
584 (*dic
)[ "BM" ] = SimplePDF::newName( "Screen" );
587 (*dic
)[ "BM" ] = SimplePDF::newName( "Overlay" );
590 (*dic
)[ "BM" ] = SimplePDF::newName( "Darken" );
593 (*dic
)[ "BM" ] = SimplePDF::newName( "Lighten" );
596 (*dic
)[ "BM" ] = SimplePDF::newName( "ColorDodge" );
599 (*dic
)[ "BM" ] = SimplePDF::newName( "ColorBurn" );
602 (*dic
)[ "BM" ] = SimplePDF::newName( "HardLight" );
605 (*dic
)[ "BM" ] = SimplePDF::newName( "SoftLight" );
608 (*dic
)[ "BM" ] = SimplePDF::newName( "Difference" );
611 (*dic
)[ "BM" ] = SimplePDF::newName( "Exclusion" );
614 (*dic
)[ "BM" ] = SimplePDF::newName( "Hue" );
617 (*dic
)[ "BM" ] = SimplePDF::newName( "Saturation" );
620 (*dic
)[ "BM" ] = SimplePDF::newName( "Color" );
623 (*dic
)[ "BM" ] = SimplePDF::newName( "Luminosity" );
626 // We leave the graphics state dictionary empty!
629 throw Exceptions::InternalError( strrefdup( "BlendMode switch out of range." ) );
631 os
<< resources
->nameofGraphicsState( indirection
) << " gs " ;
636 Kernel::GraphicsState::GraphicsState( )
637 : strokingColor_( NullPtr
< const Lang::Color
>( ) ),
638 nonStrokingColor_( NullPtr
< const Lang::Color
>( ) ),
639 width_( std::numeric_limits
< double >::signaling_NaN( ) ),
640 cap_( Lang::CapStyle::CAP_UNDEFINED
),
641 join_( Lang::JoinStyle::JOIN_UNDEFINED
),
642 miterLimit_( std::numeric_limits
< double >::signaling_NaN( ) ),
643 dash_( NullPtr
< const Lang::Dash
>( ) ),
644 blend_( Lang::BlendMode::BLEND_UNDEFINED
),
645 alphaIsShape_( true ),
646 strokingAlpha_( NullPtr
< const Lang::Alpha
>( ) ),
647 nonStrokingAlpha_( NullPtr
< const Lang::Alpha
>( ) )
650 Kernel::GraphicsState::GraphicsState( const Kernel::GraphicsState
& orig
)
651 : strokingColor_( orig
.strokingColor_
),
652 nonStrokingColor_( orig
.nonStrokingColor_
),
653 width_( orig
.width_
),
656 miterLimit_( orig
.miterLimit_
),
658 blend_( orig
.blend_
),
659 alphaIsShape_( orig
.alphaIsShape_
),
660 strokingAlpha_( orig
.strokingAlpha_
),
661 nonStrokingAlpha_( orig
.nonStrokingAlpha_
)
664 Kernel::GraphicsState::GraphicsState( const Kernel::GraphicsState
& newValues
, const Kernel::GraphicsState
& oldValues
)
665 : strokingColor_( oldValues
.strokingColor_
),
666 nonStrokingColor_( oldValues
.nonStrokingColor_
),
667 width_( oldValues
.width_
),
668 cap_( oldValues
.cap_
),
669 join_( oldValues
.join_
),
670 miterLimit_( oldValues
.miterLimit_
),
671 dash_( oldValues
.dash_
),
672 blend_( oldValues
.blend_
),
673 alphaIsShape_( oldValues
.alphaIsShape_
),
674 strokingAlpha_( oldValues
.strokingAlpha_
),
675 nonStrokingAlpha_( oldValues
.nonStrokingAlpha_
)
677 if( newValues
.strokingColor_
!= NullPtr
< const Lang::Color
>( ) )
679 strokingColor_
= newValues
.strokingColor_
;
681 if( newValues
.nonStrokingColor_
!= NullPtr
< const Lang::Color
>( ) )
683 nonStrokingColor_
= newValues
.nonStrokingColor_
;
685 if( ! IS_NAN( newValues
.width_
) )
687 width_
= newValues
.width_
;
689 if( newValues
.cap_
!= Lang::CapStyle::CAP_UNDEFINED
)
691 cap_
= newValues
.cap_
;
693 if( newValues
.join_
!= Lang::JoinStyle::JOIN_UNDEFINED
)
695 join_
= newValues
.join_
;
697 if( ! IS_NAN( newValues
.miterLimit_
) )
699 miterLimit_
= newValues
.miterLimit_
;
701 if( newValues
.dash_
!= NullPtr
< const Lang::Dash
>( ) )
703 dash_
= newValues
.dash_
;
705 if( newValues
.blend_
!= Lang::BlendMode::BLEND_UNDEFINED
)
707 blend_
= newValues
.blend_
;
709 if( newValues
.strokingAlpha_
!= NullPtr
< const Lang::Alpha
>( ) )
711 strokingAlpha_
= newValues
.strokingAlpha_
;
712 alphaIsShape_
= newValues
.alphaIsShape_
;
714 if( newValues
.nonStrokingAlpha_
!= NullPtr
< const Lang::Alpha
>( ) )
716 nonStrokingAlpha_
= newValues
.nonStrokingAlpha_
;
717 alphaIsShape_
= newValues
.alphaIsShape_
;
721 Kernel::GraphicsState::GraphicsState( bool setDefaults
)
722 : strokingColor_( Lang::THE_BLACK
),
723 nonStrokingColor_( Lang::THE_BLACK
),
725 cap_( Lang::CapStyle::CAP_BUTT
),
726 join_( Lang::JoinStyle::JOIN_MITER
),
728 dash_( Lang::THE_SOLID_DASH
),
729 blend_( Lang::BlendMode::NORMAL
),
730 alphaIsShape_( false ),
731 strokingAlpha_( Lang::THE_OPAQUE
),
732 nonStrokingAlpha_( Lang::THE_OPAQUE
)
736 throw Exceptions::InternalError( strrefdup( "setDefaults must be true in GraphicsState::GraphicsState." ) );
740 Kernel::GraphicsState::~GraphicsState( )
744 Kernel::GraphicsState::print( std::ostream
& os
, const std::string
& indentation
) const
746 if( ! IS_NAN( width_
) )
749 Lang::DYNAMIC_VARIABLE_ID_WIDTH
.show( os
, Ast::Identifier::DYNAMIC_VARIABLE
);
750 os
<< ": " << width_
/ Interaction::displayUnit
<< Interaction::displayUnitName
<< std::endl
;
752 if( strokingColor_
!= NullPtr
< const Lang::Color
>( ) )
755 Lang::DYNAMIC_VARIABLE_ID_STROKING
.show( os
, Ast::Identifier::DYNAMIC_VARIABLE
);
757 strokingColor_
->show( os
);
760 if( nonStrokingColor_
!= NullPtr
< const Lang::Color
>( ) )
763 Lang::DYNAMIC_VARIABLE_ID_NONSTROKING
.show( os
, Ast::Identifier::DYNAMIC_VARIABLE
);
765 nonStrokingColor_
->show( os
);
768 os
<< "(and a bunch of other variables...)" << std::endl
;
772 Kernel::GraphicsState::synchStrokingColor( std::ostream
& os
, const GraphicsState
* ref
, SimplePDF::PDF_Resources
* resources
, bool force
)
774 if( force
|| strokingColor_
!= ref
->strokingColor_
)
776 if( ref
->strokingColor_
== NullPtr
< const Lang::Color
>( ) )
780 strokingColor_
= ref
->strokingColor_
;
781 strokingColor_
->setStroking( os
);
788 Kernel::GraphicsState::synchNonStrokingColor( std::ostream
& os
, const GraphicsState
* ref
, SimplePDF::PDF_Resources
* resources
, bool force
)
790 if( force
|| nonStrokingColor_
!= ref
->nonStrokingColor_
)
792 if( ref
->nonStrokingColor_
== NullPtr
< const Lang::Color
>( ) )
796 nonStrokingColor_
= ref
->nonStrokingColor_
;
797 nonStrokingColor_
->setNonStroking( os
);
804 Kernel::GraphicsState::synchStrokingAlpha( std::ostream
& os
, const GraphicsState
* ref
, SimplePDF::PDF_Resources
* resources
, bool force
)
806 if( force
|| strokingAlpha_
!= ref
->strokingAlpha_
|| alphaIsShape_
!= ref
->strokingAlpha_
->isShape_
)
808 if( ref
->strokingAlpha_
== NullPtr
< const Lang::Alpha
>( ) )
812 strokingAlpha_
= ref
->strokingAlpha_
;
813 alphaIsShape_
= strokingAlpha_
->isShape_
;
815 const SimplePDF::PDF_Version::Version ALPHA_VERSION
= SimplePDF::PDF_Version::PDF_1_4
;
816 if( Kernel::the_PDF_version
.greaterOrEqual( ALPHA_VERSION
) )
818 Lang::Alpha::applyGraphicsState( os
, resources
, *strokingAlpha_
, true );
823 Kernel::the_PDF_version
.message( ALPHA_VERSION
, "The graphics state stroking alpha setting was ignored." );
830 Kernel::GraphicsState::synchNonStrokingAlpha( std::ostream
& os
, const GraphicsState
* ref
, SimplePDF::PDF_Resources
* resources
, bool force
)
832 if( force
|| nonStrokingAlpha_
!= ref
->nonStrokingAlpha_
|| alphaIsShape_
!= ref
->nonStrokingAlpha_
->isShape_
)
834 if( ref
->nonStrokingAlpha_
== NullPtr
< const Lang::Alpha
>( ) )
838 nonStrokingAlpha_
= ref
->nonStrokingAlpha_
;
839 alphaIsShape_
= nonStrokingAlpha_
->isShape_
;
841 const SimplePDF::PDF_Version::Version ALPHA_VERSION
= SimplePDF::PDF_Version::PDF_1_4
;
842 if( Kernel::the_PDF_version
.greaterOrEqual( ALPHA_VERSION
) )
844 Lang::Alpha::applyGraphicsState( os
, resources
, *nonStrokingAlpha_
, false );
849 Kernel::the_PDF_version
.message( ALPHA_VERSION
, "The graphics state non-stroking alpha setting was ignored." );
856 Kernel::GraphicsState::synchWidth( std::ostream
& os
, const GraphicsState
* ref
, SimplePDF::PDF_Resources
* resources
, bool force
)
858 if( force
|| width_
!= ref
->width_
)
860 if( IS_NAN( ref
->width_
) ||
861 ref
->width_
< Concrete::ZERO_LENGTH
)
865 width_
= ref
->width_
;
866 os
<< width_
.offtype
< 1, 0 >( ) << " w " ;
873 Kernel::GraphicsState::synchCap( std::ostream
& os
, const GraphicsState
* ref
, SimplePDF::PDF_Resources
* resources
, bool force
)
875 if( force
|| cap_
!= ref
->cap_
)
877 if( ref
->cap_
!= Lang::CapStyle::CAP_UNDEFINED
&&
878 ref
->cap_
!= Lang::CapStyle::CAP_SAME
)
881 os
<< cap_
<< " J " ;
889 Kernel::GraphicsState::synchJoin( std::ostream
& os
, const GraphicsState
* ref
, SimplePDF::PDF_Resources
* resources
, bool force
)
891 if( force
|| join_
!= ref
->join_
)
893 if( ref
->join_
!= Lang::JoinStyle::JOIN_UNDEFINED
&&
894 ref
->join_
!= Lang::JoinStyle::JOIN_SAME
)
897 os
<< join_
<< " j " ;
905 Kernel::GraphicsState::synchMiterLimit( std::ostream
& os
, const GraphicsState
* ref
, SimplePDF::PDF_Resources
* resources
, bool force
)
907 if( force
|| miterLimit_
!= ref
->miterLimit_
)
909 if( IS_NAN( ref
->miterLimit_
) ||
910 ref
->miterLimit_
< 0 )
914 miterLimit_
= ref
->miterLimit_
;
915 os
<< miterLimit_
<< " M " ;
922 Kernel::GraphicsState::synchDash( std::ostream
& os
, const GraphicsState
* ref
, SimplePDF::PDF_Resources
* resources
, bool force
)
924 if( force
|| dash_
!= ref
->dash_
)
926 if( ref
->dash_
== NullPtr
< const Lang::Dash
>( ) )
931 dash_
->setDash( os
);
938 Kernel::GraphicsState::synchBlend( std::ostream
& os
, const GraphicsState
* ref
, SimplePDF::PDF_Resources
* resources
, bool force
)
940 if( force
|| blend_
!= ref
->blend_
)
942 if( ref
->blend_
== Lang::BlendMode::BLEND_UNDEFINED
)
946 blend_
= ref
->blend_
;
947 const SimplePDF::PDF_Version::Version BLEND_VERSION
= SimplePDF::PDF_Version::PDF_1_4
;
948 if( Kernel::the_PDF_version
.greaterOrEqual( BLEND_VERSION
) )
950 Lang::BlendMode::applyGraphicsState( os
, resources
, blend_
);
955 Kernel::the_PDF_version
.message( BLEND_VERSION
, "The graphics state blend mode setting was ignored." );
963 Kernel::GraphicsState::synchForStroke( std::ostream
& os
, const GraphicsState
* ref
, SimplePDF::PDF_Resources
* resources
, bool force
)
965 bool anyChange
= false;
966 anyChange
= synchStrokingColor( os
, ref
, resources
, force
) || anyChange
;
967 anyChange
= synchStrokingAlpha( os
, ref
, resources
, force
) || anyChange
;
968 anyChange
= synchWidth( os
, ref
, resources
, force
) || anyChange
;
969 anyChange
= synchCap( os
, ref
, resources
, force
) || anyChange
;
970 anyChange
= synchJoin( os
, ref
, resources
, force
) || anyChange
;
971 anyChange
= synchMiterLimit( os
, ref
, resources
, force
) || anyChange
;
972 anyChange
= synchDash( os
, ref
, resources
, force
) || anyChange
;
981 Kernel::GraphicsState::synchForNonStroke( std::ostream
& os
, const GraphicsState
* ref
, SimplePDF::PDF_Resources
* resources
, bool force
)
983 bool anyChange
= false;
984 anyChange
= synchNonStrokingColor( os
, ref
, resources
, force
) || anyChange
;
985 anyChange
= synchNonStrokingAlpha( os
, ref
, resources
, force
) || anyChange
;
994 Kernel::GraphicsState::synchStrokingColorWithNonStrokingColor( std::ostream
& os
, SimplePDF::PDF_Resources
* resources
, Concrete::Length width
)
996 bool anyChange
= false;
998 if( ! IS_NAN( width
) && width_
!= width
)
1001 os
<< width_
.offtype
< 1, 0 >( ) << " w " ;
1005 if( strokingColor_
!= nonStrokingColor_
)
1007 strokingColor_
= nonStrokingColor_
;
1008 strokingColor_
->setStroking( os
);
1019 Lang::Alpha::Alpha( bool isShape
, double a
)
1020 : isShape_( isShape
), a_( a
)
1023 Lang::Alpha::~Alpha( )
1026 RefCountPtr
< const Lang::Class
> Lang::Alpha::TypeID( new Lang::SystemFinalClass( strrefdup( "Alpha" ) ) );
1027 TYPEINFOIMPL( Alpha
);
1030 Lang::Alpha::applyGraphicsState( std::ostream
& os
, SimplePDF::PDF_Resources
* resources
, const Lang::Alpha
& self
, bool isStroking
)
1032 typedef typeof strokingShapeResourcemap MapType
;
1033 MapType
* resourceMap
;
1038 resourceMap
= & strokingShapeResourcemap
;
1042 resourceMap
= & nonStrokingShapeResourcemap
;
1049 resourceMap
= & strokingOpacityResourcemap
;
1053 resourceMap
= & nonStrokingOpacityResourcemap
;
1056 MapType::const_iterator i
= resourceMap
->find( self
.a_
);
1057 if( i
!= resourceMap
->end( ) )
1059 os
<< resources
->nameofGraphicsState( i
->second
) << " gs " ;
1063 RefCountPtr
< SimplePDF::PDF_Dictionary
> dic
;
1064 (*dic
)[ "Type" ] = SimplePDF::newName( "ExtGState" );
1065 RefCountPtr
< SimplePDF::PDF_Object
> indirection
= SimplePDF::indirect( dic
, & Kernel::theIndirectObjectCount
);
1067 resourceMap
->insert( MapType::value_type( self
.a_
, indirection
) );
1070 (*dic
)[ "AIS" ] = SimplePDF::newBoolean( self
.isShape_
);
1073 (*dic
)[ "CA" ] = SimplePDF::newFloat( self
.a_
);
1077 (*dic
)[ "ca" ] = SimplePDF::newFloat( self
.a_
);
1080 // If self.a_ < 0 we just leave the graphics state dictionary empty
1082 os
<< resources
->nameofGraphicsState( indirection
) << " gs " ;
1086 std::map
< double, RefCountPtr
< SimplePDF::PDF_Object
> > Lang::Alpha::strokingShapeResourcemap
;
1087 std::map
< double, RefCountPtr
< SimplePDF::PDF_Object
> > Lang::Alpha::strokingOpacityResourcemap
;
1088 std::map
< double, RefCountPtr
< SimplePDF::PDF_Object
> > Lang::Alpha::nonStrokingShapeResourcemap
;
1089 std::map
< double, RefCountPtr
< SimplePDF::PDF_Object
> > Lang::Alpha::nonStrokingOpacityResourcemap
;
1092 Lang::AlphaBinding::AlphaBinding( const Ast::PlacedIdentifier
* id
, const Ast::DynamicBindingExpression
* bindingExpr
, const RefCountPtr
< const Lang::Alpha
> & alpha
, bool isStroking
)
1093 : bindingExpr_( bindingExpr
), alpha_( alpha
), isStroking_( isStroking
), id_( id
)
1096 Lang::AlphaBinding::~AlphaBinding( )
1100 Lang::AlphaBinding::bind( MapType
& bindings
, Kernel::SystemDynamicVariables
** sysBindings
) const
1102 if( *sysBindings
== 0 ) {
1103 *sysBindings
= new Kernel::SystemDynamicVariables( );
1104 Kernel::GraphicsState
* newState
= new Kernel::GraphicsState( );
1107 newState
->strokingAlpha_
= alpha_
;
1111 newState
->nonStrokingAlpha_
= alpha_
;
1113 newState
->alphaIsShape_
= alpha_
->isShape_
;
1114 (*sysBindings
)->graphicsState_
= RefCountPtr
< const Kernel::GraphicsState
>( newState
);
1118 if( (*sysBindings
)->graphicsState_
== NullPtr
< const Kernel::GraphicsState
>( ) )
1120 Kernel::GraphicsState
* newState
= new Kernel::GraphicsState( );
1123 newState
->strokingAlpha_
= alpha_
;
1127 newState
->nonStrokingAlpha_
= alpha_
;
1129 newState
->alphaIsShape_
= alpha_
->isShape_
;
1130 (*sysBindings
)->graphicsState_
= RefCountPtr
< const Kernel::GraphicsState
>( newState
);
1134 Kernel::GraphicsState
* newState
= new Kernel::GraphicsState( *((*sysBindings
)->graphicsState_
) );
1138 if( newState
->strokingAlpha_
!= NullPtr
< const Lang::Alpha
>( ) )
1140 throw Exceptions::MultipleDynamicBind( id_
, bindingExpr_
->idLoc( ), Ast::THE_UNKNOWN_LOCATION
);
1142 newState
->strokingAlpha_
= alpha_
;
1146 if( newState
->nonStrokingAlpha_
!= NullPtr
< const Lang::Alpha
>( ) )
1148 throw Exceptions::MultipleDynamicBind( id_
, bindingExpr_
->idLoc( ), Ast::THE_UNKNOWN_LOCATION
);
1150 newState
->nonStrokingAlpha_
= alpha_
;
1152 newState
->alphaIsShape_
= alpha_
->isShape_
;
1153 (*sysBindings
)->graphicsState_
= RefCountPtr
< const Kernel::GraphicsState
>( newState
);
1157 Lang::AlphaBinding::show( std::ostream
& os
) const
1159 os
<< Interaction::DYNAMIC_VARIABLE_PREFIX
<< id_
<< ":" ;
1164 Lang::AlphaBinding::gcMark( Kernel::GCMarkedSet
& marked
)
1166 const_cast< Lang::Alpha
* >( alpha_
.getPtr( ) )->gcMark( marked
);
1171 Kernel::AlphaDynamicVariableProperties::AlphaDynamicVariableProperties( const Ast::PlacedIdentifier
* id
, bool isStroking
)
1172 : Kernel::DynamicVariableProperties( id
), isStroking_( isStroking
)
1175 Kernel::AlphaDynamicVariableProperties::~AlphaDynamicVariableProperties( )
1178 Kernel::VariableHandle
1179 Kernel::AlphaDynamicVariableProperties::fetch( const Kernel::PassedDyn
& dyn
) const
1181 RefCountPtr
< const Kernel::GraphicsState
> graphicsState
= dyn
->getGraphicsState( );
1184 return Kernel::VariableHandle( new Kernel::Variable( graphicsState
->strokingAlpha_
) );
1186 return Kernel::VariableHandle( new Kernel::Variable( graphicsState
->nonStrokingAlpha_
) );
1190 Kernel::AlphaDynamicVariableProperties::makeBinding( Kernel::VariableHandle val
, const Ast::DynamicBindingExpression
* bindingExpr
, Kernel::EvalState
* evalState
) const
1194 RefCountPtr
< const Lang::Alpha
> alpha
= val
->tryVal
< const Lang::Alpha
>( );
1195 Kernel::ContRef cont
= evalState
->cont_
;
1196 cont
->takeValue( Kernel::ValueRef( new Lang::AlphaBinding( id_
, bindingExpr
, alpha
, isStroking_
) ),
1200 catch( const NonLocalExit::NotThisType
& ball
)
1207 RefCountPtr
< const Lang::Void
> dummy
= val
->tryVal
< const Lang::Void
>( );
1208 Kernel::ContRef cont
= evalState
->cont_
;
1209 cont
->takeValue( Kernel::ValueRef( new Lang::AlphaBinding( id_
, bindingExpr
, RefCountPtr
< const Lang::Alpha
>( new Lang::Alpha( true, -1 ) ), isStroking_
) ),
1213 catch( const NonLocalExit::NotThisType
& ball
)
1218 throw Exceptions::TypeMismatch( bindingExpr
->exprLoc( ), val
->getUntyped( )->getTypeName( ), Helpers::typeSetString( Lang::Alpha::staticTypeName( ), Lang::Void::staticTypeName( ) ) );
1222 Lang::SoftMask::SoftMask( )
1223 : graphicsStateResource_( NullPtr
< SimplePDF::PDF_Object
>( ) )
1225 static size_t callCount
= 0;
1229 throw Exceptions::InternalError( strrefdup( "The None soft mask should be generated at most twice!" ) );
1232 RefCountPtr
< SimplePDF::PDF_Dictionary
> dic
;
1233 graphicsStateResource_
= SimplePDF::indirect( dic
, & Kernel::theIndirectObjectCount
);
1235 (*dic
)[ "Type" ] = SimplePDF::newName( "ExtGState" );
1236 (*dic
)[ "SMask" ] = SimplePDF::newName( "None" );
1239 Lang::SoftMask::SoftMask( SubType subType
, const RefCountPtr
< const Lang::TransparencyGroup
> & tpGroup
, const RefCountPtr
< const Lang::Color
> & background
, const RefCountPtr
< const Lang::PDF_Function
> & transfer
)
1240 : graphicsStateResource_( NullPtr
< SimplePDF::PDF_Object
>( ) )
1242 RefCountPtr
< SimplePDF::PDF_Dictionary
> gsDic
;
1243 graphicsStateResource_
= SimplePDF::indirect( gsDic
, & Kernel::theIndirectObjectCount
);
1245 RefCountPtr
< SimplePDF::PDF_Dictionary
> smDic
;
1247 (*gsDic
)[ "Type" ] = SimplePDF::newName( "ExtGState" );
1248 (*gsDic
)[ "SMask" ] = smDic
;
1249 (*smDic
)[ "G" ] = tpGroup
->getPDF_Object( );
1255 (*smDic
)[ "S" ] = SimplePDF::newName( "Alpha" );
1256 if( background
!= NullPtr
< const Lang::Color
>( ) )
1258 throw Exceptions::InternalError( strrefdup( "Attempt to create Alpha soft mask with BC." ) );
1264 (*smDic
)[ "S" ] = SimplePDF::newName( "Luminosity" );
1265 if( background
!= NullPtr
< const Lang::Color
>( ) )
1267 (*smDic
)[ "BC" ] = background
->componentVector( );
1268 if( ! tpGroup
->colorSpace( )->containsColor( background
.getPtr( ) ) )
1270 throw Exceptions::OutOfRange( "The background color is not in the transparency groups color space." );
1276 throw Exceptions::InternalError( strrefdup( "SoftMask::SoftMask: Enum switch out of range." ) );
1278 if( transfer
!= NullPtr
< const Lang::PDF_Function
>( ) )
1280 if( ! transfer
->matchesDimensions( 1, 1 ) )
1282 throw Exceptions::InternalError( strrefdup( "SoftMask::SoftMask: The transfer function arity should be correct at this point." ) );
1284 (*smDic
)[ "TR" ] = transfer
->getFunction( );
1288 Lang::SoftMask::~SoftMask( )
1291 RefCountPtr
< const Lang::Class
> Lang::SoftMask::TypeID( new Lang::SystemFinalClass( strrefdup( "SoftMask" ) ) );
1292 TYPEINFOIMPL( SoftMask
);
1295 Lang::Dash::Iterator::Iterator( RefCountPtr
< std::list
< Concrete::Length
> > _pattern
, double _scale
, std::list
< Concrete::Length
>::const_iterator _i
, bool _on
, Concrete::Length _length
)
1296 : mem_( _pattern
), begin_( _pattern
->begin( ) ), end_( _pattern
->end( ) ), scale_( _scale
), i_( _i
), on_( _on
), length_( _scale
* _length
)
1299 Lang::Dash::Iterator
&
1300 Lang::Dash::Iterator::operator ++ ( )
1312 length_
= scale_
* (*i_
);
1317 Lang::Dash::Iterator::isOn( ) const
1323 Lang::Dash::Iterator::getLength( ) const
1330 : pattern_( new list
< Concrete::Length
>( ) ), phase_( 0 ), scale_( 1 )
1333 Lang::Dash::Dash( RefCountPtr
< std::list
< Concrete::Length
> > _pattern
, Concrete::Length _phase
, double _scale
)
1334 : pattern_( _pattern
), phase_( _phase
), scale_( _scale
), myLength_( 0 )
1336 for( list
< Concrete::Length
>::const_iterator i
= pattern_
->begin( ); i
!= pattern_
->end( ); ++i
)
1342 Lang::Dash::Dash( RefCountPtr
< std::list
< Concrete::Length
> > _pattern
, Concrete::Length _phase
, double _scale
, Concrete::Length _length
)
1343 : pattern_( _pattern
), phase_( _phase
), scale_( _scale
), myLength_( _length
)
1346 DISPATCHIMPL( Dash
);
1348 Lang::Dash::~Dash( )
1351 RefCountPtr
< const Lang::Class
> Lang::Dash::TypeID( new Lang::SystemFinalClass( strrefdup( "Dash" ) ) );
1352 TYPEINFOIMPL( Dash
);
1356 Lang::Dash::setDash( ostream
& os
) const
1358 // Negative scale means that the dash shall not be altered
1365 for( list
< Concrete::Length
>::const_iterator i
= pattern_
->begin( ); i
!= pattern_
->end( ); ++i
)
1367 os
<< Concrete::Length::offtype( *i
) * scale_
<< " " ;
1369 os
<< "] " << Concrete::Length::offtype( phase_
) * scale_
<< " d " ;
1372 RefCountPtr
< SimplePDF::PDF_Vector
>
1373 Lang::Dash::getDashArray( ) const
1377 throw Exceptions::MiscellaneousRequirement( "The same-as-before dash cannot be represented in PDF." );
1380 RefCountPtr
< SimplePDF::PDF_Vector
> res
= RefCountPtr
< SimplePDF::PDF_Vector
>( new SimplePDF::PDF_Vector
);
1381 for( list
< Concrete::Length
>::const_iterator i
= pattern_
->begin( ); i
!= pattern_
->end( ); ++i
)
1383 res
->vec
.push_back( SimplePDF::newFloat( Concrete::Length::offtype( *i
) * scale_
) );
1389 RefCountPtr
< const Lang::Dash
>
1390 Lang::Dash::scaled( double factor
) const
1392 return RefCountPtr
< const Lang::Dash
>( new Lang::Dash( pattern_
, phase_
, scale_
* factor
, myLength_
) );
1395 RefCountPtr
< const Lang::Dash
>
1396 Lang::Dash::shifted( Concrete::Length dist
) const
1398 return RefCountPtr
< const Lang::Dash
>( new Lang::Dash( pattern_
, phase_
+ dist
/ scale_
, scale_
, myLength_
) );
1402 Lang::Dash::length( ) const
1404 return myLength_
* scale_
;
1408 Lang::Dash::isSolid( ) const
1410 return pattern_
->empty( );
1413 Lang::Dash::Iterator
1414 Lang::Dash::begin( ) const
1416 Concrete::Length tmpPhase
= modPhysical( phase_
, myLength_
);
1419 tmpPhase
+= myLength_
;
1421 std::list
< Concrete::Length
>::const_iterator i
= pattern_
->begin( );
1423 while( tmpPhase
>= *i
)
1429 return Lang::Dash::Iterator( pattern_
, scale_
, i
, on
, *i
- tmpPhase
);
1432 Lang::Color::Color( )
1435 DISPATCHIMPL( Color
);
1437 Lang::Color::~Color( )
1440 RefCountPtr
< const Lang::Class
> Lang::Color::TypeID
= NullPtr
< const Lang::Class
>( ); /* The value is set in main */
1442 RefCountPtr
< const char >
1443 Lang::Color::staticTypeName( )
1445 return TypeID
->getPrettyName( );
1449 Lang::Gray::Gray( const Concrete::Gray
& components
)
1450 : components_( components
)
1453 DISPATCHIMPL( Gray
);
1455 Lang::Gray::~Gray( )
1458 RefCountPtr
< const Lang::Class
> Lang::Gray::TypeID( new Lang::SystemFinalClass( strrefdup( "Gray" ) ) );
1459 TYPEINFOIMPL( Gray
);
1462 Lang::Gray::show( std::ostream
& os
) const
1464 os
<< "[gray " << components_
.gr_
<< "]" ;
1468 Lang::Gray::setStroking( ostream
& os
) const
1470 components_
.setStroking( os
);
1474 Lang::Gray::setNonStroking( ostream
& os
) const
1476 components_
.setNonStroking( os
);
1479 RefCountPtr
< SimplePDF::PDF_Vector
>
1480 Lang::Gray::componentVector( ) const
1482 return components_
.componentVector( );
1486 Lang::RGB::RGB( const Concrete::RGB
& components
)
1487 : components_( components
)
1490 DISPATCHIMPL( RGB
);
1495 RefCountPtr
< const Lang::Class
> Lang::RGB::TypeID( new Lang::SystemFinalClass( strrefdup( "RGB" ) ) );
1496 TYPEINFOIMPL( RGB
);
1499 Lang::RGB::show( std::ostream
& os
) const
1501 os
<< "[rgb " << components_
.r_
<< " " << components_
.g_
<< " " << components_
.b_
<< "]" ;
1505 Lang::RGB::setStroking( ostream
& os
) const
1507 components_
.setStroking( os
);
1511 Lang::RGB::setNonStroking( ostream
& os
) const
1513 components_
.setNonStroking( os
);
1516 RefCountPtr
< SimplePDF::PDF_Vector
>
1517 Lang::RGB::componentVector( ) const
1519 return components_
.componentVector( );
1523 Lang::CMYK::CMYK( const Concrete::CMYK
& components
)
1524 : components_( components
)
1527 DISPATCHIMPL( CMYK
);
1529 Lang::CMYK::~CMYK( )
1532 RefCountPtr
< const Lang::Class
> Lang::CMYK::TypeID( new Lang::SystemFinalClass( strrefdup( "CMYK" ) ) );
1533 TYPEINFOIMPL( CMYK
);
1536 Lang::CMYK::show( std::ostream
& os
) const
1538 os
<< "[cmyk " << components_
.c_
<< " " << components_
.m_
<< " " << components_
.y_
<< " " << components_
.k_
<< "]" ;
1542 Lang::CMYK::setStroking( ostream
& os
) const
1544 components_
.setStroking( os
);
1548 Lang::CMYK::setNonStroking( ostream
& os
) const
1550 components_
.setNonStroking( os
);
1553 RefCountPtr
< SimplePDF::PDF_Vector
>
1554 Lang::CMYK::componentVector( ) const
1556 return components_
.componentVector( );
1560 Lang::StrokingBinding::StrokingBinding( const Ast::PlacedIdentifier
* id
, const Ast::DynamicBindingExpression
* bindingExpr
, RefCountPtr
< const Lang::Color
> color
)
1561 : bindingExpr_( bindingExpr
), color_( color
), id_( id
)
1564 Lang::StrokingBinding::~StrokingBinding( )
1568 Lang::StrokingBinding::bind( MapType
& bindings
, Kernel::SystemDynamicVariables
** sysBindings
) const
1570 if( *sysBindings
== 0 )
1572 *sysBindings
= new Kernel::SystemDynamicVariables( );
1573 Kernel::GraphicsState
* newState
= new Kernel::GraphicsState( );
1574 newState
->strokingColor_
= color_
;
1575 (*sysBindings
)->graphicsState_
= RefCountPtr
< const Kernel::GraphicsState
>( newState
);
1579 if( (*sysBindings
)->graphicsState_
== NullPtr
< const Kernel::GraphicsState
>( ) )
1581 Kernel::GraphicsState
* newState
= new Kernel::GraphicsState( );
1582 newState
->strokingColor_
= color_
;
1583 (*sysBindings
)->graphicsState_
= RefCountPtr
< const Kernel::GraphicsState
>( newState
);
1587 Kernel::GraphicsState
* newState
= new Kernel::GraphicsState( *((*sysBindings
)->graphicsState_
) );
1589 if( newState
->strokingColor_
!= NullPtr
< const Lang::Color
>( ) )
1591 throw Exceptions::MultipleDynamicBind( id_
, bindingExpr_
->idLoc( ), Ast::THE_UNKNOWN_LOCATION
);
1594 newState
->strokingColor_
= color_
;
1595 (*sysBindings
)->graphicsState_
= RefCountPtr
< const Kernel::GraphicsState
>( newState
);
1599 Lang::StrokingBinding::show( std::ostream
& os
) const
1601 os
<< Interaction::DYNAMIC_VARIABLE_PREFIX
<< id_
<< ":" ;
1606 Lang::StrokingBinding::gcMark( Kernel::GCMarkedSet
& marked
)
1608 const_cast< Lang::Color
* >( color_
.getPtr( ) )->gcMark( marked
);
1613 Kernel::StrokingDynamicVariableProperties::StrokingDynamicVariableProperties( const Ast::PlacedIdentifier
* id
)
1614 : Kernel::DynamicVariableProperties( id
)
1617 Kernel::StrokingDynamicVariableProperties::~StrokingDynamicVariableProperties( )
1620 Kernel::VariableHandle
1621 Kernel::StrokingDynamicVariableProperties::fetch( const Kernel::PassedDyn
& dyn
) const
1623 RefCountPtr
< const Kernel::GraphicsState
> graphicsState
= dyn
->getGraphicsState( );
1624 return Kernel::VariableHandle( new Kernel::Variable( graphicsState
->strokingColor_
) );
1628 Kernel::StrokingDynamicVariableProperties::makeBinding( Kernel::VariableHandle val
, const Ast::DynamicBindingExpression
* bindingExpr
, Kernel::EvalState
* evalState
) const
1632 RefCountPtr
< const Lang::Color
> color
= val
->tryVal
< const Lang::Color
>( );
1633 Kernel::ContRef cont
= evalState
->cont_
;
1634 cont
->takeValue( Kernel::ValueRef( new Lang::StrokingBinding( id_
, bindingExpr
, color
) ),
1638 catch( const NonLocalExit::NotThisType
& ball
)
1645 RefCountPtr
< const Lang::Void
> dummy
= val
->tryVal
< const Lang::Void
>( );
1646 Kernel::ContRef cont
= evalState
->cont_
;
1647 cont
->takeValue( Kernel::ValueRef( new Lang::StrokingBinding( id_
, bindingExpr
, RefCountPtr
< const Lang::Color
>( new Lang::Gray( -1 ) ) ) ),
1651 catch( const NonLocalExit::NotThisType
& ball
)
1656 throw Exceptions::TypeMismatch( bindingExpr
->exprLoc( ), val
->getUntyped( )->getTypeName( ), Helpers::typeSetString( Lang::Color::staticTypeName( ), Lang::Void::staticTypeName( ) ) );
1660 Lang::NonStrokingBinding::NonStrokingBinding( const Ast::PlacedIdentifier
* id
, const Ast::DynamicBindingExpression
* bindingExpr
, RefCountPtr
< const Lang::Color
> color
)
1661 : bindingExpr_( bindingExpr
), color_( color
), id_( id
)
1664 Lang::NonStrokingBinding::~NonStrokingBinding( )
1668 Lang::NonStrokingBinding::bind( MapType
& bindings
, Kernel::SystemDynamicVariables
** sysBindings
) const
1670 if( *sysBindings
== 0 )
1672 *sysBindings
= new Kernel::SystemDynamicVariables( );
1673 Kernel::GraphicsState
* newState
= new Kernel::GraphicsState( );
1674 newState
->nonStrokingColor_
= color_
;
1675 (*sysBindings
)->graphicsState_
= RefCountPtr
< const Kernel::GraphicsState
>( newState
);
1679 if( (*sysBindings
)->graphicsState_
== NullPtr
< const Kernel::GraphicsState
>( ) )
1681 Kernel::GraphicsState
* newState
= new Kernel::GraphicsState( );
1682 newState
->nonStrokingColor_
= color_
;
1683 (*sysBindings
)->graphicsState_
= RefCountPtr
< const Kernel::GraphicsState
>( newState
);
1687 Kernel::GraphicsState
* newState
= new Kernel::GraphicsState( *((*sysBindings
)->graphicsState_
) );
1689 if( newState
->nonStrokingColor_
!= NullPtr
< const Lang::Color
>( ) )
1691 throw Exceptions::MultipleDynamicBind( id_
, bindingExpr_
->idLoc( ), Ast::THE_UNKNOWN_LOCATION
);
1694 newState
->nonStrokingColor_
= color_
;
1695 (*sysBindings
)->graphicsState_
= RefCountPtr
< const Kernel::GraphicsState
>( newState
);
1699 Lang::NonStrokingBinding::show( std::ostream
& os
) const
1701 os
<< Interaction::DYNAMIC_VARIABLE_PREFIX
<< id_
<< ":" ;
1706 Lang::NonStrokingBinding::gcMark( Kernel::GCMarkedSet
& marked
)
1708 const_cast< Lang::Color
* >( color_
.getPtr( ) )->gcMark( marked
);
1713 Kernel::NonStrokingDynamicVariableProperties::NonStrokingDynamicVariableProperties( const Ast::PlacedIdentifier
* id
)
1714 : Kernel::DynamicVariableProperties( id
)
1717 Kernel::NonStrokingDynamicVariableProperties::~NonStrokingDynamicVariableProperties( )
1720 Kernel::VariableHandle
1721 Kernel::NonStrokingDynamicVariableProperties::fetch( const Kernel::PassedDyn
& dyn
) const
1723 RefCountPtr
< const Kernel::GraphicsState
> graphicsState
= dyn
->getGraphicsState( );
1724 return Kernel::VariableHandle( new Kernel::Variable( graphicsState
->nonStrokingColor_
) );
1728 Kernel::NonStrokingDynamicVariableProperties::makeBinding( Kernel::VariableHandle val
, const Ast::DynamicBindingExpression
* bindingExpr
, Kernel::EvalState
* evalState
) const
1732 RefCountPtr
< const Lang::Color
> color
= val
->tryVal
< const Lang::Color
>( );
1733 Kernel::ContRef cont
= evalState
->cont_
;
1734 cont
->takeValue( Kernel::ValueRef( new Lang::NonStrokingBinding( id_
, bindingExpr
, color
) ),
1738 catch( const NonLocalExit::NotThisType
& ball
)
1745 RefCountPtr
< const Lang::Void
> dummy
= val
->tryVal
< const Lang::Void
>( );
1746 Kernel::ContRef cont
= evalState
->cont_
;
1747 cont
->takeValue( Kernel::ValueRef( new Lang::NonStrokingBinding( id_
, bindingExpr
, RefCountPtr
< const Lang::Color
>( new Lang::Gray( -1 ) ) ) ),
1751 catch( const NonLocalExit::NotThisType
& ball
)
1756 throw Exceptions::TypeMismatch( bindingExpr
->exprLoc( ), val
->getUntyped( )->getTypeName( ), Helpers::typeSetString( Lang::Color::staticTypeName( ), Lang::Void::staticTypeName( ) ) );
1760 Lang::DashBinding::DashBinding( const Ast::PlacedIdentifier
* id
, const Ast::DynamicBindingExpression
* bindingExpr
, RefCountPtr
< const Lang::Dash
> dash
)
1761 : bindingExpr_( bindingExpr
), dash_( dash
), id_( id
)
1764 Lang::DashBinding::~DashBinding( )
1768 Lang::DashBinding::bind( MapType
& bindings
, Kernel::SystemDynamicVariables
** sysBindings
) const
1770 if( *sysBindings
== 0 )
1772 *sysBindings
= new Kernel::SystemDynamicVariables( );
1773 Kernel::GraphicsState
* newState
= new Kernel::GraphicsState( );
1774 newState
->dash_
= dash_
;
1775 (*sysBindings
)->graphicsState_
= RefCountPtr
< const Kernel::GraphicsState
>( newState
);
1779 if( (*sysBindings
)->graphicsState_
== NullPtr
< const Kernel::GraphicsState
>( ) )
1781 Kernel::GraphicsState
* newState
= new Kernel::GraphicsState( );
1782 newState
->dash_
= dash_
;
1783 (*sysBindings
)->graphicsState_
= RefCountPtr
< const Kernel::GraphicsState
>( newState
);
1787 Kernel::GraphicsState
* newState
= new Kernel::GraphicsState( *((*sysBindings
)->graphicsState_
) );
1789 if( newState
->dash_
!= NullPtr
< const Lang::Dash
>( ) )
1791 throw Exceptions::MultipleDynamicBind( id_
, bindingExpr_
->idLoc( ), Ast::THE_UNKNOWN_LOCATION
);
1794 newState
->dash_
= dash_
;
1795 (*sysBindings
)->graphicsState_
= RefCountPtr
< const Kernel::GraphicsState
>( newState
);
1799 Lang::DashBinding::show( std::ostream
& os
) const
1801 os
<< Interaction::DYNAMIC_VARIABLE_PREFIX
<< id_
<< ":" ;
1806 Lang::DashBinding::gcMark( Kernel::GCMarkedSet
& marked
)
1808 const_cast< Lang::Dash
* >( dash_
.getPtr( ) )->gcMark( marked
);
1813 Kernel::DashDynamicVariableProperties::DashDynamicVariableProperties( const Ast::PlacedIdentifier
* id
)
1814 : Kernel::DynamicVariableProperties( id
)
1817 Kernel::DashDynamicVariableProperties::~DashDynamicVariableProperties( )
1820 Kernel::VariableHandle
1821 Kernel::DashDynamicVariableProperties::fetch( const Kernel::PassedDyn
& dyn
) const
1823 RefCountPtr
< const Kernel::GraphicsState
> graphicsState
= dyn
->getGraphicsState( );
1824 return Kernel::VariableHandle( new Kernel::Variable( graphicsState
->dash_
) );
1828 Kernel::DashDynamicVariableProperties::makeBinding( Kernel::VariableHandle val
, const Ast::DynamicBindingExpression
* bindingExpr
, Kernel::EvalState
* evalState
) const
1832 RefCountPtr
< const Lang::Dash
> dash
= val
->tryVal
< const Lang::Dash
>( );
1833 Kernel::ContRef cont
= evalState
->cont_
;
1834 cont
->takeValue( Kernel::ValueRef( new Lang::DashBinding( id_
, bindingExpr
, dash
) ),
1838 catch( const NonLocalExit::NotThisType
& ball
)
1845 RefCountPtr
< const Lang::Void
> dummy
= val
->tryVal
< const Lang::Void
>( );
1846 Kernel::ContRef cont
= evalState
->cont_
;
1847 cont
->takeValue( Kernel::ValueRef( new Lang::DashBinding( id_
, bindingExpr
, RefCountPtr
< const Lang::Dash
>( new Lang::Dash( RefCountPtr
< std::list
< Concrete::Length
> >( new std::list
< Concrete::Length
>( ) ), 0, -1 ) ) ) ),
1851 catch( const NonLocalExit::NotThisType
& ball
)
1856 throw Exceptions::TypeMismatch( bindingExpr
->exprLoc( ), val
->getUntyped( )->getTypeName( ), Helpers::typeSetString( Lang::Dash::staticTypeName( ), Lang::Void::staticTypeName( ) ) );
1861 Lang::CapStyleBinding::CapStyleBinding( const Ast::PlacedIdentifier
* id
, const Ast::DynamicBindingExpression
* bindingExpr
, const Lang::CapStyle::ValueType
& cap
)
1862 : bindingExpr_( bindingExpr
), cap_( cap
), id_( id
)
1865 Lang::CapStyleBinding::~CapStyleBinding( )
1869 Lang::CapStyleBinding::bind( MapType
& bindings
, Kernel::SystemDynamicVariables
** sysBindings
) const
1871 if( *sysBindings
== 0 ) {
1872 *sysBindings
= new Kernel::SystemDynamicVariables( );
1873 Kernel::GraphicsState
* newState
= new Kernel::GraphicsState( );
1874 newState
->cap_
= cap_
;
1875 (*sysBindings
)->graphicsState_
= RefCountPtr
< const Kernel::GraphicsState
>( newState
);
1879 if( (*sysBindings
)->graphicsState_
== NullPtr
< const Kernel::GraphicsState
>( ) )
1881 Kernel::GraphicsState
* newState
= new Kernel::GraphicsState( );
1882 newState
->cap_
= cap_
;
1883 (*sysBindings
)->graphicsState_
= RefCountPtr
< const Kernel::GraphicsState
>( newState
);
1887 Kernel::GraphicsState
* newState
= new Kernel::GraphicsState( *((*sysBindings
)->graphicsState_
) );
1889 if( newState
->cap_
!= Lang::CapStyle::CAP_UNDEFINED
)
1891 throw Exceptions::MultipleDynamicBind( id_
, bindingExpr_
->idLoc( ), Ast::THE_UNKNOWN_LOCATION
);
1894 newState
->cap_
= cap_
;
1895 (*sysBindings
)->graphicsState_
= RefCountPtr
< const Kernel::GraphicsState
>( newState
);
1899 Lang::CapStyleBinding::show( std::ostream
& os
) const
1901 os
<< Interaction::DYNAMIC_VARIABLE_PREFIX
<< id_
<< ":"
1902 << "<internal-enum>" ;
1906 Lang::CapStyleBinding::gcMark( Kernel::GCMarkedSet
& marked
)
1911 Kernel::CapStyleDynamicVariableProperties::CapStyleDynamicVariableProperties( const Ast::PlacedIdentifier
* id
)
1912 : Kernel::DynamicVariableProperties( id
)
1915 Kernel::CapStyleDynamicVariableProperties::~CapStyleDynamicVariableProperties( )
1918 Kernel::VariableHandle
1919 Kernel::CapStyleDynamicVariableProperties::fetch( const Kernel::PassedDyn
& dyn
) const
1921 RefCountPtr
< const Kernel::GraphicsState
> graphicsState
= dyn
->getGraphicsState( );
1922 return Helpers::newValHandle( new Lang::CapStyle( graphicsState
->cap_
) );
1926 Kernel::CapStyleDynamicVariableProperties::makeBinding( Kernel::VariableHandle val
, const Ast::DynamicBindingExpression
* bindingExpr
, Kernel::EvalState
* evalState
) const
1930 RefCountPtr
< const Lang::CapStyle
> cap
= val
->tryVal
< const Lang::CapStyle
>( );
1931 Kernel::ContRef cont
= evalState
->cont_
;
1932 cont
->takeValue( Kernel::ValueRef( new Lang::CapStyleBinding( id_
, bindingExpr
, cap
->cap_
) ),
1936 catch( const NonLocalExit::NotThisType
& ball
)
1943 RefCountPtr
< const Lang::Void
> dummy
= val
->tryVal
< const Lang::Void
>( );
1944 Kernel::ContRef cont
= evalState
->cont_
;
1945 cont
->takeValue( Kernel::ValueRef( new Lang::CapStyleBinding( id_
, bindingExpr
, Lang::CapStyle::CAP_SAME
) ),
1949 catch( const NonLocalExit::NotThisType
& ball
)
1954 throw Exceptions::TypeMismatch( bindingExpr
->exprLoc( ), val
->getUntyped( )->getTypeName( ), Helpers::typeSetString( Lang::CapStyle::staticTypeName( ), Lang::Void::staticTypeName( ) ) );
1958 Lang::JoinStyleBinding::JoinStyleBinding( const Ast::PlacedIdentifier
* id
, const Ast::DynamicBindingExpression
* bindingExpr
, const Lang::JoinStyle::ValueType
& join
)
1959 : bindingExpr_( bindingExpr
), join_( join
), id_( id
)
1962 Lang::JoinStyleBinding::~JoinStyleBinding( )
1966 Lang::JoinStyleBinding::bind( MapType
& bindings
, Kernel::SystemDynamicVariables
** sysBindings
) const
1968 if( *sysBindings
== 0 ) {
1969 *sysBindings
= new Kernel::SystemDynamicVariables( );
1970 Kernel::GraphicsState
* newState
= new Kernel::GraphicsState( );
1971 newState
->join_
= join_
;
1972 (*sysBindings
)->graphicsState_
= RefCountPtr
< const Kernel::GraphicsState
>( newState
);
1976 if( (*sysBindings
)->graphicsState_
== NullPtr
< const Kernel::GraphicsState
>( ) )
1978 Kernel::GraphicsState
* newState
= new Kernel::GraphicsState( );
1979 newState
->join_
= join_
;
1980 (*sysBindings
)->graphicsState_
= RefCountPtr
< const Kernel::GraphicsState
>( newState
);
1984 Kernel::GraphicsState
* newState
= new Kernel::GraphicsState( *((*sysBindings
)->graphicsState_
) );
1986 if( newState
->join_
!= Lang::JoinStyle::JOIN_UNDEFINED
)
1988 throw Exceptions::MultipleDynamicBind( id_
, bindingExpr_
->idLoc( ), Ast::THE_UNKNOWN_LOCATION
);
1991 newState
->join_
= join_
;
1992 (*sysBindings
)->graphicsState_
= RefCountPtr
< const Kernel::GraphicsState
>( newState
);
1996 Lang::JoinStyleBinding::show( std::ostream
& os
) const
1998 os
<< Interaction::DYNAMIC_VARIABLE_PREFIX
<< id_
<< ":"
1999 << "<internal-enum>" ;
2003 Lang::JoinStyleBinding::gcMark( Kernel::GCMarkedSet
& marked
)
2008 Kernel::JoinStyleDynamicVariableProperties::JoinStyleDynamicVariableProperties( const Ast::PlacedIdentifier
* id
)
2009 : Kernel::DynamicVariableProperties( id
)
2012 Kernel::JoinStyleDynamicVariableProperties::~JoinStyleDynamicVariableProperties( )
2015 Kernel::VariableHandle
2016 Kernel::JoinStyleDynamicVariableProperties::fetch( const Kernel::PassedDyn
& dyn
) const
2018 RefCountPtr
< const Kernel::GraphicsState
> graphicsState
= dyn
->getGraphicsState( );
2019 return Helpers::newValHandle( new Lang::JoinStyle( graphicsState
->join_
) );
2023 Kernel::JoinStyleDynamicVariableProperties::makeBinding( Kernel::VariableHandle val
, const Ast::DynamicBindingExpression
* bindingExpr
, Kernel::EvalState
* evalState
) const
2027 RefCountPtr
< const Lang::JoinStyle
> join
= val
->tryVal
< const Lang::JoinStyle
>( );
2028 Kernel::ContRef cont
= evalState
->cont_
;
2029 cont
->takeValue( Kernel::ValueRef( new Lang::JoinStyleBinding( id_
, bindingExpr
, join
->join_
) ),
2033 catch( const NonLocalExit::NotThisType
& ball
)
2040 RefCountPtr
< const Lang::Void
> dummy
= val
->tryVal
< const Lang::Void
>( );
2041 Kernel::ContRef cont
= evalState
->cont_
;
2042 cont
->takeValue( Kernel::ValueRef( new Lang::JoinStyleBinding( id_
, bindingExpr
, Lang::JoinStyle::JOIN_SAME
) ),
2046 catch( const NonLocalExit::NotThisType
& ball
)
2051 throw Exceptions::TypeMismatch( bindingExpr
->exprLoc( ), val
->getUntyped( )->getTypeName( ), Helpers::typeSetString( Lang::JoinStyle::staticTypeName( ), Lang::Void::staticTypeName( ) ) );
2055 Lang::BlendModeBinding::BlendModeBinding( const Ast::PlacedIdentifier
* id
, const Ast::DynamicBindingExpression
* bindingExpr
, const Lang::BlendMode::ValueType
& blend
)
2056 : bindingExpr_( bindingExpr
), blend_( blend
), id_( id
)
2059 Lang::BlendModeBinding::~BlendModeBinding( )
2063 Lang::BlendModeBinding::bind( MapType
& bindings
, Kernel::SystemDynamicVariables
** sysBindings
) const
2065 if( *sysBindings
== 0 ) {
2066 *sysBindings
= new Kernel::SystemDynamicVariables( );
2067 Kernel::GraphicsState
* newState
= new Kernel::GraphicsState( );
2068 newState
->blend_
= blend_
;
2069 (*sysBindings
)->graphicsState_
= RefCountPtr
< const Kernel::GraphicsState
>( newState
);
2073 if( (*sysBindings
)->graphicsState_
== NullPtr
< const Kernel::GraphicsState
>( ) )
2075 Kernel::GraphicsState
* newState
= new Kernel::GraphicsState( );
2076 newState
->blend_
= blend_
;
2077 (*sysBindings
)->graphicsState_
= RefCountPtr
< const Kernel::GraphicsState
>( newState
);
2081 Kernel::GraphicsState
* newState
= new Kernel::GraphicsState( *((*sysBindings
)->graphicsState_
) );
2083 if( newState
->blend_
!= Lang::BlendMode::BLEND_UNDEFINED
)
2085 throw Exceptions::MultipleDynamicBind( id_
, bindingExpr_
->idLoc( ), Ast::THE_UNKNOWN_LOCATION
);
2088 newState
->blend_
= blend_
;
2089 (*sysBindings
)->graphicsState_
= RefCountPtr
< const Kernel::GraphicsState
>( newState
);
2093 Lang::BlendModeBinding::show( std::ostream
& os
) const
2095 os
<< Interaction::DYNAMIC_VARIABLE_PREFIX
<< id_
<< ":"
2096 << "<internal-enum>" ;
2100 Lang::BlendModeBinding::gcMark( Kernel::GCMarkedSet
& marked
)
2105 Kernel::BlendModeDynamicVariableProperties::BlendModeDynamicVariableProperties( const Ast::PlacedIdentifier
* id
)
2106 : Kernel::DynamicVariableProperties( id
)
2109 Kernel::BlendModeDynamicVariableProperties::~BlendModeDynamicVariableProperties( )
2112 Kernel::VariableHandle
2113 Kernel::BlendModeDynamicVariableProperties::fetch( const Kernel::PassedDyn
& dyn
) const
2115 RefCountPtr
< const Kernel::GraphicsState
> graphicsState
= dyn
->getGraphicsState( );
2116 return Helpers::newValHandle( new Lang::BlendMode( graphicsState
->blend_
) );
2120 Kernel::BlendModeDynamicVariableProperties::makeBinding( Kernel::VariableHandle val
, const Ast::DynamicBindingExpression
* bindingExpr
, Kernel::EvalState
* evalState
) const
2124 RefCountPtr
< const Lang::BlendMode
> blend
= val
->tryVal
< const Lang::BlendMode
>( );
2125 Kernel::ContRef cont
= evalState
->cont_
;
2126 cont
->takeValue( Kernel::ValueRef( new Lang::BlendModeBinding( id_
, bindingExpr
, blend
->mode_
) ),
2130 catch( const NonLocalExit::NotThisType
& ball
)
2137 RefCountPtr
< const Lang::Void
> dummy
= val
->tryVal
< const Lang::Void
>( );
2138 Kernel::ContRef cont
= evalState
->cont_
;
2139 cont
->takeValue( Kernel::ValueRef( new Lang::BlendModeBinding( id_
, bindingExpr
, Lang::BlendMode::BLEND_SAME
) ),
2143 catch( const NonLocalExit::NotThisType
& ball
)
2148 throw Exceptions::TypeMismatch( bindingExpr
->exprLoc( ), val
->getUntyped( )->getTypeName( ), Helpers::typeSetString( Lang::BlendMode::staticTypeName( ), Lang::Void::staticTypeName( ) ) );
2153 Lang::ColorSpace::ColorSpace( )
2156 Lang::ColorSpace::~ColorSpace( )
2159 RefCountPtr
< const Lang::Class
> Lang::ColorSpace::TypeID( new Lang::SystemFinalClass( strrefdup( "ColorSpace" ) ) );
2160 TYPEINFOIMPL( ColorSpace
);
2163 Lang::ColorSpace::show( std::ostream
& os
) const
2165 os
<< this->name( )->name( ) ;
2169 Lang::InheritedColorSpace::InheritedColorSpace( )
2172 Lang::InheritedColorSpace::~InheritedColorSpace( )
2175 RefCountPtr
< SimplePDF::PDF_Name
>
2176 Lang::InheritedColorSpace::name( ) const
2178 throw Exceptions::InternalError( "InheritedColorSpace::name was invoked." );
2182 Lang::InheritedColorSpace::numberOfComponents( ) const
2184 throw Exceptions::InternalError( "InheritedColorSpace::numerOfComponents was invoked." );
2188 Lang::InheritedColorSpace::containsColor( const Lang::Color
* col
) const
2190 throw Exceptions::InternalError( "InheritedColorSpace::containsColor was invoked." );
2194 Kernel::Auto_qQ::Auto_qQ( Kernel::GraphicsState
* graphicsState
, Kernel::TextState
* textState
, std::ostream
& os
, bool active
)
2195 : graphicsState_( graphicsState
), graphicsEnterState_( 0 ), textState_( textState
), textEnterState_( 0 ), os_( os
), activated_( false )
2204 Kernel::Auto_qQ::activate( )
2208 throw Exceptions::InternalError( "Multiple activation of Auto_qQ." );
2211 graphicsEnterState_
= new Kernel::GraphicsState( *graphicsState_
);
2212 textEnterState_
= new Kernel::TextState( *textState_
);
2213 os_
<< "q" << std::endl
;
2216 Kernel::Auto_qQ::~Auto_qQ( )
2220 *graphicsState_
= *graphicsEnterState_
;
2221 delete graphicsEnterState_
;
2222 *textState_
= *textEnterState_
;
2223 delete textEnterState_
;
2224 os_
<< "Q" << std::endl
;