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_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 char * _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
<< "@" << 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_
;
224 const Ast::DynamicBindingExpression
* bindingExpr_
;
225 Kernel::ContRef cont_
;
227 UserDynamicBindingContinuation( const Ast::SourceLocation
& traceLoc
, const Kernel::DynamicEnvironmentKeyType
& key
, const char * name
, const Ast::DynamicBindingExpression
* bindingExpr
, const Kernel::ContRef
& cont
)
228 : Kernel::Continuation( traceLoc
), key_( key
), name_( name
), 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_
, name_
, 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 char * name
, const Kernel::DynamicEnvironmentKeyType
& key
, const RefCountPtr
< const Lang::Function
> & filter
, const Kernel::VariableHandle
& defaultVal
)
256 : DynamicVariableProperties( name
), 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_
, name_
, bindingExpr
, val
) ),
286 evalState
->cont_
= Kernel::ContRef( new Kernel::UserDynamicBindingContinuation( bindingExpr
->exprLoc( ), key_
, name_
, bindingExpr
, evalState
->cont_
) );
288 filter_
->call( filter_
, evalState
, val
, bindingExpr
->exprLoc( ) );
292 Kernel::UserDynamicStateProperties::UserDynamicStateProperties( const char * name
, const Kernel::DynamicEnvironmentKeyType
& key
, const Kernel::PassedEnv
& defaultStateEnv
, Kernel::PassedDyn defaultStateDyn
, Ast::StateReference
* defaultState
)
293 : DynamicStateProperties( name
), key_( key
),
294 defaultStateEnv_( defaultStateEnv
), defaultStateDyn_( defaultStateDyn
), defaultState_( defaultState
)
297 Kernel::UserDynamicStateProperties::~UserDynamicStateProperties( )
301 Kernel::UserDynamicStateProperties::fetch( const Kernel::PassedDyn
& dyn
) const
305 throw Exceptions::NotImplemented( "Fetching dynamic states" );
306 // return dyn->getStateHandle( key_ );
308 catch( const NonLocalExit::DynamicBindingNotFound
& ball
)
310 return defaultState_
->getHandle( defaultStateEnv_
, defaultStateDyn_
);
315 Kernel::UserDynamicStateProperties::makeBinding( Kernel::StateHandle val
, const Ast::DynamicStateBindingExpression
* bindingExpr
, Kernel::EvalState
* evalState
) const
317 throw Exceptions::NotImplemented( "Creation of dynamic state bindings" );
322 Lang::WidthBinding::WidthBinding( const char * id
, const Ast::DynamicBindingExpression
* bindingExpr
, Concrete::Length val
)
323 : bindingExpr_( bindingExpr
), val_( val
), id_( id
)
326 Lang::WidthBinding::~WidthBinding( )
330 Lang::WidthBinding::bind( MapType
& bindings
, Kernel::SystemDynamicVariables
** sysBindings
) const
332 if( *sysBindings
== 0 )
334 *sysBindings
= new Kernel::SystemDynamicVariables( );
335 Kernel::GraphicsState
* newState
= new Kernel::GraphicsState( );
336 newState
->width_
= val_
;
337 (*sysBindings
)->graphicsState_
= RefCountPtr
< const Kernel::GraphicsState
>( newState
);
341 if( (*sysBindings
)->graphicsState_
== NullPtr
< const Kernel::GraphicsState
>( ) )
343 Kernel::GraphicsState
* newState
= new Kernel::GraphicsState( );
344 newState
->width_
= val_
;
345 (*sysBindings
)->graphicsState_
= RefCountPtr
< const Kernel::GraphicsState
>( newState
);
349 Kernel::GraphicsState
* newState
= new Kernel::GraphicsState( *((*sysBindings
)->graphicsState_
) );
351 if( ! IS_NAN( newState
->width_
) )
353 throw Exceptions::MultipleDynamicBind( id_
, bindingExpr_
->idLoc( ), Ast::THE_UNKNOWN_LOCATION
);
356 newState
->width_
= val_
;
357 (*sysBindings
)->graphicsState_
= RefCountPtr
< const Kernel::GraphicsState
>( newState
);
361 Lang::WidthBinding::show( std::ostream
& os
) const
363 os
<< Interaction::DYNAMIC_VARIABLE_PREFIX
<< id_
<< ":"
364 << double( val_
.offtype
< 1, 0 >( ) ) * Interaction::displayUnitFactor
<< Interaction::displayUnitName
;
368 Lang::WidthBinding::gcMark( Kernel::GCMarkedSet
& marked
)
373 Kernel::WidthDynamicVariableProperties::WidthDynamicVariableProperties( const char * _name
)
374 : Kernel::DynamicVariableProperties( _name
)
377 Kernel::WidthDynamicVariableProperties::~WidthDynamicVariableProperties( )
380 Kernel::VariableHandle
381 Kernel::WidthDynamicVariableProperties::fetch( const Kernel::PassedDyn
& dyn
) const
383 RefCountPtr
< const Kernel::GraphicsState
> graphicsState
= dyn
->getGraphicsState( );
384 return Kernel::VariableHandle( new Kernel::Variable( RefCountPtr
< const Lang::Value
>( new Lang::Length( graphicsState
->width_
) ) ) );
388 Kernel::WidthDynamicVariableProperties::makeBinding( Kernel::VariableHandle val
, const Ast::DynamicBindingExpression
* bindingExpr
, Kernel::EvalState
* evalState
) const
392 RefCountPtr
< const Lang::Length
> len
= val
->tryVal
< const Lang::Length
>( );
393 if( len
->getScalar( ) < 0 )
395 throw Exceptions::OutOfRange( bindingExpr
->exprLoc( ), strrefdup( "The length must be non-negative." ) );
397 Kernel::ContRef cont
= evalState
->cont_
;
398 cont
->takeValue( Kernel::ValueRef( new Lang::WidthBinding( name_
, bindingExpr
, len
->get( ) ) ),
402 catch( const NonLocalExit::NotThisType
& ball
)
409 RefCountPtr
< const Lang::Void
> dummy
= val
->tryVal
< const Lang::Void
>( );
410 Kernel::ContRef cont
= evalState
->cont_
;
411 cont
->takeValue( Kernel::ValueRef( new Lang::WidthBinding( name_
, bindingExpr
, Concrete::Length( -1 ) ) ),
415 catch( const NonLocalExit::NotThisType
& ball
)
420 throw Exceptions::TypeMismatch( bindingExpr
->exprLoc( ), val
->getUntyped( )->getTypeName( ), Helpers::typeSetString( Lang::Length::staticTypeName( ), Lang::Void::staticTypeName( ) ) );
424 Lang::MiterLimitBinding::MiterLimitBinding( const char * id
, const Ast::DynamicBindingExpression
* bindingExpr
, Concrete::Length val
)
425 : bindingExpr_( bindingExpr
), val_( val
), id_( id
)
428 Lang::MiterLimitBinding::~MiterLimitBinding( )
432 Lang::MiterLimitBinding::bind( MapType
& bindings
, Kernel::SystemDynamicVariables
** sysBindings
) const
434 if( *sysBindings
== 0 )
436 *sysBindings
= new Kernel::SystemDynamicVariables( );
437 Kernel::GraphicsState
* newState
= new Kernel::GraphicsState( );
438 newState
->miterLimit_
= val_
;
439 (*sysBindings
)->graphicsState_
= RefCountPtr
< const Kernel::GraphicsState
>( newState
);
443 if( (*sysBindings
)->graphicsState_
== NullPtr
< const Kernel::GraphicsState
>( ) )
445 Kernel::GraphicsState
* newState
= new Kernel::GraphicsState( );
446 newState
->miterLimit_
= val_
;
447 (*sysBindings
)->graphicsState_
= RefCountPtr
< const Kernel::GraphicsState
>( newState
);
451 Kernel::GraphicsState
* newState
= new Kernel::GraphicsState( *((*sysBindings
)->graphicsState_
) );
453 if( ! IS_NAN( newState
->miterLimit_
) )
455 throw Exceptions::MultipleDynamicBind( id_
, bindingExpr_
->idLoc( ), Ast::THE_UNKNOWN_LOCATION
);
458 newState
->miterLimit_
= val_
;
459 (*sysBindings
)->graphicsState_
= RefCountPtr
< const Kernel::GraphicsState
>( newState
);
463 Lang::MiterLimitBinding::show( std::ostream
& os
) const
465 os
<< Interaction::DYNAMIC_VARIABLE_PREFIX
<< id_
<< ":"
466 << double( val_
.offtype
< 1, 0 >( ) ) * Interaction::displayUnitFactor
<< Interaction::displayUnitName
;
470 Lang::MiterLimitBinding::gcMark( Kernel::GCMarkedSet
& marked
)
475 Kernel::MiterLimitDynamicVariableProperties::MiterLimitDynamicVariableProperties( const char * name
)
476 : Kernel::DynamicVariableProperties( name
)
479 Kernel::MiterLimitDynamicVariableProperties::~MiterLimitDynamicVariableProperties( )
482 Kernel::VariableHandle
483 Kernel::MiterLimitDynamicVariableProperties::fetch( const Kernel::PassedDyn
& dyn
) const
485 RefCountPtr
< const Kernel::GraphicsState
> graphicsState
= dyn
->getGraphicsState( );
486 return Kernel::VariableHandle( new Kernel::Variable( RefCountPtr
< const Lang::Value
>( new Lang::Length( graphicsState
->miterLimit_
) ) ) );
490 Kernel::MiterLimitDynamicVariableProperties::makeBinding( Kernel::VariableHandle val
, const Ast::DynamicBindingExpression
* bindingExpr
, Kernel::EvalState
* evalState
) const
494 RefCountPtr
< const Lang::Length
> len
= val
->tryVal
< const Lang::Length
>( );
495 if( len
->getScalar( ) < 0 )
497 throw Exceptions::OutOfRange( bindingExpr
->exprLoc( ), strrefdup( "The length must be non-negative." ) );
499 Kernel::ContRef cont
= evalState
->cont_
;
500 cont
->takeValue( Kernel::ValueRef( new Lang::MiterLimitBinding( name_
, bindingExpr
, len
->get( ) ) ),
504 catch( const NonLocalExit::NotThisType
& ball
)
511 RefCountPtr
< const Lang::Void
> dummy
= val
->tryVal
< const Lang::Void
>( );
512 Kernel::ContRef cont
= evalState
->cont_
;
513 cont
->takeValue( Kernel::ValueRef( new Lang::MiterLimitBinding( name_
, bindingExpr
, Concrete::Length( -1 ) ) ),
517 catch( const NonLocalExit::NotThisType
& ball
)
522 throw Exceptions::TypeMismatch( bindingExpr
->exprLoc( ), val
->getUntyped( )->getTypeName( ), Helpers::typeSetString( Lang::Length::staticTypeName( ), Lang::Void::staticTypeName( ) ) );
526 Lang::CapStyle::CapStyle( const Lang::CapStyle::ValueType
& cap
)
530 RefCountPtr
< const Lang::Class
> Lang::CapStyle::TypeID( new Lang::SystemFinalClass( strrefdup( "CapStyle" ) ) );
531 TYPEINFOIMPL( CapStyle
);
534 Lang::JoinStyle::JoinStyle( const Lang::JoinStyle::ValueType
& join
)
538 RefCountPtr
< const Lang::Class
> Lang::JoinStyle::TypeID( new Lang::SystemFinalClass( strrefdup( "JoinStyle" ) ) );
539 TYPEINFOIMPL( JoinStyle
);
542 Lang::BlendMode::BlendMode( const Lang::BlendMode::ValueType
& mode
)
546 RefCountPtr
< const Lang::Class
> Lang::BlendMode::TypeID( new Lang::SystemFinalClass( strrefdup( "BlendMode" ) ) );
547 TYPEINFOIMPL( BlendMode
);
549 std::map
< Lang::BlendMode::ValueType
, RefCountPtr
< SimplePDF::PDF_Object
> > Lang::BlendMode::resourceMap
;
552 Lang::BlendMode::applyGraphicsState( std::ostream
& os
, SimplePDF::PDF_Resources
* resources
, const Lang::BlendMode::ValueType
& mode
)
554 typedef typeof resourceMap MapType
;
555 MapType::const_iterator i
= resourceMap
.find( mode
);
556 if( i
!= resourceMap
.end( ) )
558 os
<< resources
->nameofGraphicsState( i
->second
) << " gs " ;
562 RefCountPtr
< SimplePDF::PDF_Dictionary
> dic
;
563 (*dic
)[ "Type" ] = SimplePDF::newName( "ExtGState" );
565 RefCountPtr
< SimplePDF::PDF_Object
> indirection
= SimplePDF::indirect( dic
, & Kernel::theIndirectObjectCount
);
566 resourceMap
.insert( MapType::value_type( mode
, indirection
) );
570 (*dic
)[ "BM" ] = SimplePDF::newName( "Normal" );
573 (*dic
)[ "BM" ] = SimplePDF::newName( "Multiply" );
576 (*dic
)[ "BM" ] = SimplePDF::newName( "Screen" );
579 (*dic
)[ "BM" ] = SimplePDF::newName( "Overlay" );
582 (*dic
)[ "BM" ] = SimplePDF::newName( "Darken" );
585 (*dic
)[ "BM" ] = SimplePDF::newName( "Lighten" );
588 (*dic
)[ "BM" ] = SimplePDF::newName( "ColorDodge" );
591 (*dic
)[ "BM" ] = SimplePDF::newName( "ColorBurn" );
594 (*dic
)[ "BM" ] = SimplePDF::newName( "HardLight" );
597 (*dic
)[ "BM" ] = SimplePDF::newName( "SoftLight" );
600 (*dic
)[ "BM" ] = SimplePDF::newName( "Difference" );
603 (*dic
)[ "BM" ] = SimplePDF::newName( "Exclusion" );
606 (*dic
)[ "BM" ] = SimplePDF::newName( "Hue" );
609 (*dic
)[ "BM" ] = SimplePDF::newName( "Saturation" );
612 (*dic
)[ "BM" ] = SimplePDF::newName( "Color" );
615 (*dic
)[ "BM" ] = SimplePDF::newName( "Luminosity" );
618 // We leave the graphics state dictionary empty!
621 throw Exceptions::InternalError( strrefdup( "BlendMode switch out of range." ) );
623 os
<< resources
->nameofGraphicsState( indirection
) << " gs " ;
628 Kernel::GraphicsState::GraphicsState( )
629 : strokingColor_( NullPtr
< const Lang::Color
>( ) ),
630 nonStrokingColor_( NullPtr
< const Lang::Color
>( ) ),
631 width_( std::numeric_limits
< double >::signaling_NaN( ) ),
632 cap_( Lang::CapStyle::CAP_UNDEFINED
),
633 join_( Lang::JoinStyle::JOIN_UNDEFINED
),
634 miterLimit_( std::numeric_limits
< double >::signaling_NaN( ) ),
635 dash_( NullPtr
< const Lang::Dash
>( ) ),
636 blend_( Lang::BlendMode::BLEND_UNDEFINED
),
637 alphaIsShape_( true ),
638 strokingAlpha_( NullPtr
< const Lang::Alpha
>( ) ),
639 nonStrokingAlpha_( NullPtr
< const Lang::Alpha
>( ) )
642 Kernel::GraphicsState::GraphicsState( const Kernel::GraphicsState
& orig
)
643 : strokingColor_( orig
.strokingColor_
),
644 nonStrokingColor_( orig
.nonStrokingColor_
),
645 width_( orig
.width_
),
648 miterLimit_( orig
.miterLimit_
),
650 blend_( orig
.blend_
),
651 alphaIsShape_( orig
.alphaIsShape_
),
652 strokingAlpha_( orig
.strokingAlpha_
),
653 nonStrokingAlpha_( orig
.nonStrokingAlpha_
)
656 Kernel::GraphicsState::GraphicsState( const Kernel::GraphicsState
& newValues
, const Kernel::GraphicsState
& oldValues
)
657 : strokingColor_( oldValues
.strokingColor_
),
658 nonStrokingColor_( oldValues
.nonStrokingColor_
),
659 width_( oldValues
.width_
),
660 cap_( oldValues
.cap_
),
661 join_( oldValues
.join_
),
662 miterLimit_( oldValues
.miterLimit_
),
663 dash_( oldValues
.dash_
),
664 blend_( oldValues
.blend_
),
665 alphaIsShape_( oldValues
.alphaIsShape_
),
666 strokingAlpha_( oldValues
.strokingAlpha_
),
667 nonStrokingAlpha_( oldValues
.nonStrokingAlpha_
)
669 if( newValues
.strokingColor_
!= NullPtr
< const Lang::Color
>( ) )
671 strokingColor_
= newValues
.strokingColor_
;
673 if( newValues
.nonStrokingColor_
!= NullPtr
< const Lang::Color
>( ) )
675 nonStrokingColor_
= newValues
.nonStrokingColor_
;
677 if( ! IS_NAN( newValues
.width_
) )
679 width_
= newValues
.width_
;
681 if( newValues
.cap_
!= Lang::CapStyle::CAP_UNDEFINED
)
683 cap_
= newValues
.cap_
;
685 if( newValues
.join_
!= Lang::JoinStyle::JOIN_UNDEFINED
)
687 join_
= newValues
.join_
;
689 if( ! IS_NAN( newValues
.miterLimit_
) )
691 miterLimit_
= newValues
.miterLimit_
;
693 if( newValues
.dash_
!= NullPtr
< const Lang::Dash
>( ) )
695 dash_
= newValues
.dash_
;
697 if( newValues
.blend_
!= Lang::BlendMode::BLEND_UNDEFINED
)
699 blend_
= newValues
.blend_
;
701 if( newValues
.strokingAlpha_
!= NullPtr
< const Lang::Alpha
>( ) )
703 strokingAlpha_
= newValues
.strokingAlpha_
;
704 alphaIsShape_
= newValues
.alphaIsShape_
;
706 if( newValues
.nonStrokingAlpha_
!= NullPtr
< const Lang::Alpha
>( ) )
708 nonStrokingAlpha_
= newValues
.nonStrokingAlpha_
;
709 alphaIsShape_
= newValues
.alphaIsShape_
;
713 Kernel::GraphicsState::GraphicsState( bool setDefaults
)
714 : strokingColor_( Lang::THE_BLACK
),
715 nonStrokingColor_( Lang::THE_BLACK
),
717 cap_( Lang::CapStyle::CAP_BUTT
),
718 join_( Lang::JoinStyle::JOIN_MITER
),
720 dash_( Lang::THE_SOLID_DASH
),
721 blend_( Lang::BlendMode::NORMAL
),
722 alphaIsShape_( false ),
723 strokingAlpha_( Lang::THE_OPAQUE
),
724 nonStrokingAlpha_( Lang::THE_OPAQUE
)
728 throw Exceptions::InternalError( strrefdup( "setDefaults must be true in GraphicsState::GraphicsState." ) );
732 Kernel::GraphicsState::~GraphicsState( )
736 Kernel::GraphicsState::print( std::ostream
& os
, const std::string
& indentation
) const
738 if( ! IS_NAN( width_
) )
740 os
<< indentation
<< Interaction::DYNAMIC_VARIABLE_PREFIX
<< Lang::DYNAMIC_VARIABLE_ID_WIDTH
<< ": " << width_
/ Interaction::displayUnit
<< Interaction::displayUnitName
<< std::endl
;
742 if( strokingColor_
!= NullPtr
< const Lang::Color
>( ) )
744 os
<< indentation
<< Interaction::DYNAMIC_VARIABLE_PREFIX
<< Lang::DYNAMIC_VARIABLE_ID_STROKING
<< ": " ;
745 strokingColor_
->show( os
);
748 if( nonStrokingColor_
!= NullPtr
< const Lang::Color
>( ) )
750 os
<< indentation
<< Interaction::DYNAMIC_VARIABLE_PREFIX
<< Lang::DYNAMIC_VARIABLE_ID_NONSTROKING
<< ": " ;
751 nonStrokingColor_
->show( os
);
754 os
<< "(and a bunch of other variables...)" << std::endl
;
758 Kernel::GraphicsState::synchStrokingColor( std::ostream
& os
, const GraphicsState
* ref
, SimplePDF::PDF_Resources
* resources
, bool force
)
760 if( force
|| strokingColor_
!= ref
->strokingColor_
)
762 if( ref
->strokingColor_
== NullPtr
< const Lang::Color
>( ) )
766 strokingColor_
= ref
->strokingColor_
;
767 strokingColor_
->setStroking( os
);
774 Kernel::GraphicsState::synchNonStrokingColor( std::ostream
& os
, const GraphicsState
* ref
, SimplePDF::PDF_Resources
* resources
, bool force
)
776 if( force
|| nonStrokingColor_
!= ref
->nonStrokingColor_
)
778 if( ref
->nonStrokingColor_
== NullPtr
< const Lang::Color
>( ) )
782 nonStrokingColor_
= ref
->nonStrokingColor_
;
783 nonStrokingColor_
->setNonStroking( os
);
790 Kernel::GraphicsState::synchStrokingAlpha( std::ostream
& os
, const GraphicsState
* ref
, SimplePDF::PDF_Resources
* resources
, bool force
)
792 if( force
|| strokingAlpha_
!= ref
->strokingAlpha_
|| alphaIsShape_
!= ref
->strokingAlpha_
->isShape_
)
794 if( ref
->strokingAlpha_
== NullPtr
< const Lang::Alpha
>( ) )
798 strokingAlpha_
= ref
->strokingAlpha_
;
799 alphaIsShape_
= strokingAlpha_
->isShape_
;
801 const SimplePDF::PDF_Version::Version ALPHA_VERSION
= SimplePDF::PDF_Version::PDF_1_4
;
802 if( Kernel::the_PDF_version
.greaterOrEqual( ALPHA_VERSION
) )
804 Lang::Alpha::applyGraphicsState( os
, resources
, *strokingAlpha_
, true );
809 Kernel::the_PDF_version
.message( ALPHA_VERSION
, "The graphics state stroking alpha setting was ignored." );
816 Kernel::GraphicsState::synchNonStrokingAlpha( std::ostream
& os
, const GraphicsState
* ref
, SimplePDF::PDF_Resources
* resources
, bool force
)
818 if( force
|| nonStrokingAlpha_
!= ref
->nonStrokingAlpha_
|| alphaIsShape_
!= ref
->nonStrokingAlpha_
->isShape_
)
820 if( ref
->nonStrokingAlpha_
== NullPtr
< const Lang::Alpha
>( ) )
824 nonStrokingAlpha_
= ref
->nonStrokingAlpha_
;
825 alphaIsShape_
= nonStrokingAlpha_
->isShape_
;
827 const SimplePDF::PDF_Version::Version ALPHA_VERSION
= SimplePDF::PDF_Version::PDF_1_4
;
828 if( Kernel::the_PDF_version
.greaterOrEqual( ALPHA_VERSION
) )
830 Lang::Alpha::applyGraphicsState( os
, resources
, *nonStrokingAlpha_
, false );
835 Kernel::the_PDF_version
.message( ALPHA_VERSION
, "The graphics state non-stroking alpha setting was ignored." );
842 Kernel::GraphicsState::synchWidth( std::ostream
& os
, const GraphicsState
* ref
, SimplePDF::PDF_Resources
* resources
, bool force
)
844 if( force
|| width_
!= ref
->width_
)
846 if( IS_NAN( ref
->width_
) ||
847 ref
->width_
< Concrete::ZERO_LENGTH
)
851 width_
= ref
->width_
;
852 os
<< width_
.offtype
< 1, 0 >( ) << " w " ;
859 Kernel::GraphicsState::synchCap( std::ostream
& os
, const GraphicsState
* ref
, SimplePDF::PDF_Resources
* resources
, bool force
)
861 if( force
|| cap_
!= ref
->cap_
)
863 if( ref
->cap_
!= Lang::CapStyle::CAP_UNDEFINED
&&
864 ref
->cap_
!= Lang::CapStyle::CAP_SAME
)
867 os
<< cap_
<< " J " ;
875 Kernel::GraphicsState::synchJoin( std::ostream
& os
, const GraphicsState
* ref
, SimplePDF::PDF_Resources
* resources
, bool force
)
877 if( force
|| join_
!= ref
->join_
)
879 if( ref
->join_
!= Lang::JoinStyle::JOIN_UNDEFINED
&&
880 ref
->join_
!= Lang::JoinStyle::JOIN_SAME
)
883 os
<< join_
<< " j " ;
891 Kernel::GraphicsState::synchMiterLimit( std::ostream
& os
, const GraphicsState
* ref
, SimplePDF::PDF_Resources
* resources
, bool force
)
893 if( force
|| miterLimit_
!= ref
->miterLimit_
)
895 if( IS_NAN( ref
->miterLimit_
) ||
896 ref
->miterLimit_
< Concrete::ZERO_LENGTH
)
900 miterLimit_
= ref
->miterLimit_
;
901 os
<< miterLimit_
.offtype
< 1, 0 >( ) << " M " ;
908 Kernel::GraphicsState::synchDash( std::ostream
& os
, const GraphicsState
* ref
, SimplePDF::PDF_Resources
* resources
, bool force
)
910 if( force
|| dash_
!= ref
->dash_
)
912 if( ref
->dash_
== NullPtr
< const Lang::Dash
>( ) )
917 dash_
->setDash( os
);
924 Kernel::GraphicsState::synchBlend( std::ostream
& os
, const GraphicsState
* ref
, SimplePDF::PDF_Resources
* resources
, bool force
)
926 if( force
|| blend_
!= ref
->blend_
)
928 if( ref
->blend_
== Lang::BlendMode::BLEND_UNDEFINED
)
932 blend_
= ref
->blend_
;
933 const SimplePDF::PDF_Version::Version BLEND_VERSION
= SimplePDF::PDF_Version::PDF_1_4
;
934 if( Kernel::the_PDF_version
.greaterOrEqual( BLEND_VERSION
) )
936 Lang::BlendMode::applyGraphicsState( os
, resources
, blend_
);
941 Kernel::the_PDF_version
.message( BLEND_VERSION
, "The graphics state blend mode setting was ignored." );
949 Kernel::GraphicsState::synchForStroke( std::ostream
& os
, const GraphicsState
* ref
, SimplePDF::PDF_Resources
* resources
, bool force
)
951 bool anyChange
= false;
952 anyChange
= synchStrokingColor( os
, ref
, resources
, force
) || anyChange
;
953 anyChange
= synchStrokingAlpha( os
, ref
, resources
, force
) || anyChange
;
954 anyChange
= synchWidth( os
, ref
, resources
, force
) || anyChange
;
955 anyChange
= synchCap( os
, ref
, resources
, force
) || anyChange
;
956 anyChange
= synchJoin( os
, ref
, resources
, force
) || anyChange
;
957 anyChange
= synchMiterLimit( os
, ref
, resources
, force
) || anyChange
;
958 anyChange
= synchDash( os
, ref
, resources
, force
) || anyChange
;
967 Kernel::GraphicsState::synchForNonStroke( std::ostream
& os
, const GraphicsState
* ref
, SimplePDF::PDF_Resources
* resources
, bool force
)
969 bool anyChange
= false;
970 anyChange
= synchNonStrokingColor( os
, ref
, resources
, force
) || anyChange
;
971 anyChange
= synchNonStrokingAlpha( os
, ref
, resources
, force
) || anyChange
;
980 Kernel::GraphicsState::synchStrokingColorWithNonStrokingColor( std::ostream
& os
, SimplePDF::PDF_Resources
* resources
, Concrete::Length width
)
982 bool anyChange
= false;
984 if( ! IS_NAN( width
) && width_
!= width
)
987 os
<< width_
.offtype
< 1, 0 >( ) << " w " ;
991 if( strokingColor_
!= nonStrokingColor_
)
993 strokingColor_
= nonStrokingColor_
;
994 strokingColor_
->setStroking( os
);
1005 Lang::Alpha::Alpha( bool isShape
, double a
)
1006 : isShape_( isShape
), a_( a
)
1009 Lang::Alpha::~Alpha( )
1012 RefCountPtr
< const Lang::Class
> Lang::Alpha::TypeID( new Lang::SystemFinalClass( strrefdup( "Alpha" ) ) );
1013 TYPEINFOIMPL( Alpha
);
1016 Lang::Alpha::applyGraphicsState( std::ostream
& os
, SimplePDF::PDF_Resources
* resources
, const Lang::Alpha
& self
, bool isStroking
)
1018 typedef typeof strokingShapeResourcemap MapType
;
1019 MapType
* resourceMap
;
1024 resourceMap
= & strokingShapeResourcemap
;
1028 resourceMap
= & nonStrokingShapeResourcemap
;
1035 resourceMap
= & strokingOpacityResourcemap
;
1039 resourceMap
= & nonStrokingOpacityResourcemap
;
1042 MapType::const_iterator i
= resourceMap
->find( self
.a_
);
1043 if( i
!= resourceMap
->end( ) )
1045 os
<< resources
->nameofGraphicsState( i
->second
) << " gs " ;
1049 RefCountPtr
< SimplePDF::PDF_Dictionary
> dic
;
1050 (*dic
)[ "Type" ] = SimplePDF::newName( "ExtGState" );
1051 RefCountPtr
< SimplePDF::PDF_Object
> indirection
= SimplePDF::indirect( dic
, & Kernel::theIndirectObjectCount
);
1053 resourceMap
->insert( MapType::value_type( self
.a_
, indirection
) );
1056 (*dic
)[ "AIS" ] = SimplePDF::newBoolean( self
.isShape_
);
1059 (*dic
)[ "CA" ] = SimplePDF::newFloat( self
.a_
);
1063 (*dic
)[ "ca" ] = SimplePDF::newFloat( self
.a_
);
1066 // If self.a_ < 0 we just leave the graphics state dictionary empty
1068 os
<< resources
->nameofGraphicsState( indirection
) << " gs " ;
1072 std::map
< double, RefCountPtr
< SimplePDF::PDF_Object
> > Lang::Alpha::strokingShapeResourcemap
;
1073 std::map
< double, RefCountPtr
< SimplePDF::PDF_Object
> > Lang::Alpha::strokingOpacityResourcemap
;
1074 std::map
< double, RefCountPtr
< SimplePDF::PDF_Object
> > Lang::Alpha::nonStrokingShapeResourcemap
;
1075 std::map
< double, RefCountPtr
< SimplePDF::PDF_Object
> > Lang::Alpha::nonStrokingOpacityResourcemap
;
1078 Lang::AlphaBinding::AlphaBinding( const char * id
, const Ast::DynamicBindingExpression
* bindingExpr
, const RefCountPtr
< const Lang::Alpha
> & alpha
, bool isStroking
)
1079 : bindingExpr_( bindingExpr
), alpha_( alpha
), isStroking_( isStroking
), id_( id
)
1082 Lang::AlphaBinding::~AlphaBinding( )
1086 Lang::AlphaBinding::bind( MapType
& bindings
, Kernel::SystemDynamicVariables
** sysBindings
) const
1088 if( *sysBindings
== 0 ) {
1089 *sysBindings
= new Kernel::SystemDynamicVariables( );
1090 Kernel::GraphicsState
* newState
= new Kernel::GraphicsState( );
1093 newState
->strokingAlpha_
= alpha_
;
1097 newState
->nonStrokingAlpha_
= alpha_
;
1099 newState
->alphaIsShape_
= alpha_
->isShape_
;
1100 (*sysBindings
)->graphicsState_
= RefCountPtr
< const Kernel::GraphicsState
>( newState
);
1104 if( (*sysBindings
)->graphicsState_
== NullPtr
< const Kernel::GraphicsState
>( ) )
1106 Kernel::GraphicsState
* newState
= new Kernel::GraphicsState( );
1109 newState
->strokingAlpha_
= alpha_
;
1113 newState
->nonStrokingAlpha_
= alpha_
;
1115 newState
->alphaIsShape_
= alpha_
->isShape_
;
1116 (*sysBindings
)->graphicsState_
= RefCountPtr
< const Kernel::GraphicsState
>( newState
);
1120 Kernel::GraphicsState
* newState
= new Kernel::GraphicsState( *((*sysBindings
)->graphicsState_
) );
1124 if( newState
->strokingAlpha_
!= NullPtr
< const Lang::Alpha
>( ) )
1126 throw Exceptions::MultipleDynamicBind( id_
, bindingExpr_
->idLoc( ), Ast::THE_UNKNOWN_LOCATION
);
1128 newState
->strokingAlpha_
= alpha_
;
1132 if( newState
->nonStrokingAlpha_
!= NullPtr
< const Lang::Alpha
>( ) )
1134 throw Exceptions::MultipleDynamicBind( id_
, bindingExpr_
->idLoc( ), Ast::THE_UNKNOWN_LOCATION
);
1136 newState
->nonStrokingAlpha_
= alpha_
;
1138 newState
->alphaIsShape_
= alpha_
->isShape_
;
1139 (*sysBindings
)->graphicsState_
= RefCountPtr
< const Kernel::GraphicsState
>( newState
);
1143 Lang::AlphaBinding::show( std::ostream
& os
) const
1145 os
<< Interaction::DYNAMIC_VARIABLE_PREFIX
<< id_
<< ":" ;
1150 Lang::AlphaBinding::gcMark( Kernel::GCMarkedSet
& marked
)
1152 const_cast< Lang::Alpha
* >( alpha_
.getPtr( ) )->gcMark( marked
);
1157 Kernel::AlphaDynamicVariableProperties::AlphaDynamicVariableProperties( const char * name
, bool isStroking
)
1158 : Kernel::DynamicVariableProperties( name
), isStroking_( isStroking
)
1161 Kernel::AlphaDynamicVariableProperties::~AlphaDynamicVariableProperties( )
1164 Kernel::VariableHandle
1165 Kernel::AlphaDynamicVariableProperties::fetch( const Kernel::PassedDyn
& dyn
) const
1167 RefCountPtr
< const Kernel::GraphicsState
> graphicsState
= dyn
->getGraphicsState( );
1170 return Kernel::VariableHandle( new Kernel::Variable( graphicsState
->strokingAlpha_
) );
1172 return Kernel::VariableHandle( new Kernel::Variable( graphicsState
->nonStrokingAlpha_
) );
1176 Kernel::AlphaDynamicVariableProperties::makeBinding( Kernel::VariableHandle val
, const Ast::DynamicBindingExpression
* bindingExpr
, Kernel::EvalState
* evalState
) const
1180 RefCountPtr
< const Lang::Alpha
> alpha
= val
->tryVal
< const Lang::Alpha
>( );
1181 Kernel::ContRef cont
= evalState
->cont_
;
1182 cont
->takeValue( Kernel::ValueRef( new Lang::AlphaBinding( name_
, bindingExpr
, alpha
, isStroking_
) ),
1186 catch( const NonLocalExit::NotThisType
& ball
)
1193 RefCountPtr
< const Lang::Void
> dummy
= val
->tryVal
< const Lang::Void
>( );
1194 Kernel::ContRef cont
= evalState
->cont_
;
1195 cont
->takeValue( Kernel::ValueRef( new Lang::AlphaBinding( name_
, bindingExpr
, RefCountPtr
< const Lang::Alpha
>( new Lang::Alpha( true, -1 ) ), isStroking_
) ),
1199 catch( const NonLocalExit::NotThisType
& ball
)
1204 throw Exceptions::TypeMismatch( bindingExpr
->exprLoc( ), val
->getUntyped( )->getTypeName( ), Helpers::typeSetString( Lang::Alpha::staticTypeName( ), Lang::Void::staticTypeName( ) ) );
1208 Lang::SoftMask::SoftMask( )
1209 : graphicsStateResource_( NullPtr
< SimplePDF::PDF_Object
>( ) )
1211 static size_t callCount
= 0;
1215 throw Exceptions::InternalError( strrefdup( "The None soft mask should be generated at most twice!" ) );
1218 RefCountPtr
< SimplePDF::PDF_Dictionary
> dic
;
1219 graphicsStateResource_
= SimplePDF::indirect( dic
, & Kernel::theIndirectObjectCount
);
1221 (*dic
)[ "Type" ] = SimplePDF::newName( "ExtGState" );
1222 (*dic
)[ "SMask" ] = SimplePDF::newName( "None" );
1225 Lang::SoftMask::SoftMask( SubType subType
, const RefCountPtr
< const Lang::TransparencyGroup
> & tpGroup
, const RefCountPtr
< const Lang::Color
> & background
, const RefCountPtr
< const Lang::PDF_Function
> & transfer
)
1226 : graphicsStateResource_( NullPtr
< SimplePDF::PDF_Object
>( ) )
1228 RefCountPtr
< SimplePDF::PDF_Dictionary
> gsDic
;
1229 graphicsStateResource_
= SimplePDF::indirect( gsDic
, & Kernel::theIndirectObjectCount
);
1231 RefCountPtr
< SimplePDF::PDF_Dictionary
> smDic
;
1233 (*gsDic
)[ "Type" ] = SimplePDF::newName( "ExtGState" );
1234 (*gsDic
)[ "SMask" ] = smDic
;
1235 (*smDic
)[ "G" ] = tpGroup
->getPDF_Object( );
1241 (*smDic
)[ "S" ] = SimplePDF::newName( "Alpha" );
1242 if( background
!= NullPtr
< const Lang::Color
>( ) )
1244 throw Exceptions::InternalError( strrefdup( "Attempt to create Alpha soft mask with BC." ) );
1250 (*smDic
)[ "S" ] = SimplePDF::newName( "Luminosity" );
1251 if( background
!= NullPtr
< const Lang::Color
>( ) )
1253 (*smDic
)[ "BC" ] = background
->componentVector( );
1254 if( ! tpGroup
->colorSpace( )->containsColor( background
.getPtr( ) ) )
1256 throw Exceptions::OutOfRange( "The background color is not in the transparency groups color space." );
1262 throw Exceptions::InternalError( strrefdup( "SoftMask::SoftMask: Enum switch out of range." ) );
1264 if( transfer
!= NullPtr
< const Lang::PDF_Function
>( ) )
1266 if( ! transfer
->matchesDimensions( 1, 1 ) )
1268 throw Exceptions::InternalError( strrefdup( "SoftMask::SoftMask: The transfer function arity should be correct at this point." ) );
1270 (*smDic
)[ "TR" ] = transfer
->getFunction( );
1274 Lang::SoftMask::~SoftMask( )
1277 RefCountPtr
< const Lang::Class
> Lang::SoftMask::TypeID( new Lang::SystemFinalClass( strrefdup( "SoftMask" ) ) );
1278 TYPEINFOIMPL( SoftMask
);
1281 Lang::Dash::Iterator::Iterator( RefCountPtr
< std::list
< Concrete::Length
> > _pattern
, double _scale
, std::list
< Concrete::Length
>::const_iterator _i
, bool _on
, Concrete::Length _length
)
1282 : mem_( _pattern
), begin_( _pattern
->begin( ) ), end_( _pattern
->end( ) ), scale_( _scale
), i_( _i
), on_( _on
), length_( _scale
* _length
)
1285 Lang::Dash::Iterator
&
1286 Lang::Dash::Iterator::operator ++ ( )
1298 length_
= scale_
* (*i_
);
1303 Lang::Dash::Iterator::isOn( ) const
1309 Lang::Dash::Iterator::getLength( ) const
1316 : pattern_( new list
< Concrete::Length
>( ) ), phase_( 0 ), scale_( 1 )
1319 Lang::Dash::Dash( RefCountPtr
< std::list
< Concrete::Length
> > _pattern
, Concrete::Length _phase
, double _scale
)
1320 : pattern_( _pattern
), phase_( _phase
), scale_( _scale
), myLength_( 0 )
1322 for( list
< Concrete::Length
>::const_iterator i
= pattern_
->begin( ); i
!= pattern_
->end( ); ++i
)
1328 Lang::Dash::Dash( RefCountPtr
< std::list
< Concrete::Length
> > _pattern
, Concrete::Length _phase
, double _scale
, Concrete::Length _length
)
1329 : pattern_( _pattern
), phase_( _phase
), scale_( _scale
), myLength_( _length
)
1332 DISPATCHIMPL( Dash
);
1334 Lang::Dash::~Dash( )
1337 RefCountPtr
< const Lang::Class
> Lang::Dash::TypeID( new Lang::SystemFinalClass( strrefdup( "Dash" ) ) );
1338 TYPEINFOIMPL( Dash
);
1342 Lang::Dash::setDash( ostream
& os
) const
1344 // Negative scale means that the dash shall not be altered
1351 for( list
< Concrete::Length
>::const_iterator i
= pattern_
->begin( ); i
!= pattern_
->end( ); ++i
)
1353 os
<< Concrete::Length::offtype( *i
) * scale_
<< " " ;
1355 os
<< "] " << Concrete::Length::offtype( phase_
) * scale_
<< " d " ;
1358 RefCountPtr
< SimplePDF::PDF_Vector
>
1359 Lang::Dash::getDashArray( ) const
1363 throw Exceptions::MiscellaneousRequirement( "The same-as-before dash cannot be represented in PDF." );
1366 RefCountPtr
< SimplePDF::PDF_Vector
> res
= RefCountPtr
< SimplePDF::PDF_Vector
>( new SimplePDF::PDF_Vector
);
1367 for( list
< Concrete::Length
>::const_iterator i
= pattern_
->begin( ); i
!= pattern_
->end( ); ++i
)
1369 res
->vec
.push_back( SimplePDF::newFloat( Concrete::Length::offtype( *i
) * scale_
) );
1375 RefCountPtr
< const Lang::Dash
>
1376 Lang::Dash::scaled( double factor
) const
1378 return RefCountPtr
< const Lang::Dash
>( new Lang::Dash( pattern_
, phase_
, scale_
* factor
, myLength_
) );
1381 RefCountPtr
< const Lang::Dash
>
1382 Lang::Dash::shifted( Concrete::Length dist
) const
1384 return RefCountPtr
< const Lang::Dash
>( new Lang::Dash( pattern_
, phase_
+ dist
/ scale_
, scale_
, myLength_
) );
1388 Lang::Dash::length( ) const
1390 return myLength_
* scale_
;
1394 Lang::Dash::isSolid( ) const
1396 return pattern_
->empty( );
1399 Lang::Dash::Iterator
1400 Lang::Dash::begin( ) const
1402 Concrete::Length tmpPhase
= modPhysical( phase_
, myLength_
);
1405 tmpPhase
+= myLength_
;
1407 std::list
< Concrete::Length
>::const_iterator i
= pattern_
->begin( );
1409 while( tmpPhase
>= *i
)
1415 return Lang::Dash::Iterator( pattern_
, scale_
, i
, on
, *i
- tmpPhase
);
1418 Lang::Color::Color( )
1421 DISPATCHIMPL( Color
);
1423 Lang::Color::~Color( )
1426 RefCountPtr
< const Lang::Class
> Lang::Color::TypeID
= NullPtr
< const Lang::Class
>( ); /* The value is set in main */
1428 RefCountPtr
< const char >
1429 Lang::Color::staticTypeName( )
1431 return TypeID
->getPrettyName( );
1435 Lang::Gray::Gray( const Concrete::Gray
& components
)
1436 : components_( components
)
1439 DISPATCHIMPL( Gray
);
1441 Lang::Gray::~Gray( )
1444 RefCountPtr
< const Lang::Class
> Lang::Gray::TypeID( new Lang::SystemFinalClass( strrefdup( "Gray" ) ) );
1445 TYPEINFOIMPL( Gray
);
1448 Lang::Gray::show( std::ostream
& os
) const
1450 os
<< "[gray " << components_
.gr_
<< "]" ;
1454 Lang::Gray::setStroking( ostream
& os
) const
1456 components_
.setStroking( os
);
1460 Lang::Gray::setNonStroking( ostream
& os
) const
1462 components_
.setNonStroking( os
);
1465 RefCountPtr
< SimplePDF::PDF_Vector
>
1466 Lang::Gray::componentVector( ) const
1468 return components_
.componentVector( );
1472 Lang::RGB::RGB( const Concrete::RGB
& components
)
1473 : components_( components
)
1476 DISPATCHIMPL( RGB
);
1481 RefCountPtr
< const Lang::Class
> Lang::RGB::TypeID( new Lang::SystemFinalClass( strrefdup( "RGB" ) ) );
1482 TYPEINFOIMPL( RGB
);
1485 Lang::RGB::show( std::ostream
& os
) const
1487 os
<< "[rgb " << components_
.r_
<< " " << components_
.g_
<< " " << components_
.b_
<< "]" ;
1491 Lang::RGB::setStroking( ostream
& os
) const
1493 components_
.setStroking( os
);
1497 Lang::RGB::setNonStroking( ostream
& os
) const
1499 components_
.setNonStroking( os
);
1502 RefCountPtr
< SimplePDF::PDF_Vector
>
1503 Lang::RGB::componentVector( ) const
1505 return components_
.componentVector( );
1509 Lang::CMYK::CMYK( const Concrete::CMYK
& components
)
1510 : components_( components
)
1513 DISPATCHIMPL( CMYK
);
1515 Lang::CMYK::~CMYK( )
1518 RefCountPtr
< const Lang::Class
> Lang::CMYK::TypeID( new Lang::SystemFinalClass( strrefdup( "CMYK" ) ) );
1519 TYPEINFOIMPL( CMYK
);
1522 Lang::CMYK::show( std::ostream
& os
) const
1524 os
<< "[cmyk " << components_
.c_
<< " " << components_
.m_
<< " " << components_
.y_
<< " " << components_
.k_
<< "]" ;
1528 Lang::CMYK::setStroking( ostream
& os
) const
1530 components_
.setStroking( os
);
1534 Lang::CMYK::setNonStroking( ostream
& os
) const
1536 components_
.setNonStroking( os
);
1539 RefCountPtr
< SimplePDF::PDF_Vector
>
1540 Lang::CMYK::componentVector( ) const
1542 return components_
.componentVector( );
1546 Lang::StrokingBinding::StrokingBinding( const char * id
, const Ast::DynamicBindingExpression
* bindingExpr
, RefCountPtr
< const Lang::Color
> color
)
1547 : bindingExpr_( bindingExpr
), color_( color
), id_( id
)
1550 Lang::StrokingBinding::~StrokingBinding( )
1554 Lang::StrokingBinding::bind( MapType
& bindings
, Kernel::SystemDynamicVariables
** sysBindings
) const
1556 if( *sysBindings
== 0 )
1558 *sysBindings
= new Kernel::SystemDynamicVariables( );
1559 Kernel::GraphicsState
* newState
= new Kernel::GraphicsState( );
1560 newState
->strokingColor_
= color_
;
1561 (*sysBindings
)->graphicsState_
= RefCountPtr
< const Kernel::GraphicsState
>( newState
);
1565 if( (*sysBindings
)->graphicsState_
== NullPtr
< const Kernel::GraphicsState
>( ) )
1567 Kernel::GraphicsState
* newState
= new Kernel::GraphicsState( );
1568 newState
->strokingColor_
= color_
;
1569 (*sysBindings
)->graphicsState_
= RefCountPtr
< const Kernel::GraphicsState
>( newState
);
1573 Kernel::GraphicsState
* newState
= new Kernel::GraphicsState( *((*sysBindings
)->graphicsState_
) );
1575 if( newState
->strokingColor_
!= NullPtr
< const Lang::Color
>( ) )
1577 throw Exceptions::MultipleDynamicBind( id_
, bindingExpr_
->idLoc( ), Ast::THE_UNKNOWN_LOCATION
);
1580 newState
->strokingColor_
= color_
;
1581 (*sysBindings
)->graphicsState_
= RefCountPtr
< const Kernel::GraphicsState
>( newState
);
1585 Lang::StrokingBinding::show( std::ostream
& os
) const
1587 os
<< Interaction::DYNAMIC_VARIABLE_PREFIX
<< id_
<< ":" ;
1592 Lang::StrokingBinding::gcMark( Kernel::GCMarkedSet
& marked
)
1594 const_cast< Lang::Color
* >( color_
.getPtr( ) )->gcMark( marked
);
1599 Kernel::StrokingDynamicVariableProperties::StrokingDynamicVariableProperties( const char * name
)
1600 : Kernel::DynamicVariableProperties( name
)
1603 Kernel::StrokingDynamicVariableProperties::~StrokingDynamicVariableProperties( )
1606 Kernel::VariableHandle
1607 Kernel::StrokingDynamicVariableProperties::fetch( const Kernel::PassedDyn
& dyn
) const
1609 RefCountPtr
< const Kernel::GraphicsState
> graphicsState
= dyn
->getGraphicsState( );
1610 return Kernel::VariableHandle( new Kernel::Variable( graphicsState
->strokingColor_
) );
1614 Kernel::StrokingDynamicVariableProperties::makeBinding( Kernel::VariableHandle val
, const Ast::DynamicBindingExpression
* bindingExpr
, Kernel::EvalState
* evalState
) const
1618 RefCountPtr
< const Lang::Color
> color
= val
->tryVal
< const Lang::Color
>( );
1619 Kernel::ContRef cont
= evalState
->cont_
;
1620 cont
->takeValue( Kernel::ValueRef( new Lang::StrokingBinding( name_
, bindingExpr
, color
) ),
1624 catch( const NonLocalExit::NotThisType
& ball
)
1631 RefCountPtr
< const Lang::Void
> dummy
= val
->tryVal
< const Lang::Void
>( );
1632 Kernel::ContRef cont
= evalState
->cont_
;
1633 cont
->takeValue( Kernel::ValueRef( new Lang::StrokingBinding( name_
, bindingExpr
, RefCountPtr
< const Lang::Color
>( new Lang::Gray( -1 ) ) ) ),
1637 catch( const NonLocalExit::NotThisType
& ball
)
1642 throw Exceptions::TypeMismatch( bindingExpr
->exprLoc( ), val
->getUntyped( )->getTypeName( ), Helpers::typeSetString( Lang::Color::staticTypeName( ), Lang::Void::staticTypeName( ) ) );
1646 Lang::NonStrokingBinding::NonStrokingBinding( const char * id
, const Ast::DynamicBindingExpression
* bindingExpr
, RefCountPtr
< const Lang::Color
> color
)
1647 : bindingExpr_( bindingExpr
), color_( color
), id_( id
)
1650 Lang::NonStrokingBinding::~NonStrokingBinding( )
1654 Lang::NonStrokingBinding::bind( MapType
& bindings
, Kernel::SystemDynamicVariables
** sysBindings
) const
1656 if( *sysBindings
== 0 )
1658 *sysBindings
= new Kernel::SystemDynamicVariables( );
1659 Kernel::GraphicsState
* newState
= new Kernel::GraphicsState( );
1660 newState
->nonStrokingColor_
= color_
;
1661 (*sysBindings
)->graphicsState_
= RefCountPtr
< const Kernel::GraphicsState
>( newState
);
1665 if( (*sysBindings
)->graphicsState_
== NullPtr
< const Kernel::GraphicsState
>( ) )
1667 Kernel::GraphicsState
* newState
= new Kernel::GraphicsState( );
1668 newState
->nonStrokingColor_
= color_
;
1669 (*sysBindings
)->graphicsState_
= RefCountPtr
< const Kernel::GraphicsState
>( newState
);
1673 Kernel::GraphicsState
* newState
= new Kernel::GraphicsState( *((*sysBindings
)->graphicsState_
) );
1675 if( newState
->nonStrokingColor_
!= NullPtr
< const Lang::Color
>( ) )
1677 throw Exceptions::MultipleDynamicBind( id_
, bindingExpr_
->idLoc( ), Ast::THE_UNKNOWN_LOCATION
);
1680 newState
->nonStrokingColor_
= color_
;
1681 (*sysBindings
)->graphicsState_
= RefCountPtr
< const Kernel::GraphicsState
>( newState
);
1685 Lang::NonStrokingBinding::show( std::ostream
& os
) const
1687 os
<< Interaction::DYNAMIC_VARIABLE_PREFIX
<< id_
<< ":" ;
1692 Lang::NonStrokingBinding::gcMark( Kernel::GCMarkedSet
& marked
)
1694 const_cast< Lang::Color
* >( color_
.getPtr( ) )->gcMark( marked
);
1699 Kernel::NonStrokingDynamicVariableProperties::NonStrokingDynamicVariableProperties( const char * name
)
1700 : Kernel::DynamicVariableProperties( name
)
1703 Kernel::NonStrokingDynamicVariableProperties::~NonStrokingDynamicVariableProperties( )
1706 Kernel::VariableHandle
1707 Kernel::NonStrokingDynamicVariableProperties::fetch( const Kernel::PassedDyn
& dyn
) const
1709 RefCountPtr
< const Kernel::GraphicsState
> graphicsState
= dyn
->getGraphicsState( );
1710 return Kernel::VariableHandle( new Kernel::Variable( graphicsState
->nonStrokingColor_
) );
1714 Kernel::NonStrokingDynamicVariableProperties::makeBinding( Kernel::VariableHandle val
, const Ast::DynamicBindingExpression
* bindingExpr
, Kernel::EvalState
* evalState
) const
1718 RefCountPtr
< const Lang::Color
> color
= val
->tryVal
< const Lang::Color
>( );
1719 Kernel::ContRef cont
= evalState
->cont_
;
1720 cont
->takeValue( Kernel::ValueRef( new Lang::NonStrokingBinding( name_
, bindingExpr
, color
) ),
1724 catch( const NonLocalExit::NotThisType
& ball
)
1731 RefCountPtr
< const Lang::Void
> dummy
= val
->tryVal
< const Lang::Void
>( );
1732 Kernel::ContRef cont
= evalState
->cont_
;
1733 cont
->takeValue( Kernel::ValueRef( new Lang::NonStrokingBinding( name_
, bindingExpr
, RefCountPtr
< const Lang::Color
>( new Lang::Gray( -1 ) ) ) ),
1737 catch( const NonLocalExit::NotThisType
& ball
)
1742 throw Exceptions::TypeMismatch( bindingExpr
->exprLoc( ), val
->getUntyped( )->getTypeName( ), Helpers::typeSetString( Lang::Color::staticTypeName( ), Lang::Void::staticTypeName( ) ) );
1746 Lang::DashBinding::DashBinding( const char * id
, const Ast::DynamicBindingExpression
* bindingExpr
, RefCountPtr
< const Lang::Dash
> dash
)
1747 : bindingExpr_( bindingExpr
), dash_( dash
), id_( id
)
1750 Lang::DashBinding::~DashBinding( )
1754 Lang::DashBinding::bind( MapType
& bindings
, Kernel::SystemDynamicVariables
** sysBindings
) const
1756 if( *sysBindings
== 0 )
1758 *sysBindings
= new Kernel::SystemDynamicVariables( );
1759 Kernel::GraphicsState
* newState
= new Kernel::GraphicsState( );
1760 newState
->dash_
= dash_
;
1761 (*sysBindings
)->graphicsState_
= RefCountPtr
< const Kernel::GraphicsState
>( newState
);
1765 if( (*sysBindings
)->graphicsState_
== NullPtr
< const Kernel::GraphicsState
>( ) )
1767 Kernel::GraphicsState
* newState
= new Kernel::GraphicsState( );
1768 newState
->dash_
= dash_
;
1769 (*sysBindings
)->graphicsState_
= RefCountPtr
< const Kernel::GraphicsState
>( newState
);
1773 Kernel::GraphicsState
* newState
= new Kernel::GraphicsState( *((*sysBindings
)->graphicsState_
) );
1775 if( newState
->dash_
!= NullPtr
< const Lang::Dash
>( ) )
1777 throw Exceptions::MultipleDynamicBind( id_
, bindingExpr_
->idLoc( ), Ast::THE_UNKNOWN_LOCATION
);
1780 newState
->dash_
= dash_
;
1781 (*sysBindings
)->graphicsState_
= RefCountPtr
< const Kernel::GraphicsState
>( newState
);
1785 Lang::DashBinding::show( std::ostream
& os
) const
1787 os
<< Interaction::DYNAMIC_VARIABLE_PREFIX
<< id_
<< ":" ;
1792 Lang::DashBinding::gcMark( Kernel::GCMarkedSet
& marked
)
1794 const_cast< Lang::Dash
* >( dash_
.getPtr( ) )->gcMark( marked
);
1799 Kernel::DashDynamicVariableProperties::DashDynamicVariableProperties( const char * _name
)
1800 : Kernel::DynamicVariableProperties( _name
)
1803 Kernel::DashDynamicVariableProperties::~DashDynamicVariableProperties( )
1806 Kernel::VariableHandle
1807 Kernel::DashDynamicVariableProperties::fetch( const Kernel::PassedDyn
& dyn
) const
1809 RefCountPtr
< const Kernel::GraphicsState
> graphicsState
= dyn
->getGraphicsState( );
1810 return Kernel::VariableHandle( new Kernel::Variable( graphicsState
->dash_
) );
1814 Kernel::DashDynamicVariableProperties::makeBinding( Kernel::VariableHandle val
, const Ast::DynamicBindingExpression
* bindingExpr
, Kernel::EvalState
* evalState
) const
1818 RefCountPtr
< const Lang::Dash
> dash
= val
->tryVal
< const Lang::Dash
>( );
1819 Kernel::ContRef cont
= evalState
->cont_
;
1820 cont
->takeValue( Kernel::ValueRef( new Lang::DashBinding( name_
, bindingExpr
, dash
) ),
1824 catch( const NonLocalExit::NotThisType
& ball
)
1831 RefCountPtr
< const Lang::Void
> dummy
= val
->tryVal
< const Lang::Void
>( );
1832 Kernel::ContRef cont
= evalState
->cont_
;
1833 cont
->takeValue( Kernel::ValueRef( new Lang::DashBinding( name_
, bindingExpr
, RefCountPtr
< const Lang::Dash
>( new Lang::Dash( RefCountPtr
< std::list
< Concrete::Length
> >( new std::list
< Concrete::Length
>( ) ), 0, -1 ) ) ) ),
1837 catch( const NonLocalExit::NotThisType
& ball
)
1842 throw Exceptions::TypeMismatch( bindingExpr
->exprLoc( ), val
->getUntyped( )->getTypeName( ), Helpers::typeSetString( Lang::Dash::staticTypeName( ), Lang::Void::staticTypeName( ) ) );
1847 Lang::CapStyleBinding::CapStyleBinding( const char * id
, const Ast::DynamicBindingExpression
* bindingExpr
, const Lang::CapStyle::ValueType
& cap
)
1848 : bindingExpr_( bindingExpr
), cap_( cap
), id_( id
)
1851 Lang::CapStyleBinding::~CapStyleBinding( )
1855 Lang::CapStyleBinding::bind( MapType
& bindings
, Kernel::SystemDynamicVariables
** sysBindings
) const
1857 if( *sysBindings
== 0 ) {
1858 *sysBindings
= new Kernel::SystemDynamicVariables( );
1859 Kernel::GraphicsState
* newState
= new Kernel::GraphicsState( );
1860 newState
->cap_
= cap_
;
1861 (*sysBindings
)->graphicsState_
= RefCountPtr
< const Kernel::GraphicsState
>( newState
);
1865 if( (*sysBindings
)->graphicsState_
== NullPtr
< const Kernel::GraphicsState
>( ) )
1867 Kernel::GraphicsState
* newState
= new Kernel::GraphicsState( );
1868 newState
->cap_
= cap_
;
1869 (*sysBindings
)->graphicsState_
= RefCountPtr
< const Kernel::GraphicsState
>( newState
);
1873 Kernel::GraphicsState
* newState
= new Kernel::GraphicsState( *((*sysBindings
)->graphicsState_
) );
1875 if( newState
->cap_
!= Lang::CapStyle::CAP_UNDEFINED
)
1877 throw Exceptions::MultipleDynamicBind( id_
, bindingExpr_
->idLoc( ), Ast::THE_UNKNOWN_LOCATION
);
1880 newState
->cap_
= cap_
;
1881 (*sysBindings
)->graphicsState_
= RefCountPtr
< const Kernel::GraphicsState
>( newState
);
1885 Lang::CapStyleBinding::show( std::ostream
& os
) const
1887 os
<< Interaction::DYNAMIC_VARIABLE_PREFIX
<< id_
<< ":"
1888 << "<internal-enum>" ;
1892 Lang::CapStyleBinding::gcMark( Kernel::GCMarkedSet
& marked
)
1897 Kernel::CapStyleDynamicVariableProperties::CapStyleDynamicVariableProperties( const char * name
)
1898 : Kernel::DynamicVariableProperties( name
)
1901 Kernel::CapStyleDynamicVariableProperties::~CapStyleDynamicVariableProperties( )
1904 Kernel::VariableHandle
1905 Kernel::CapStyleDynamicVariableProperties::fetch( const Kernel::PassedDyn
& dyn
) const
1907 RefCountPtr
< const Kernel::GraphicsState
> graphicsState
= dyn
->getGraphicsState( );
1908 return Helpers::newValHandle( new Lang::CapStyle( graphicsState
->cap_
) );
1912 Kernel::CapStyleDynamicVariableProperties::makeBinding( Kernel::VariableHandle val
, const Ast::DynamicBindingExpression
* bindingExpr
, Kernel::EvalState
* evalState
) const
1916 RefCountPtr
< const Lang::CapStyle
> cap
= val
->tryVal
< const Lang::CapStyle
>( );
1917 Kernel::ContRef cont
= evalState
->cont_
;
1918 cont
->takeValue( Kernel::ValueRef( new Lang::CapStyleBinding( name_
, bindingExpr
, cap
->cap_
) ),
1922 catch( const NonLocalExit::NotThisType
& ball
)
1929 RefCountPtr
< const Lang::Void
> dummy
= val
->tryVal
< const Lang::Void
>( );
1930 Kernel::ContRef cont
= evalState
->cont_
;
1931 cont
->takeValue( Kernel::ValueRef( new Lang::CapStyleBinding( name_
, bindingExpr
, Lang::CapStyle::CAP_SAME
) ),
1935 catch( const NonLocalExit::NotThisType
& ball
)
1940 throw Exceptions::TypeMismatch( bindingExpr
->exprLoc( ), val
->getUntyped( )->getTypeName( ), Helpers::typeSetString( Lang::CapStyle::staticTypeName( ), Lang::Void::staticTypeName( ) ) );
1944 Lang::JoinStyleBinding::JoinStyleBinding( const char * id
, const Ast::DynamicBindingExpression
* bindingExpr
, const Lang::JoinStyle::ValueType
& join
)
1945 : bindingExpr_( bindingExpr
), join_( join
), id_( id
)
1948 Lang::JoinStyleBinding::~JoinStyleBinding( )
1952 Lang::JoinStyleBinding::bind( MapType
& bindings
, Kernel::SystemDynamicVariables
** sysBindings
) const
1954 if( *sysBindings
== 0 ) {
1955 *sysBindings
= new Kernel::SystemDynamicVariables( );
1956 Kernel::GraphicsState
* newState
= new Kernel::GraphicsState( );
1957 newState
->join_
= join_
;
1958 (*sysBindings
)->graphicsState_
= RefCountPtr
< const Kernel::GraphicsState
>( newState
);
1962 if( (*sysBindings
)->graphicsState_
== NullPtr
< const Kernel::GraphicsState
>( ) )
1964 Kernel::GraphicsState
* newState
= new Kernel::GraphicsState( );
1965 newState
->join_
= join_
;
1966 (*sysBindings
)->graphicsState_
= RefCountPtr
< const Kernel::GraphicsState
>( newState
);
1970 Kernel::GraphicsState
* newState
= new Kernel::GraphicsState( *((*sysBindings
)->graphicsState_
) );
1972 if( newState
->join_
!= Lang::JoinStyle::JOIN_UNDEFINED
)
1974 throw Exceptions::MultipleDynamicBind( id_
, bindingExpr_
->idLoc( ), Ast::THE_UNKNOWN_LOCATION
);
1977 newState
->join_
= join_
;
1978 (*sysBindings
)->graphicsState_
= RefCountPtr
< const Kernel::GraphicsState
>( newState
);
1982 Lang::JoinStyleBinding::show( std::ostream
& os
) const
1984 os
<< Interaction::DYNAMIC_VARIABLE_PREFIX
<< id_
<< ":"
1985 << "<internal-enum>" ;
1989 Lang::JoinStyleBinding::gcMark( Kernel::GCMarkedSet
& marked
)
1994 Kernel::JoinStyleDynamicVariableProperties::JoinStyleDynamicVariableProperties( const char * name
)
1995 : Kernel::DynamicVariableProperties( name
)
1998 Kernel::JoinStyleDynamicVariableProperties::~JoinStyleDynamicVariableProperties( )
2001 Kernel::VariableHandle
2002 Kernel::JoinStyleDynamicVariableProperties::fetch( const Kernel::PassedDyn
& dyn
) const
2004 RefCountPtr
< const Kernel::GraphicsState
> graphicsState
= dyn
->getGraphicsState( );
2005 return Helpers::newValHandle( new Lang::JoinStyle( graphicsState
->join_
) );
2009 Kernel::JoinStyleDynamicVariableProperties::makeBinding( Kernel::VariableHandle val
, const Ast::DynamicBindingExpression
* bindingExpr
, Kernel::EvalState
* evalState
) const
2013 RefCountPtr
< const Lang::JoinStyle
> join
= val
->tryVal
< const Lang::JoinStyle
>( );
2014 Kernel::ContRef cont
= evalState
->cont_
;
2015 cont
->takeValue( Kernel::ValueRef( new Lang::JoinStyleBinding( name_
, bindingExpr
, join
->join_
) ),
2019 catch( const NonLocalExit::NotThisType
& ball
)
2026 RefCountPtr
< const Lang::Void
> dummy
= val
->tryVal
< const Lang::Void
>( );
2027 Kernel::ContRef cont
= evalState
->cont_
;
2028 cont
->takeValue( Kernel::ValueRef( new Lang::JoinStyleBinding( name_
, bindingExpr
, Lang::JoinStyle::JOIN_SAME
) ),
2032 catch( const NonLocalExit::NotThisType
& ball
)
2037 throw Exceptions::TypeMismatch( bindingExpr
->exprLoc( ), val
->getUntyped( )->getTypeName( ), Helpers::typeSetString( Lang::JoinStyle::staticTypeName( ), Lang::Void::staticTypeName( ) ) );
2041 Lang::BlendModeBinding::BlendModeBinding( const char * id
, const Ast::DynamicBindingExpression
* bindingExpr
, const Lang::BlendMode::ValueType
& blend
)
2042 : bindingExpr_( bindingExpr
), blend_( blend
), id_( id
)
2045 Lang::BlendModeBinding::~BlendModeBinding( )
2049 Lang::BlendModeBinding::bind( MapType
& bindings
, Kernel::SystemDynamicVariables
** sysBindings
) const
2051 if( *sysBindings
== 0 ) {
2052 *sysBindings
= new Kernel::SystemDynamicVariables( );
2053 Kernel::GraphicsState
* newState
= new Kernel::GraphicsState( );
2054 newState
->blend_
= blend_
;
2055 (*sysBindings
)->graphicsState_
= RefCountPtr
< const Kernel::GraphicsState
>( newState
);
2059 if( (*sysBindings
)->graphicsState_
== NullPtr
< const Kernel::GraphicsState
>( ) )
2061 Kernel::GraphicsState
* newState
= new Kernel::GraphicsState( );
2062 newState
->blend_
= blend_
;
2063 (*sysBindings
)->graphicsState_
= RefCountPtr
< const Kernel::GraphicsState
>( newState
);
2067 Kernel::GraphicsState
* newState
= new Kernel::GraphicsState( *((*sysBindings
)->graphicsState_
) );
2069 if( newState
->blend_
!= Lang::BlendMode::BLEND_UNDEFINED
)
2071 throw Exceptions::MultipleDynamicBind( id_
, bindingExpr_
->idLoc( ), Ast::THE_UNKNOWN_LOCATION
);
2074 newState
->blend_
= blend_
;
2075 (*sysBindings
)->graphicsState_
= RefCountPtr
< const Kernel::GraphicsState
>( newState
);
2079 Lang::BlendModeBinding::show( std::ostream
& os
) const
2081 os
<< Interaction::DYNAMIC_VARIABLE_PREFIX
<< id_
<< ":"
2082 << "<internal-enum>" ;
2086 Lang::BlendModeBinding::gcMark( Kernel::GCMarkedSet
& marked
)
2091 Kernel::BlendModeDynamicVariableProperties::BlendModeDynamicVariableProperties( const char * _name
)
2092 : Kernel::DynamicVariableProperties( _name
)
2095 Kernel::BlendModeDynamicVariableProperties::~BlendModeDynamicVariableProperties( )
2098 Kernel::VariableHandle
2099 Kernel::BlendModeDynamicVariableProperties::fetch( const Kernel::PassedDyn
& dyn
) const
2101 RefCountPtr
< const Kernel::GraphicsState
> graphicsState
= dyn
->getGraphicsState( );
2102 return Helpers::newValHandle( new Lang::BlendMode( graphicsState
->blend_
) );
2106 Kernel::BlendModeDynamicVariableProperties::makeBinding( Kernel::VariableHandle val
, const Ast::DynamicBindingExpression
* bindingExpr
, Kernel::EvalState
* evalState
) const
2110 RefCountPtr
< const Lang::BlendMode
> blend
= val
->tryVal
< const Lang::BlendMode
>( );
2111 Kernel::ContRef cont
= evalState
->cont_
;
2112 cont
->takeValue( Kernel::ValueRef( new Lang::BlendModeBinding( name_
, bindingExpr
, blend
->mode_
) ),
2116 catch( const NonLocalExit::NotThisType
& ball
)
2123 RefCountPtr
< const Lang::Void
> dummy
= val
->tryVal
< const Lang::Void
>( );
2124 Kernel::ContRef cont
= evalState
->cont_
;
2125 cont
->takeValue( Kernel::ValueRef( new Lang::BlendModeBinding( name_
, bindingExpr
, Lang::BlendMode::BLEND_SAME
) ),
2129 catch( const NonLocalExit::NotThisType
& ball
)
2134 throw Exceptions::TypeMismatch( bindingExpr
->exprLoc( ), val
->getUntyped( )->getTypeName( ), Helpers::typeSetString( Lang::BlendMode::staticTypeName( ), Lang::Void::staticTypeName( ) ) );
2139 Lang::ColorSpace::ColorSpace( )
2142 Lang::ColorSpace::~ColorSpace( )
2145 RefCountPtr
< const Lang::Class
> Lang::ColorSpace::TypeID( new Lang::SystemFinalClass( strrefdup( "ColorSpace" ) ) );
2146 TYPEINFOIMPL( ColorSpace
);
2150 Lang::InheritedColorSpace::InheritedColorSpace( )
2153 Lang::InheritedColorSpace::~InheritedColorSpace( )
2156 RefCountPtr
< SimplePDF::PDF_Name
>
2157 Lang::InheritedColorSpace::name( ) const
2159 throw Exceptions::InternalError( "InheritedColorSpace::name was invoked." );
2163 Lang::InheritedColorSpace::numberOfComponents( ) const
2165 throw Exceptions::InternalError( "InheritedColorSpace::numerOfComponents was invoked." );
2169 Lang::InheritedColorSpace::containsColor( const Lang::Color
* col
) const
2171 throw Exceptions::InternalError( "InheritedColorSpace::containsColor was invoked." );
2175 Kernel::Auto_qQ::Auto_qQ( Kernel::GraphicsState
* graphicsState
, Kernel::TextState
* textState
, std::ostream
& os
, bool active
)
2176 : graphicsState_( graphicsState
), graphicsEnterState_( 0 ), textState_( textState
), textEnterState_( 0 ), os_( os
), activated_( false )
2185 Kernel::Auto_qQ::activate( )
2189 throw Exceptions::InternalError( "Multiple activation of Auto_qQ." );
2192 graphicsEnterState_
= new Kernel::GraphicsState( *graphicsState_
);
2193 textEnterState_
= new Kernel::TextState( *textState_
);
2194 os_
<< "q" << std::endl
;
2197 Kernel::Auto_qQ::~Auto_qQ( )
2201 *graphicsState_
= *graphicsEnterState_
;
2202 delete graphicsEnterState_
;
2203 *textState_
= *textEnterState_
;
2204 delete textEnterState_
;
2205 os_
<< "Q" << std::endl
;