The SKIRT project
advanced radiative transfer for astrophysics
ShapeCanvas Class Reference

#include <ShapeCanvas.hpp>

Inheritance diagram for ShapeCanvas:

Public Member Functions

void paintAndSave (string outPath)
string savePath () const
Shapeshape () const
Public Member Functions inherited from ShapeItem
virtual void paint ()
Public Member Functions inherited from Item
 Item (const Item &)=delete
virtual ~Item ()
void addChild (Item *child)
const vector< Item * > & children () const
virtual void clearItemListProperty (const PropertyDef *property)
void destroyChild (Item *child)
virtual bool getBoolProperty (const PropertyDef *property) const
virtual vector< double > getDoubleListProperty (const PropertyDef *property) const
virtual double getDoubleProperty (const PropertyDef *property) const
virtual string getEnumProperty (const PropertyDef *property) const
virtual int getIntProperty (const PropertyDef *property) const
virtual vector< Item * > getItemListProperty (const PropertyDef *property) const
virtual ItemgetItemProperty (const PropertyDef *property) const
virtual string getStringProperty (const PropertyDef *property) const
int getUtilityProperty (string name) const
virtual void insertIntoItemListProperty (const PropertyDef *property, int index, Item *item)
Itemoperator= (const Item &)=delete
Itemparent () const
virtual void removeFromItemListProperty (const PropertyDef *property, int index)
virtual void setBoolProperty (const PropertyDef *property, bool value)
virtual void setDoubleListProperty (const PropertyDef *property, vector< double > value)
virtual void setDoubleProperty (const PropertyDef *property, double value)
virtual void setEnumProperty (const PropertyDef *property, string value)
virtual void setIntProperty (const PropertyDef *property, int value)
virtual void setItemProperty (const PropertyDef *property, Item *item)
virtual void setStringProperty (const PropertyDef *property, string value)
void setUtilityProperty (string name, int value)
virtual string type () const

Protected Member Functions

 ShapeCanvas ()
void drawLine (double x1, double y1, double x2, double y2) override
void popState () override
void pushState () override
void setColor (double r, double g, double b) override
void setWidth (double w) override
Protected Member Functions inherited from ShapeItem
 ShapeItem ()
virtual void paintSelf ()
Protected Member Functions inherited from Item
 Item ()

Private Types

using BaseType
using ItemType

Private Attributes

GraphicsStateCanvas * _canvas
string _savePath
Shape_shape

Friends

class ItemRegistry

Detailed Description

The ShapeCanvas class is a shape item that manages a canvas on which the shapes in a hierarchy can be drawn, and provides facilities to perform such drawing. The root of a run-time shape hierarchy must be an instance of the ShapeCanvas class.

Constructor & Destructor Documentation

◆ ShapeCanvas()

ShapeCanvas::ShapeCanvas ( )
inlineprotected

Default constructor for concrete Item subclass ShapeCanvas: "the root of a shape hierarchy, managing the canvas".

Member Function Documentation

◆ drawLine()

void ShapeCanvas::drawLine ( double x1,
double y1,
double x2,
double y2 )
overrideprotectedvirtual

This function draws a line on the canvas. The line is drawn using the current graphics state color and width from the point (x1,y1) to the point (x2,y2). The coordinates are specified in in a frame where the lower left corner of the canvas is at (0 m, 0 m) and the upper right corner of the canvas is at (1 m, 1 m). Segments of the line lying outside of the canvas are clipped away.

Reimplemented from ShapeItem.

◆ paintAndSave()

void ShapeCanvas::paintAndSave ( string outPath)

This function paints the shape hierarchy held by the receiving item onto its canvas, and then saves the result to the specified output file. Call the paintAndSave() function of a shape canvas rather than the paint() function inherited from the Shape class.

◆ popState()

void ShapeCanvas::popState ( )
overrideprotectedvirtual

This function pops the graphics state of the canvas from the graphics state stack, restoring the most recently pushed state.

Reimplemented from ShapeItem.

◆ pushState()

void ShapeCanvas::pushState ( )
overrideprotectedvirtual

This function pushes the graphics state of the canvas on the graphics state stack.

Reimplemented from ShapeItem.

◆ savePath()

string ShapeCanvas::savePath ( ) const
inline

This function returns the value of the discoverable string property savePath: "the path of the output file when saving this canvas".

This property is required only if the Boolean expression "false" evaluates to true after replacing the names by true or false depending on their presence.

This property is displayed only if the Boolean expression "false" evaluates to true after replacing the names by true or false depending on their presence.

◆ setColor()

void ShapeCanvas::setColor ( double r,
double g,
double b )
overrideprotectedvirtual

This function sets the color in the graphics state. The color is specified as three RGB components ranging from 0 (no intensity) to 1 (maximum intensity). If a component value is out of range, the result is undefined.

Reimplemented from ShapeItem.

◆ setWidth()

void ShapeCanvas::setWidth ( double w)
overrideprotectedvirtual

This function sets the line width in the graphics state. The line width is specified in units where the canvas size equals 1, and should be greater than 0 and smaller than 1. If the value is out of range, the result is undefined.

Reimplemented from ShapeItem.

◆ shape()

Shape * ShapeCanvas::shape ( ) const
inline

This function returns the value of the discoverable item property shape: "the top-level shape in this hierarchy".

The default value for this property is given by the conditional value expression "ShapeGroup".


The documentation for this class was generated from the following file: