Skip to content

Commit

Permalink
[Vectors] Reorganised source files
Browse files Browse the repository at this point in the history
  • Loading branch information
paul-manias committed Feb 23, 2025
1 parent 231d9a1 commit c34cd17
Show file tree
Hide file tree
Showing 18 changed files with 68 additions and 30 deletions.
2 changes: 1 addition & 1 deletion docs/xml/modules/classes/vectorcolour.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<description>
<p>VectorColour is a stub class for exclusive use with the Vector module's <function module="Vector">DrawPath</function> function, for use in either the <code>StrokeStyle</code> or <code>FillStyle</code> parameters. VectorColour allows the path to be drawn with a solid colour, as specified in the <fl>Red</fl>, <fl>Green</fl>, <fl>Blue</fl> and <fl>Alpha</fl> fields.</p></description>
<source>
<file path="defs/">colour.cpp</file>
<file path="painters/">colour.cpp</file>
</source>
</info>

Expand Down
2 changes: 1 addition & 1 deletion docs/xml/modules/classes/vectorgradient.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<p>Any vector within the target scene will be able to utilise the gradient for filling or stroking by referencing its name through the <class name="Vector" field="Fill">Vector.Fill</class> and <class name="Vector" field="Stroke">Vector.Stroke</class> fields. For instance 'url(#redgradient)'.</p>
<p>It is strongly recommended that the VectorGradient is owned by the <class name="VectorScene">VectorScene</class> that is handling the definition. This will ensure that the VectorGradient is de-allocated when the scene is destroyed.</p></description>
<source>
<file path="defs/">gradient.cpp</file>
<file path="painters/">gradient.cpp</file>
</source>
</info>

Expand Down
2 changes: 1 addition & 1 deletion docs/xml/modules/classes/vectorimage.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<p>It is strongly recommended that the VectorImage is owned by the <class name="VectorScene">VectorScene</class> that is handling the definition. This will ensure that the VectorImage is de-allocated when the scene is destroyed.</p>
<p>NOTE: For the rendering of vectors as flattened images, use <class name="VectorPattern">VectorPattern</class>.</p></description>
<source>
<file path="defs/">image.cpp</file>
<file path="painters/">image.cpp</file>
</source>
</info>

Expand Down
2 changes: 1 addition & 1 deletion docs/xml/modules/classes/vectorpattern.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<p>A special use case is made for patterns that are applied as a fill operation in <class name="VectorViewport">VectorViewport</class> objects. In this case the renderer will dynamically render the pattern as a background within the viewport. This ensures that the pattern is rendered at maximum fidelity whenever it is used, and not affected by bitmap clipping restrictions. It should be noted that this means the image caching feature will be disabled.</p>
<p>It is strongly recommended that the VectorPattern is owned by the <class name="VectorScene">VectorScene</class> that is handling the definition. This will ensure that the VectorPattern is deallocated when the scene is destroyed.</p></description>
<source>
<file path="defs/">pattern.cpp</file>
<file path="painters/">pattern.cpp</file>
</source>
</info>

Expand Down
2 changes: 1 addition & 1 deletion docs/xml/modules/classes/vectortransition.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
</pre>
<p>Transitions are most effective when used in conjunction with the morph feature in the <class name="Vector">Vector</class> class.</p></description>
<source>
<file path="defs/">transition.cpp</file>
<file path="transformers/">transition.cpp</file>
</source>
</info>

Expand Down
25 changes: 19 additions & 6 deletions docs/xml/modules/core.xml
Original file line number Diff line number Diff line change
Expand Up @@ -589,13 +589,14 @@ typedef struct { EVENTID EventID; OBJECTID TaskID; OBJECTID ProcessID; } evTaskR
<function>
<name>FindClass</name>
<category>Objects</category>
<comment>Returns all class objects for a given class ID.</comment>
<comment>Returns the internal MetaClass for a given class ID.</comment>
<prototype>objMetaClass * FindClass(CLASSID ClassID)</prototype>
<input>
<param type="CLASSID" name="ClassID">A class ID such as one retrieved from <function>ResolveClassName</function>.</param>
</input>
<description>
<p>This function will find a specific class by ID and return its <class name="MetaClass">MetaClass</class>. If the class is not in memory, the internal dictionary is checked to discover a module binary registered with that ID. If this succeeds, the module is loaded into memory and the class will be returned. In any event of failure, <code>NULL</code> is returned.</p>
<p>This function will find a specific class by ID and return its <class name="MetaClass">MetaClass</class>. If the class is not already loaded, the internal dictionary is checked to discover a module binary registered with that ID. If this succeeds, the module is loaded into memory and the correct MetaClass will be returned.</p>
<p>In any event of failure, <code>NULL</code> is returned.</p>
<p>If the ID of a named class is not known, call <function>ResolveClassName</function> first and pass the resulting ID to this function.</p>
</description>
<result type="objMetaClass *">Returns a pointer to the <class name="MetaClass">MetaClass</class> structure that has been found as a result of the search, or <code>NULL</code> if no matching class was found.</result>
Expand Down Expand Up @@ -1146,7 +1147,7 @@ parasol:pictures/ parasol:documents parasol:documents (Existing documents
<function>
<name>NotifySubscribers</name>
<category>Objects</category>
<comment>Used to send notification messages to action subscribers.</comment>
<comment>Send a notification event to action subscribers.</comment>
<prototype>void NotifySubscribers(OBJECTPTR Object, AC Action, APTR Args, ERR Error)</prototype>
<input>
<param type="OBJECTPTR" name="Object">Pointer to the object that is to receive the notification message.</param>
Expand All @@ -1155,9 +1156,21 @@ parasol:pictures/ parasol:documents parasol:documents (Existing documents
<param type="ERR" name="Error">The error code that is associated with the action result.</param>
</input>
<description>
<p>This function can be used by classes that need total control over notification management. It allows an action to notify its subscribers manually, rather than deferring to the system default of notifying on return.</p>
<p>Another useful feature is that parameter values can be customised for the recipients.</p>
<p>NOTE: Calling NotifySubscribers() does nothing to prevent the core from sending out an action notification as it normally would, thus causing duplication. To prevent this, the client must logical-or the return code of the action function with <code>ERR::Notified</code>, e.g. <code>ERR::Okay|ERR::Notified</code>.</p>
<p>This function can be used by classes that need fine-tuned control over notification events, as managed by the <function>SubscribeAction</function> function. Normally the Core will automatically notify subscribers after an action is executed. Using NotifySubscribers(), the client can instead manually notify subscribers during the execution of the action.</p>
<p>Another useful aspect is that the client can control the parameter values that are passed on to the subscribers.</p>
<p>NOTE: The use of NotifySubscribers() does not prevent the core from sending out an action notification as it normally would, which will cause duplication. To prevent this, the client must logical-or the return code of the action function with <code>ERR::Notified</code>, e.g. <code>ERR::Okay|ERR::Notified</code>.</p>
<p>In the following example you can see how the <class name="Surface">Surface</class> class uses NotifySubscribers() to convert a Move event to a Redimension event. The parameter values are customised to support this, and the function returns <code>ERR::Notified</code> to prevent the core from sending out a Move notification.</p>
<pre>ERR SURFACE_Move(extSurface *Self, struct acMove *Args)
{
if (!Args) return ERR::NullArgs|ERR::Notified;

...

struct acRedimension redimension = { Self-&gt;X, Self-&gt;Y, 0, Self-&gt;Width, Self-&gt;Height, 0 };
NotifySubscribers(Self, AC::Redimension, &amp;redimension, ERR::Okay);
return ERR::Okay|ERR::Notified;
}
</pre>
</description>
</function>

Expand Down
41 changes: 31 additions & 10 deletions src/core/lib_objects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -748,11 +748,13 @@ OBJECTPTR ParentContext(void)
/*********************************************************************************************************************
-FUNCTION-
FindClass: Returns all class objects for a given class ID.
FindClass: Returns the internal MetaClass for a given class ID.
This function will find a specific class by ID and return its @MetaClass. If the class is not in memory, the internal
dictionary is checked to discover a module binary registered with that ID. If this succeeds, the module is loaded
into memory and the class will be returned. In any event of failure, `NULL` is returned.
This function will find a specific class by ID and return its @MetaClass. If the class is not already loaded, the
internal dictionary is checked to discover a module binary registered with that ID. If this succeeds, the module is
loaded into memory and the correct MetaClass will be returned.
In any event of failure, `NULL` is returned.
If the ID of a named class is not known, call ~ResolveClassName() first and pass the resulting ID to this function.
Expand Down Expand Up @@ -1361,17 +1363,36 @@ ERR NewObject(CLASSID ClassID, NF Flags, OBJECTPTR *Object)
/*********************************************************************************************************************
-FUNCTION-
NotifySubscribers: Used to send notification messages to action subscribers.
NotifySubscribers: Send a notification event to action subscribers.
This function can be used by classes that need total control over notification management. It allows an action to
notify its subscribers manually, rather than deferring to the system default of notifying on return.
This function can be used by classes that need fine-tuned control over notification events, as managed by the
~SubscribeAction() function. Normally the Core will automatically notify subscribers after an action
is executed. Using NotifySubscribers(), the client can instead manually notify subscribers during the
execution of the action.
Another useful feature is that parameter values can be customised for the recipients.
Another useful aspect is that the client can control the parameter values that are passed on to the subscribers.
NOTE: Calling NotifySubscribers() does nothing to prevent the core from sending out an action notification as it
normally would, thus causing duplication. To prevent this, the client must logical-or the return code of
NOTE: The use of NotifySubscribers() does not prevent the core from sending out an action notification as it
normally would, which will cause duplication. To prevent this, the client must logical-or the return code of
the action function with `ERR::Notified`, e.g. `ERR::Okay|ERR::Notified`.
In the following example you can see how the @Surface class uses NotifySubscribers() to convert a Move event to a
Redimension event. The parameter values are customised to support this, and the function returns `ERR::Notified` to
prevent the core from sending out a Move notification.
<pre>
ERR SURFACE_Move(extSurface *Self, struct acMove *Args)
{
if (!Args) return ERR::NullArgs|ERR::Notified;
...
struct acRedimension redimension = { Self->X, Self->Y, 0, Self->Width, Self->Height, 0 };
NotifySubscribers(Self, AC::Redimension, &redimension, ERR::Okay);
return ERR::Okay|ERR::Notified;
}
</pre>
-INPUT-
obj Object: Pointer to the object that is to receive the notification message.
int(AC) Action: The action ID for notification.
Expand Down
3 changes: 2 additions & 1 deletion src/vector/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ target_sources (${MOD} PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/vector_functions.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/filters/filter.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/scene/scene.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/defs/defs.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/painters/painters.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/transformers/transformers.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/colourmaps.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/agg/src/agg_arc.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/agg/src/agg_arrowhead.cpp"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@
#include "colour.cpp"
#include "gradient.cpp"
#include "image.cpp"
#include "pattern.cpp"
#include "transition.cpp"
#include "pattern.cpp"
File renamed without changes.
2 changes: 1 addition & 1 deletion src/vector/scene/scene_fill.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ static void fill_pattern(VectorState &State, const TClipRectangle<double> &Bound

//target_width *= Transform.sx;
//target_height *= Transform.sy;

LONG page_width = F2T(target_width);
LONG page_height = F2T(target_height);

Expand Down
4 changes: 4 additions & 0 deletions src/vector/transformers/transformers.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

//#include "../vector.h"

#include "transition.cpp"
File renamed without changes.
10 changes: 5 additions & 5 deletions src/vector/vector.fdl
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ module({ name="Vector", copyright="Paul Manias © 2010-2025", version=1.0, times
// Use SET_VECTOR_COLOUR() to configure the RGB values in VectorColour

class("VectorColour", {
src="defs/colour.cpp",
src="painters/colour.cpp",
comment="VectorColour is a basic stub class that is used for the DrawPath() routine when filling or stroking solid colour values"
}, [[
double Red
Expand All @@ -392,7 +392,7 @@ module({ name="Vector", copyright="Paul Manias © 2010-2025", version=1.0, times
]])

class('VectorTransition', {
src='defs/transition.cpp',
src='transformers/transition.cpp',
references={ 'Transition' },
comment="Transitions are used to gradually apply transforms over distance."
})
Expand All @@ -417,7 +417,7 @@ module({ name="Vector", copyright="Paul Manias © 2010-2025", version=1.0, times
int(VSM) SampleMethod # Method to use for resampling images and patterns.
]])

class("VectorImage", { src="defs/image.cpp" }, [[
class("VectorImage", { src="painters/image.cpp" }, [[
double X # Starting horizontal coordinate
double Y # Starting vertical coordinate
obj(Picture) Picture
Expand All @@ -428,7 +428,7 @@ module({ name="Vector", copyright="Paul Manias © 2010-2025", version=1.0, times
int(ARF) AspectRatio # Defines how the referenced image should fit in the boundary of its target shape.
]])

class("VectorPattern", { src="defs/pattern.cpp" }, [[
class("VectorPattern", { src="painters/pattern.cpp" }, [[
double X # Starting horizontal coordinate
double Y # Starting vertical coordinate
double Width # Width of the canvas
Expand All @@ -442,7 +442,7 @@ module({ name="Vector", copyright="Paul Manias © 2010-2025", version=1.0, times
int(DMF) Dimensions # Flags for the dimension values.
]])

class("VectorGradient", { src="defs/gradient.cpp", output="defs/gradient_def.c" }, [[
class("VectorGradient", { src="painters/gradient.cpp", output="painters/gradient_def.c" }, [[
double X1 # Starting X coordinate of the gradient 'line'
double Y1 # Starting Y coordinate of the gradient 'line'
double X2 # Ending X of the gradient 'line'
Expand Down

0 comments on commit c34cd17

Please sign in to comment.