HDK
|
#include <OP_NetworkBox.h>
Public Member Functions | |
OP_NetworkBox (const UT_String &name, OP_Network *net) | |
~OP_NetworkBox () override | |
void | setXY (fpreal x, fpreal y) override |
void | setXY (fpreal x, fpreal y, bool force, bool propagate_parent_event) |
fpreal | getX () const override |
fpreal | getY () const override |
void | setW (fpreal w, bool force=false) |
void | setH (fpreal h, bool force=false) |
bool | setWWithBoundsChecks (fpreal w) |
bool | setHWithBoundsChecks (fpreal h) |
fpreal | getW () const override |
fpreal | getH () const override |
fpreal | getMaximizedW () const |
fpreal | getMaximizedH () const |
void | resizeToFit () |
void | resizeToFit (fpreal xmin, fpreal ymin, fpreal xmax, fpreal ymax) |
bool | setName (const UT_String &name) |
const UT_String & | getItemName () const override |
bool | setItemName (const UT_String &name) override |
void | setComment (const UT_StringHolder &comment) |
The comment that is used to describe the network box. More... | |
const UT_StringHolder & | getComment () const |
int | getNitems () const |
int | getNexposedItems () const |
OP_NetworkBoxItem * | getItem (int idx) const |
void | getItems (OP_ItemTypeMask item_mask, OP_NetworkBoxItemList &list, bool include_hidden=true, bool recursive=true, bool picked_only=false) const |
Collect items base on their type, possibly recursively. More... | |
void | getNodes (OP_NodeList &list, bool include_hidden=true, bool recursive=true, bool picked_only=false) const |
exint | countItems (OP_ItemTypeMask item_mask, bool include_hidden=true, bool recursive=true, bool picked_only=false) const |
template<typename F > | |
void | traverseItems (OP_ItemTypeMask item_mask, bool include_hidden, bool recursive, bool picked_only, const F &functor) const |
bool | addItem (OP_NetworkBoxItem *item, bool propagate_parent_event=true, bool resize_to_fit=true) |
bool | addItems (OP_NetworkBoxItemList &items) |
bool | removeItem (OP_NetworkBoxItem *item, bool propagate_parent_event=true, bool do_reparent=false, bool save_undo=true) |
Remove the item from this box. The item's owner box is set to NULL. More... | |
bool | removeItems (OP_NetworkBoxItemList &items) |
bool | removeAllItems (bool do_reparent=false) |
bool | setContents (OP_NetworkBoxItemList &items, bool snap_to_bounds) |
bool | getPicked () const override |
Returns true if this box is currently picked. More... | |
bool | setPicked (bool on_off, bool propagate_parent_event=true) override |
bool | getMinimized () const |
Get whether this box is currently minimized. More... | |
bool | setMinimized (bool isminimized, bool update_position, bool propagate_parent_event) |
fpreal | getAlpha () const |
Get the alpha value for this drawing network box. More... | |
bool | setAlpha (fpreal alpha) |
Set the alpha value for drawing this network box. More... | |
void | setMarked (bool flag) |
bool | getMarked () |
void | getItemBounds (fpreal &x1, fpreal &y1, fpreal &x2, fpreal &y2, bool incl_buff_border=true) const |
void | snapToBounds (bool incl_buff_border=true) |
int | save (std::ostream &os, const OP_SaveFlags &flags) |
Save the attributes of this network box to the ostream. More... | |
bool | load (UT_IStream &is) |
void | resolveLoadedOwnerName () |
OP_ItemType | getItemType () const override |
Returns my item type (OP_ITEMTYPE_NETWORKBOX) More... | |
const OP_Stat & | getStat () const |
OP_Stat & | getStat () |
OP_Network * | getParentNetwork () const override |
Return the network i'm in. More... | |
void | getSaveFlagsString (UT_String &cmd, const char *flags, bool save_to_hip) const |
int | saveCommand (std::ostream &os, const char *name, int dogeneral) const |
int | getUniqueId () const |
int64 | getItemUniqueId () const override |
Functions to get hip-file-unique ids for any item type. More... | |
void | setResizing (bool resizing) |
bool | getResizing () const |
void | setAutoFit (bool autofit) |
Accessors for the auto fit flag on the network box. More... | |
bool | getAutoFit () const |
int64 | getMemoryUsage (bool inclusive) const |
Returns the amount of memory owned by this OP_NetworkBox. More... | |
Public Member Functions inherited from OP_NetworkBoxItem | |
OP_NetworkBoxItem () | |
virtual | ~OP_NetworkBoxItem () |
bool | setXYWithBoundsChecks (fpreal x, fpreal y) |
void | validateSafeBounds (fpreal &x, fpreal &y) |
void | validateSafeBounds (fpreal &x, fpreal &y, fpreal &w, fpreal &h) |
void | moveToGoodPosition (bool relativetoinputs=true, bool moveinputs=true, bool moveoutputs=true, bool moveunconnected=true) |
void | setOwnerBox (OP_NetworkBox *box) |
OP_NetworkBox * | getOwnerBox () const |
bool | hasOwnerBox (const OP_NetworkBoxItem *item) const |
OP_NetworkBox * | getMinimizedOwnerBox () const |
void | getPathFromParent (UT_String &str, const OP_Node *parent) const |
void | getPathFromParent (UT_WorkBuffer &str, const OP_Node *parent) const |
void | getRelativePathTo (const OP_NetworkBoxItem *base_item, UT_String &result) const |
Returns the path of this item relative to 'base_item'. More... | |
virtual UT_Color | getColor () const |
Accessors for color used in the network view. More... | |
virtual bool | setColor (const UT_Color &color) |
virtual bool | getItemExpose () const |
virtual void | setItemExpose (bool expose) |
OP_Network * | getCreator () const |
OP_Network * | getCodeCreator () const |
void | getConnectedItems (OP_NetworkBoxItemList &connected, bool inputs, bool recursive, bool include_this_item) const |
Fills an array with all network box items connected to this item. More... | |
int64 | getMemoryUsage (bool inclusive) const |
Static Public Member Functions | |
static OP_NetworkBox * | lookupNetworkBox (int unique_id) |
static const UT_Color & | defaultColor () |
Control the default color used on new network boxes. More... | |
static void | setDefaultColor (const UT_Color *color) |
static void | clearAllPendingUndoFlags () |
Clear undo flags on all network boxes. More... | |
Static Public Member Functions inherited from OP_NetworkBoxItem | |
static fpreal | getMaxSafeX () |
The following methods return the safe extents of the position of items. More... | |
static fpreal | getMinSafeX () |
static fpreal | getMaxSafeY () |
static fpreal | getMinSafeY () |
static OP_NetworkBoxItem * | lookupItem (const OP_ItemType &type, int64 id) |
static OP_NetworkBoxItem * | lookupItem (const OP_ItemId &id) |
Additional Inherited Members | |
Protected Member Functions inherited from UT_NonCopyableNS::UT_NonCopyable | |
UT_NonCopyable ()=default | |
~UT_NonCopyable ()=default | |
UT_NonCopyable (const UT_NonCopyable &)=delete | |
UT_NonCopyable & | operator= (const UT_NonCopyable &)=delete |
Protected Attributes inherited from OP_NetworkBoxItem | |
UT_Color | myColor |
Definition at line 54 of file OP_NetworkBox.h.
OP_NetworkBox::OP_NetworkBox | ( | const UT_String & | name, |
OP_Network * | net | ||
) |
Create a network box with the specified name. If a duplicate name is passed in, it will be altered to make it unique in the network.
|
override |
bool OP_NetworkBox::addItem | ( | OP_NetworkBoxItem * | item, |
bool | propagate_parent_event = true , |
||
bool | resize_to_fit = true |
||
) |
Add an item to this box. If the item was previously in another netbox, we remove it from there before we add it here. If 'resize_to_fit' is set to true, we'll resize if necessary to fit our contents after the item is added - this option should always be on, except when the undo mechanism requires some extra control to restore states properly
bool OP_NetworkBox::addItems | ( | OP_NetworkBoxItemList & | items | ) |
|
static |
Clear undo flags on all network boxes.
exint OP_NetworkBox::countItems | ( | OP_ItemTypeMask | item_mask, |
bool | include_hidden = true , |
||
bool | recursive = true , |
||
bool | picked_only = false |
||
) | const |
|
static |
Control the default color used on new network boxes.
fpreal OP_NetworkBox::getAlpha | ( | ) | const |
Get the alpha value for this drawing network box.
bool OP_NetworkBox::getAutoFit | ( | ) | const |
|
inline |
Definition at line 136 of file OP_NetworkBox.h.
|
overridevirtual |
Implements OP_NetworkBoxItem.
OP_NetworkBoxItem* OP_NetworkBox::getItem | ( | int | idx | ) | const |
void OP_NetworkBox::getItemBounds | ( | fpreal & | x1, |
fpreal & | y1, | ||
fpreal & | x2, | ||
fpreal & | y2, | ||
bool | incl_buff_border = true |
||
) | const |
Calculate the smallest bounds we're willing to accept as our size given our contents. By default, 'incl_buff_border' is set to add a small buffer border to make the layout look pretty. NOTE: If we contain no items, we return an inverted bounding box, see implementation for further details.
|
inlineoverridevirtual |
Basically the same as OP_Node::getName(), but abstracted to a higher level so we can call it on all items.
Implements OP_NetworkBoxItem.
Definition at line 129 of file OP_NetworkBox.h.
void OP_NetworkBox::getItems | ( | OP_ItemTypeMask | item_mask, |
OP_NetworkBoxItemList & | list, | ||
bool | include_hidden = true , |
||
bool | recursive = true , |
||
bool | picked_only = false |
||
) | const |
Collect items base on their type, possibly recursively.
|
overridevirtual |
Returns my item type (OP_ITEMTYPE_NETWORKBOX)
Implements OP_NetworkBoxItem.
|
inlineoverridevirtual |
Functions to get hip-file-unique ids for any item type.
Implements OP_NetworkBoxItem.
Definition at line 292 of file OP_NetworkBox.h.
bool OP_NetworkBox::getMarked | ( | ) |
fpreal OP_NetworkBox::getMaximizedH | ( | ) | const |
fpreal OP_NetworkBox::getMaximizedW | ( | ) | const |
Return the full maximized size of the netbox, regardless of whether the netbox is currently maximized or minimized
int64 OP_NetworkBox::getMemoryUsage | ( | bool | inclusive | ) | const |
Returns the amount of memory owned by this OP_NetworkBox.
bool OP_NetworkBox::getMinimized | ( | ) | const |
Get whether this box is currently minimized.
int OP_NetworkBox::getNexposedItems | ( | ) | const |
int OP_NetworkBox::getNitems | ( | ) | const |
Items which are contained in this box can be OP_Nodes, OP_IndirectInputs or OP_NetworkBoxes. They are all encapsulated in the OP_NetworkBoxItem class.
void OP_NetworkBox::getNodes | ( | OP_NodeList & | list, |
bool | include_hidden = true , |
||
bool | recursive = true , |
||
bool | picked_only = false |
||
) | const |
|
overridevirtual |
Return the network i'm in.
Implements OP_NetworkBoxItem.
|
overridevirtual |
Returns true if this box is currently picked.
Implements OP_NetworkBoxItem.
bool OP_NetworkBox::getResizing | ( | ) | const |
void OP_NetworkBox::getSaveFlagsString | ( | UT_String & | cmd, |
const char * | flags, | ||
bool | save_to_hip | ||
) | const |
Sets 'cmd' to be a string containing our values for the flags specified by 'flags'. If 'flags' == NULL, then we output values for all of our flags.
|
inline |
Definition at line 268 of file OP_NetworkBox.h.
|
inline |
Definition at line 269 of file OP_NetworkBox.h.
|
inline |
Definition at line 291 of file OP_NetworkBox.h.
|
overridevirtual |
Gives you the w/h of the netbox as you see it, meaning if the netbox is minimized, you get the minimized size.
Implements OP_NetworkBoxItem.
|
overridevirtual |
Get the position of this box. Units are absolute, as opposed to relative units found in OPUI.
Implements OP_NetworkBoxItem.
|
overridevirtual |
Implements OP_NetworkBoxItem.
bool OP_NetworkBox::load | ( | UT_IStream & | is | ) |
Load the contents of the stream into the attributes of this network box; if binary is nonzero, load in binary mode. Loading doesn't send the OP_NETWORKBOX_CREATED message to the network; the caller is responsible for doing that.
|
static |
Each netbox has a unique id. This is used primarily for undos, as we also keep a list of netboxes in order of id, so lookup by id becomes quite quick.
bool OP_NetworkBox::removeAllItems | ( | bool | do_reparent = false | ) |
bool OP_NetworkBox::removeItem | ( | OP_NetworkBoxItem * | item, |
bool | propagate_parent_event = true , |
||
bool | do_reparent = false , |
||
bool | save_undo = true |
||
) |
Remove the item from this box. The item's owner box is set to NULL.
bool OP_NetworkBox::removeItems | ( | OP_NetworkBoxItemList & | items | ) |
void OP_NetworkBox::resizeToFit | ( | ) |
Using the netbox's current X,Y, width, and height data, resize the netbox if necessary to fit its contents. Will ONLY resize if the box is too small. WILL add a small buffer border around its contents for prettiness.
Given an area defined by the absolute coordinates (xmin, ymin) - (xmax, ymax), resize the netbox if necessary to ensure that the area can fit inside this box. Will ONLY resize if the box is too small. Will NOT add a buffer border around its contents for prettiness.
void OP_NetworkBox::resolveLoadedOwnerName | ( | ) |
Depending on the order in which netboxes are saved, we may load them in an order where an owned netbox is loaded before its owner. In this case, we need to run through all the netboxes after loading them to set up any ownerships that fall into this category.
int OP_NetworkBox::save | ( | std::ostream & | os, |
const OP_SaveFlags & | flags | ||
) |
Save the attributes of this network box to the ostream.
Used by opscript, this outputs the sequence of hscript commands necessary to recreate this network box. Does not script the box's contents. 'dogeneral' is set when opscript is generating a macro.
bool OP_NetworkBox::setAlpha | ( | fpreal | alpha | ) |
Set the alpha value for drawing this network box.
void OP_NetworkBox::setAutoFit | ( | bool | autofit | ) |
Accessors for the auto fit flag on the network box.
void OP_NetworkBox::setComment | ( | const UT_StringHolder & | comment | ) |
The comment that is used to describe the network box.
bool OP_NetworkBox::setContents | ( | OP_NetworkBoxItemList & | items, |
bool | snap_to_bounds | ||
) |
Sets the network boxes contents to be exactly the items in 'items' (i.e. removes any previous contents not in 'items'). Set 'snap_to_bounds' to true if you'd like us to make the netbox's dimensions snap to form a nice snug fit around its new contents.
bool OP_NetworkBox::setHWithBoundsChecks | ( | fpreal | h | ) |
Set the network box's width like setH(), but first check if the new height is valid. This method wraps the resizing operation with calls to setResizing(true) and setResizing(false).
|
inlineoverridevirtual |
Implements OP_NetworkBoxItem.
Definition at line 131 of file OP_NetworkBox.h.
void OP_NetworkBox::setMarked | ( | bool | flag | ) |
A very general purpose method used to temporarily mark this network box as being involved in an operation. Very useful if e.g. we have a set of nodes and network boxes to apply an operation to. In this case we want to mark each netbox as we apply our op to it and its contents, in case any of the nodes we're passed happen to be in one of those netboxes. In this way we can quickly check if a node's owning box has been marked, and avoid duplicately applying the operation to the node again. REMEMBER to UNMARK all netboxes you marked once you're done with your operation!
bool OP_NetworkBox::setMinimized | ( | bool | isminimized, |
bool | update_position, | ||
bool | propagate_parent_event | ||
) |
Set whether this box is currently minimized If update_position is true, then the box is moved to accomodate the minimized status. If propagate_parent_event is true, an event is sent to the network about our minimized state.
bool OP_NetworkBox::setName | ( | const UT_String & | name | ) |
The name which is used for identification and in displays of this box. setName() returns true if the name change was successful, and alters the name slightly if necessary to make it unique within this network.
|
overridevirtual |
Set whether this box is picked; returns true if the picked status has changed. Setting 'propagate_parent_event' to false stops this method from notifying the network of this change, useful when we're picking a lot of items at once, it's inefficient to trigger a callback for each pick separately, can just do one update at the end
Implements OP_NetworkBoxItem.
void OP_NetworkBox::setResizing | ( | bool | resizing | ) |
ALWAYS call this with 'resizing' == true before you do any resizing operations (e.g. setW()), and call it after you're done resizing with 'resizing' == false. You should only do this once for each group of resizing operations on the same netbox.
This method: 1) ensures we get a proper undo block around all the resize ops, and 2) allows you to use setXY() to stretch the box to the left (otherwise, setXY() just moves the box)
Get and set the width and height of this box. Units are absolute as opposed to the relative units found in OPUI. If the width or height specified is smaller than that which will contain all of the items, the width or height respectively will only be adjusted to the minimum size required to contain the items. To avoid this automatic size check, set 'force' to true.
bool OP_NetworkBox::setWWithBoundsChecks | ( | fpreal | w | ) |
Set the network box's width like setW(), but first check if the new width is valid. This method wraps the resizing operation with calls to setResizing(true) and setResizing(false).
Set the coordinates for this box (lower left corner) in absolute units. NOTE: If myResizing is set, then setXY does NOT move the box, but effectively resizes it by moving the lower/left corner of the box without moving its contents, and this may result in a change in myW and/or myH.
Implements OP_NetworkBoxItem.
Same as setXY(), but here we can force the box to take on these X/Y coordinates, even if our contents don't fit us any more. The propagate_parent_event tells this method whether or not it should send and event after moving the network box – this should normally be set to true.
void OP_NetworkBox::snapToBounds | ( | bool | incl_buff_border = true | ) |
Automatically alters myX, myY, myW, myH in order to snap the size of the netbox to the minimum bounding box enclosing its contents. Will ALWAYS resize the box to the minimum bounding box size, unlike resizeToFit(). Set 'incl_buff_border' to true if you want a small buffer border to make the layout look pretty.
void OP_NetworkBox::traverseItems | ( | OP_ItemTypeMask | item_mask, |
bool | include_hidden, | ||
bool | recursive, | ||
bool | picked_only, | ||
const F & | functor | ||
) | const |
Definition at line 391 of file OP_NetworkBox.h.