HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
OP_NetworkBox Class Reference

#include <OP_NetworkBox.h>

+ Inheritance diagram for OP_NetworkBox:

Public Member Functions

 OP_NetworkBox (const UT_String &name, OP_Network *net)
 
virtual ~OP_NetworkBox ()
 
virtual void setXY (fpreal x, fpreal y)
 
void setXY (fpreal x, fpreal y, bool force, bool propagate_parent_event)
 
virtual fpreal getX () const
 
virtual fpreal getY () const
 
void setW (fpreal w, bool force=false)
 
void setH (fpreal h, bool force=false)
 
bool setWWithBoundsChecks (fpreal w)
 
bool setHWithBoundsChecks (fpreal h)
 
virtual fpreal getW () const
 
virtual fpreal getH () const
 
fpreal getMaximizedW () const
 
fpreal getMaximizedH () const
 
void resizeToFit ()
 
void resizeToFit (fpreal xmin, fpreal ymin, fpreal xmax, fpreal ymax)
 
bool setName (const UT_String &name)
 
virtual const UT_StringgetItemName () const
 
virtual bool setItemName (const UT_String &name)
 
void setComment (const UT_StringHolder &comment)
 The comment that is used to describe the network box. More...
 
const UT_StringHoldergetComment () const
 
int getNitems () const
 
int getNexposedItems () const
 
OP_NetworkBoxItemgetItem (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)
 
virtual int getPicked () const
 Returns true if this box is currently picked. More...
 
virtual int setPicked (int on_off, bool propagate_parent_event=true)
 
bool getMinimized () const
 Get whether this box is currently minimized. More...
 
bool setMinimized (bool isminimized, bool update_position, bool propagate_parent_event)
 
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)
 
virtual OP_ItemType getItemType () const
 Returns my item type (OP_ITEMTYPE_NETWORKBOX) More...
 
const OP_StatgetStat () const
 
OP_StatgetStat ()
 
virtual OP_NetworkgetParentNetwork () const
 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
 
virtual int64 getItemUniqueId () const
 Functions to get hip-file-unique ids for any item type. More...
 
void setResizing (bool resizing)
 
bool getResizing ()
 
void setAutoFit (bool autofit)
 Accessors for the auto fit flag on the network box. More...
 
bool getAutoFit ()
 
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_NetworkBoxgetOwnerBox () const
 
bool hasOwnerBox (OP_NetworkBoxItem *item) const
 
OP_NetworkBoxgetMinimizedOwnerBox () 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_NetworkgetCreator () const
 
OP_NetworkgetCodeCreator () 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_NetworkBoxlookupNetworkBox (int unique_id)
 
static const UT_ColordefaultColor ()
 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_NetworkBoxItemlookupItem (const OP_ItemType &type, int64 id)
 
static OP_NetworkBoxItemlookupItem (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_NonCopyableoperator= (const UT_NonCopyable &)=delete
 
- Protected Attributes inherited from OP_NetworkBoxItem
UT_Color myColor
 

Detailed Description

Definition at line 54 of file OP_NetworkBox.h.

Constructor & Destructor Documentation

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.

virtual OP_NetworkBox::~OP_NetworkBox ( )
virtual

Member Function Documentation

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 void OP_NetworkBox::clearAllPendingUndoFlags ( )
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 const UT_Color& OP_NetworkBox::defaultColor ( )
static

Control the default color used on new network boxes.

bool OP_NetworkBox::getAutoFit ( )
const UT_StringHolder& OP_NetworkBox::getComment ( ) const
inline

Definition at line 136 of file OP_NetworkBox.h.

virtual fpreal OP_NetworkBox::getH ( ) const
virtual

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.

virtual const UT_String& OP_NetworkBox::getItemName ( ) const
inlinevirtual

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.

virtual OP_ItemType OP_NetworkBox::getItemType ( ) const
virtual

Returns my item type (OP_ITEMTYPE_NETWORKBOX)

Implements OP_NetworkBoxItem.

virtual int64 OP_NetworkBox::getItemUniqueId ( ) const
inlinevirtual

Functions to get hip-file-unique ids for any item type.

Implements OP_NetworkBoxItem.

Definition at line 282 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
virtual OP_Network* OP_NetworkBox::getParentNetwork ( ) const
virtual

Return the network i'm in.

Implements OP_NetworkBoxItem.

virtual int OP_NetworkBox::getPicked ( ) const
virtual

Returns true if this box is currently picked.

Implements OP_NetworkBoxItem.

bool OP_NetworkBox::getResizing ( )
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.

const OP_Stat& OP_NetworkBox::getStat ( ) const
inline

Definition at line 258 of file OP_NetworkBox.h.

OP_Stat& OP_NetworkBox::getStat ( )
inline

Definition at line 259 of file OP_NetworkBox.h.

int OP_NetworkBox::getUniqueId ( ) const
inline

Definition at line 281 of file OP_NetworkBox.h.

virtual fpreal OP_NetworkBox::getW ( ) const
virtual

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.

virtual fpreal OP_NetworkBox::getX ( ) const
virtual

Get the position of this box. Units are absolute, as opposed to relative units found in OPUI.

Implements OP_NetworkBoxItem.

virtual fpreal OP_NetworkBox::getY ( ) const
virtual

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 OP_NetworkBox* OP_NetworkBox::lookupNetworkBox ( int  unique_id)
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.

void OP_NetworkBox::resizeToFit ( fpreal  xmin,
fpreal  ymin,
fpreal  xmax,
fpreal  ymax 
)

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.

int OP_NetworkBox::save ( std::ostream &  os,
const OP_SaveFlags flags 
)

Save the attributes of this network box to the ostream.

int OP_NetworkBox::saveCommand ( std::ostream &  os,
const char *  name,
int  dogeneral 
) const

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.

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.

static void OP_NetworkBox::setDefaultColor ( const UT_Color color)
static
void OP_NetworkBox::setH ( fpreal  h,
bool  force = false 
)
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).

virtual bool OP_NetworkBox::setItemName ( const UT_String name)
inlinevirtual

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.

virtual int OP_NetworkBox::setPicked ( int  on_off,
bool  propagate_parent_event = true 
)
virtual

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)

void OP_NetworkBox::setW ( fpreal  w,
bool  force = false 
)

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).

virtual void OP_NetworkBox::setXY ( fpreal  x,
fpreal  y 
)
virtual

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.

void OP_NetworkBox::setXY ( fpreal  x,
fpreal  y,
bool  force,
bool  propagate_parent_event 
)

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.

template<typename F >
void OP_NetworkBox::traverseItems ( OP_ItemTypeMask  item_mask,
bool  include_hidden,
bool  recursive,
bool  picked_only,
const F &  functor 
) const

Definition at line 374 of file OP_NetworkBox.h.


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