DD::Image::ViewerContext Class Reference

Classes

struct  ViewerWindowFormatContext
 

Public Member Functions

const Vector3pos () const
 
const Vector3dPos () const
 
const Vector3mousePosInHandleSpace () const
 
float x () const
 Position of mouse in OpenGL. More...
 
float y () const
 Position of mouse in OpenGL. More...
 
float z () const
 Position of mouse in OpenGL. More...
 
DD::Image::ViewerEvent event () const
 
void event (const DD::Image::ViewerEvent newEvent)
 
bool draw_solid ()
 
bool draw_transparent ()
 
bool draw_hidden_solid ()
 
bool draw_lines ()
 
bool draw_hidden_lines ()
 
bool draw_overlay ()
 
bool draw_knobs ()
 
bool draw_unpickable_lines ()
 
bool draw_unpickable_hidden_lines ()
 
bool hit_detect ()
 
bool lighting ()
 
bool showViewerGrid () const
 
void showViewerGrid (bool show)
 
void menu (Menu *menu)
 
bool nudgeXY (double &x, double &y, double amount=1.0)
 
bool nudgeTransform (double &x, double &y, double amount=1.0, double *rotate=nullptr, double *scale=nullptr)
 
bool nudgeXYZ (double &, double &, double &, double amount=1.0)
 
int what_to_draw () const
 
void what_to_draw (int n)
 
void add_draw_handle (DrawHandleCallbackFunc cb, void *, Node *, DrawHandleTypeMask drawHandleType=eDrawHandleNodeSelection)
 
void addDrawableGeo (GeoInfo *geo, Node *node)
 
DrawableGeo * findDrawableGeo (unsigned int pickID)
 
const std::vector< DrawableGeo > & getDrawableGeoList () const
 
ViewerMode viewer_mode () const
 The mode of the viewer. 0 for 2D, non-zero for various 3D modes. More...
 
TransformSpace transformSpace () const
 
int transform_mode () const
 
void transform_mode (int v)
 
Display3DMode display3d (Display3DMode mydisplay3d) const
 How to draw objects: More...
 
unsigned node_color () const
 
unsigned fg_color () const
 
unsigned bg_color () const
 
unsigned selected_color () const
 
unsigned focused_color () const
 
unsigned soft_select_min_color () const
 
unsigned soft_select_max_color () const
 
void set_node_color (unsigned col)
 
void set_selected_color (unsigned col)
 
void set_focused_color (unsigned col)
 
void set_soft_select_min_color (unsigned col)
 
void set_soft_select_max_color (unsigned col)
 
float transformHandleSize3D () const
 
float handleSize () const
 
float handlePickSize () const
 
float lineWidth () const
 
float devicePixelRatio () const
 
const Matrix4model_matrix () const
 
const Matrix4proj_matrix () const
 
const Matrix4cam_matrix () const
 
const Vector4camera_pos () const
 
float zoom () const
 
float zoom (float x, float y, float z=0) const
 
float icon_size () const
 
float icon_size (float x, float y, float z=0) const
 
const Boxviewport () const
 
const BoxvisibleViewportArea () const
 
const BoxclipArea () const
 
Box clipAreaFormatSpace () const
 
void getScreenBoundingBox (const std::vector< DD::Image::Vector3 > &points, DD::Image::Box &bboxOut) const
 
Box viewAreaFromScreenToRender (const Box &area) const
 
AxisOpcamera () const
 
bool locked () const
 
bool unlocked () const
 
bool interactive () const
 
int pixmap_size_hint_w () const
 
int pixmap_size_hint_h () const
 
void pixmap_size_hint (int w, int h)
 
bool non_default_texture_matrix () const
 
bool non_default_texture_matrix (bool v)
 
void center_viewer (float x, float y)
 
bool draw_is_expensive () const
 
void set_draw_is_expensive (bool expensive)
 
ViewerConnected connected () const
 Flags about what is between this & viewer.
 
bool reallyConnected () const
 
void connected (ViewerConnected v, bool reallyConnected=true)
 
void expand_bbox (bool active, const Box3 &)
 
void expand_bbox (bool active, float x, float y, float r, float t)
 
void expand_bbox (bool active, float x, float y, float z=0)
 
Box3bbox ()
 
Box3active_bbox ()
 
bool addCamera (AxisOp *newCamera)
 
bool addLight (LightOp *newLight)
 
const std::vector< AxisOp * > & cameras () const
 
const std::vector< LightOp * > & lights () const
 
bool renderInProgress () const
 
bool playbackInProgress () const
 
void setPlaybackInProgress (bool inProgress)
 
bool draw_animation_path ()
 
bool draw_animation_path_done ()
 
void draw_animation_path_done (bool done)
 
void accept_drop (bool accept)
 
bool accept_drop ()
 
const float * getZBuffer () const
 
RegularGrid * buildGrid ()
 
Hash getDrawableGeometryHash () const
 
Box selection () const
 
SelectionMode3D getSelectionMode3D () const
 
Select3DAction getSelectionAction () const
 
bool getOcclusionTest () const
 
void setSelection (const Box &newSelection)
 
void setSelectionMode3D (SelectionMode3D mode)
 
void setSelectionAction (Select3DAction action)
 
void setOcclusionTest (bool enabled)
 
virtual float gamma () const
 
virtual float gain () const
 
void setMenuFirstCall (bool menuFirstCall)
 
bool menuFirstCall () const
 
Menumenu () const
 
bool glHandlesCached () const
 
void glHandlesCached (const bool glHandlesCached)
 
ViewerWindowFormatContextviewerWindowFormatContext ()
 
bool isPerspectiveRender () const
 
void requestRedraw (bool request)
 Force a redraw of the viewer. This is for use by plugins which are doing progressive rendering and don't want to frezze the UI.
 
bool redrawRequested () const
 
ViewerContextImpl * pImpl () const
 Internal use only.
 

Static Public Member Functions

static int mouse_x ()
 
static int mouse_y ()
 
static int wheel_dx ()
 
static int wheel_dy ()
 
static float pressure ()
 
static int clicks ()
 
static void clicks (int i)
 
static bool is_click ()
 
static void clear_is_click ()
 
static unsigned button ()
 
static bool state (unsigned v)
 
static unsigned state ()
 
static unsigned key ()
 
static const char * key_text ()
 
static unsigned key_text_length ()
 
static int pointer_type ()
 
static bool auto_repeat ()
 
static void getViewerWindowPanZoom (const ViewerWindowFormatContext &formatCtx, float &panx, float &pany, float &zoomx, float &zoomy)
 
static DD::Image::Vector2 convertFromViewerToFormat (const ViewerWindowFormatContext &formatCtx, const DD::Image::Vector2 &pos)
 

Public Attributes

Matrix4 modelmatrix
 

Static Public Attributes

static bool(* is_down )(unsigned key)
 

Protected Member Functions

void saveZBuffer ()
 
unsigned int getGeometryComponentLength (GeoInfo *geo)
 
void recalculateGeometryOffsets ()
 
void setRenderInProgress (bool inProgress)
 
ViewerContextoperator= (const ViewerContext &)
 noncopy and nonassign
 
 ViewerContext (const ViewerContext &)
 

Protected Attributes

ViewerMode viewer_mode_
 
TransformSpace _transformSpace
 
ViewerConnected connected_
 
bool _reallyConnected
 
bool _renderInProgress
 
bool _playbackInProgress
 
Display3DMode display3d_
 
int what_to_draw_
 
bool _showViewerGrid
 
DD::Image::ViewerEvent event_
 
Vector3 pos_
 
Vector3 posDeltaSinceLast_
 
Vector3 mousePosInHandleSpace_
 
unsigned node_color_
 
unsigned fg_color_
 
unsigned bg_color_
 
unsigned selected_color_
 
unsigned focused_color_
 
unsigned soft_select_min_color_
 
unsigned soft_select_max_color_
 
float icon_size_base
 
float icon_size_power
 
float transformHandleSize3D_
 
float handleSize_
 
float handlePickSize_
 
float lineWidth_
 
float _devicePixelRatio
 
Box viewport_
 see viewport() for more information
 
float center_x
 
float center_y
 
float reserve2
 
float reserve3
 
Box visibleViewportArea_
 
Box _clipArea
 see clipArea() for more information
 
int pixmap_size_hint_w_
 
int pixmap_size_hint_h_
 
bool ndtm
 
bool center_called
 
std::vector< Draw_Handle_Callbackdraw_handle_list
 
std::vector< DrawableGeo > drawableGeoList
 
RegularGrid * _grid
 
Hash _gridHash
 
Box3 bbox_
 build_handles sets this to bounding box of everything
 
Box3 active_bbox_
 build_handles sets this to bounding box of active things
 
std::vector< AxisOp * > _cameras
 
std::vector< LightOp * > _lights
 
AxisOpcamera_
 
CameraLockMode _camera_lockmode
 
int transform_mode_
 
Matrix4 projmatrix
 
Matrix4 cameramatrix
 
Vector4 _cameraPos
 The current camera location in world coordinates.
 
bool my_draw_animation_path
 
bool my_draw_animation_path_done
 
bool _accept_drop
 
Menu_menu
 
Hash _geometryListHash
 
bool _glHandlesCached
 

Static Protected Attributes

static int * mouse_x_
 
static int * mouse_y_
 
static int * wheel_dx_
 
static int * wheel_dy_
 
static float * pressure_
 
static unsigned * state_
 
static int * clicks_
 
static unsigned * is_click_
 
static unsigned * key_
 
static unsigned * length_
 
static const char ** text_
 
static bool * auto_repeat_
 
static int * pointer_type_
 

Friends

class ::Viewer_Window
 
class ::SelectionManager
 
struct ::KnobSelectionRecord
 

Related Functions

(Note that these are not member functions.)

enum  Display3DMode
 
enum  ViewerConnected
 
enum  TransformSpace : uint8_t
 
enum  ViewerMode
 
enum  ViewerEvent
 
enum  CameraLockMode
 
enum  
 
enum  
 
enum  
 
enum  
 
enum  Cursor
 

Detailed Description

This structure is passed to the Op::build_handles() functions, and also to any callbacks that the build_handles() creates with add_draw_handle().

The data inside of it describes the state of the Nuke viewer and any modifications done by the build_handles() calls by operators between the one being called and the viewer.

Member Function Documentation

const Vector3 & DD::Image::ViewerContext::pos ( ) const
inline

Returns the coordinate associated with the event (e.g. the mouse pos when clicking on a handle or the pos of the selected handle when a key is pressed) translated into whatever coordinate system was in effect when the current handle was created.

When the event type is PUSH, CURSOR or HOVER_MOVE and the handle type is POSITION this is equal to the handle's location in handle-space. This call only ever operates on one handle at a time.

Similarly when the event type is PUSH, CURSOR or HOVER_MOVE and the handle type is SELECTABLE this is equal to the handle's location for non-batched handles and the absolute (adjusted) mouse location (in handle space) for batched handles.

Otherwise this position, for any other event and for any handle type (with two exceptions; details to follow) is set to be the current (adjusted) mouse location.

const Vector3 & DD::Image::ViewerContext::dPos ( ) const
inline

Returns the change in coordinate of the mouse since the last event, translated into whatever coordinate system was in effect when the current handle was created.

This will (probably) be (0.0f, 0.0f, 0.0f) on push, and the change is movement since the last move otherwise.

const Vector3 & DD::Image::ViewerContext::mousePosInHandleSpace ( ) const
inline

Returns the coordinate associated with the event (e.g. the mouse pos when clicking on a handle or the pos of the selected handle when a key is pressed) translated into handle space

double DD::Image::ViewerContext::x ( ) const
inline

Position of mouse in OpenGL.

Returns the x coordinate of the mouse, translated into whatever coordinate system was in effect when the current handle was created.

double DD::Image::ViewerContext::y ( ) const
inline

Position of mouse in OpenGL.

Returns the y coordinate of the mouse, translated into whatever coordinate system was in effect when the current handle was created.

double DD::Image::ViewerContext::z ( ) const
inline

Position of mouse in OpenGL.

Returns the z coordinate of the mouse, translated into whatever coordinate system was in effect when the current handle was created.

int DD::Image::ViewerContext::mouse_x ( )
inlinestatic

Returns the position of the mouse in pixels

int DD::Image::ViewerContext::mouse_y ( )
inlinestatic

Returns the position of the mouse in pixels, 0 is the top of the viewer.

int DD::Image::ViewerContext::wheel_dx ( )
inlinestatic

Returns the number of clicks the wheel moved horizontally.

int DD::Image::ViewerContext::wheel_dy ( )
inlinestatic

Returns the number of clicks the wheel moved vertically.

int DD::Image::ViewerContext::clicks ( )
inlinestatic

Returns 0 on a PUSH event for a single click, 1 for a double click, 2 for triple, etc.

void DD::Image::ViewerContext::clicks ( int  i)
inlinestatic

Change the number of clicks, for fooling other knobs into acting different.

bool DD::Image::ViewerContext::is_click ( )
inlinestatic

True if a short enough time has passed since the last PUSH that this should be considered a "click" rather than a "hold". Clicks pop up menus, holds select menu items.

void DD::Image::ViewerContext::clear_is_click ( )
inlinestatic

Turn a click into a hold. If you do this before setting a menu then the click will pick the default item rather than making the menu appear.

int DD::Image::ViewerContext::button ( )
inlinestatic

For PUSH and RELEASE events, returns one of these values:

  • DD::Image::LeftButton (1)
  • DD::Image::MiddleButton (2)
  • DD::Image::RightButton (3) May return higher numbers for mice with more buttons. Returns garbage if the event is not PUSH or RELEASE.

Also see pointer_type() and key().

int DD::Image::ViewerContext::key ( )
inlinestatic

Returns which key the user hit for a KEY event. Letters return lower-case characters like 'x'. Other keys return symbols that are listed in ViewerContext.h.

const char * DD::Image::ViewerContext::key_text ( )
inlinestatic

String produced by this key. Mostly this lets you see the actual letter typed, for instance the X key produces 'x' for key() but "x", "X", or "\x18" depending on the shift and control keys.

int DD::Image::ViewerContext::key_text_length ( )
inlinestatic

Length of string returned by key_text(), so that a key that produces "\0" can be distinguished from a key that produces nothing.

int DD::Image::ViewerContext::pointer_type ( )
inlinestatic

For PUSH and RELEASE events, returns one of these values:

  • DD::Image::eUnknown
  • DD::Image::ePen
  • DD::Image::eCursor (indicating the mouse)
  • DD::Image::eEraser See also button().
int DD::Image::ViewerContext::event ( ) const
inline

Return the event that caused Knob::draw_handles() or a handle callback to be done. This can be DRAW, DRAW_SHADOW, MOVE, PUSH, DRAG, RELEASE, KEY, KEYUP, WHEEL, or items from menus. See Knob::begin_handle() for more information. It may also be NO_EVENT when after menu() has been called.

bool ViewerContext::draw_solid ( )

True if you should draw solid opaque objects

References DD::Image::DRAW_OPAQUE, and DD::Image::MOVE.

Referenced by DD::Image::CameraOp::draw_handle().

bool ViewerContext::draw_transparent ( )

True if you should draw objects that may be transparent

References DD::Image::MOVE.

Referenced by DD::Image::Transform::draw_handle().

bool ViewerContext::draw_hidden_solid ( )

True if you should draw solid objects that are can be seen behind objects with a stippled pattern.

References DD::Image::MOVE.

bool ViewerContext::draw_lines ( )
bool ViewerContext::draw_hidden_lines ( )

True if you should draw wireframes and points that can be seen behind objects with a stippled pattern.

References DD::Image::DRAW_OVERLAY, and DD::Image::DRAW_STIPPLED.

Referenced by DD::Image::CameraOp::draw_handle().

bool ViewerContext::draw_overlay ( )

True if you should draw overlays.

References DD::Image::DRAW_OVERLAY, and DD::Image::MOVE.

bool ViewerContext::draw_knobs ( )
bool ViewerContext::draw_unpickable_lines ( )

True if you should draw lines that are not hit-detected.

References DD::Image::DRAW_LINES, and DD::Image::DRAW_STIPPLED.

Referenced by DD::Image::AxisOp::draw_handle().

bool ViewerContext::draw_unpickable_hidden_lines ( )

True if you should draw lines that are not hit-detected.

References DD::Image::DRAW_SHADOW, and DD::Image::DRAW_STIPPLED.

bool DD::Image::ViewerContext::hit_detect ( )
inline

True if draw is being called for hit detection.

References DD::Image::MOVE.

Referenced by DD::Image::CameraOp::draw_handle().

bool DD::Image::ViewerContext::lighting ( )
inline

True if OpenGL lights have been enabled

References DD::Image::SHOW_LIGHTING.

bool DD::Image::ViewerContext::showViewerGrid ( ) const
inline

True if the 3D viewer grid should be drawn.

void DD::Image::ViewerContext::showViewerGrid ( bool  show)
inline

Sets whether the 3D viewer grid should be drawn.

void ViewerContext::menu ( Menu menu)

A Knob handle callback can call this to make a popup menu. This is a little complex in order to allow a single menu item to modify all the selected handles, even if they belong to different knobs.

If event() is PUSH then the menu is popped up and it waits for the user to select an item. You may want to call this only if button() or state() is correct, or change which menu is used depending on the buttons. When this returns event() will have either been changed to NO_EVENT or to one of the event numbers from an item in the menu.

If event() is KEY then if this matches a menu item then the event number is changed to the number from that item. If there is no match then event() is not changed (so you could use the KEY for something else).

If event() is NO_EVENT then an item was picked already from some menu. In this case, if this is the same menu, then the event() is changed to the same value. If this is a different menu then the event() is left at NO_EVENT. This allows different knobs and handles to share the effects of a menu.

bool ViewerContext::nudgeTransform ( double &  x,
double &  y,
double  amount = 1.0,
double *  rotate = nullptr,
double *  scale = nullptr 
)

Apply the current key state to nudge X and Y values

References DD::Image::KEY.

bool ViewerContext::nudgeXYZ ( double &  x,
double &  y,
double &  z,
double  amount = 1.0 
)

Apply the current key state to nudge X, Y and Z values

References DD::Image::KEY.

void ViewerContext::add_draw_handle ( DrawHandleCallbackFunc  cb,
void *  object,
Node *  node,
DrawHandleTypeMask  drawHandleType = eDrawHandleNodeSelection 
)

Add a callback that will be used to draw something in the viewer. A build_handles() function calls this, the list is then called repeatedly to draw the viewer, and also for hit-detection.

object is an arbitrary pointer that is passed to the callback.

node is a pointer to a Node. This is used to set the colors and also as the node to be selected if the user clicks on any of the graphics drawn by the callback.

type is an indicator of the type of handle we are adding. A geometry handle will always be drawn, regardless of whether which selection mode we're in; a selection handle will only be drawn when we're in the appropriate selection mode; and any other handle will be drawn when we're in node select mode (the Nuke default).

This callback will be called with this exact same ViewerContext. The modelmatrix and connected() settings will be restored to how they are when this was called (actually the modelmatrix is also multiplied by the camera and zoom/pan currently being used by the viewer). The event() will be set to say why it is being called.

References DD::Image::Draw_Handle_Callback::callback, DD::Image::Draw_Handle_Callback::connected, DD::Image::Draw_Handle_Callback::data, DD::Image::Draw_Handle_Callback::drawHandleType, DD::Image::Draw_Handle_Callback::glCached, DD::Image::Draw_Handle_Callback::matrix, DD::Image::Draw_Handle_Callback::node, DD::Image::Draw_Handle_Callback::object, DD::Image::Draw_Handle_Callback::parentTransform, and DD::Image::Draw_Handle_Callback::reallyConnected.

Referenced by DD::Image::GeoOp::add_draw_geometry(), DD::Image::Knob::add_draw_handle(), DD::Image::Op::add_draw_handle(), and DD::Image::Render::buildGeoInfoHandle().

DrawableGeo * ViewerContext::findDrawableGeo ( unsigned int  pickID)

Does a binary search through the drawables to find the one containing the packedID, if any. The return value will be a valid DrawableGeo pointer if we found anything, or NULL if not.

Runtime is O(log n), where n is the number of drawables.

ViewerMode DD::Image::ViewerContext::viewer_mode ( ) const
inline

The mode of the viewer. 0 for 2D, non-zero for various 3D modes.

Return which type of viewer this is for.

Referenced by DD::Image::TransformGeo::build_handles(), DD::Image::AxisOp::build_handles(), DD::Image::GeoOp::build_matrix_handles(), and DD::Image::CameraOp::draw_handle().

ViewerMode DD::Image::ViewerContext::transformSpace ( ) const
inline

Return which type of transform space this is for. The default is object space.

void DD::Image::ViewerContext::transform_mode ( int  v)
inline

Some clever nodes can change the mode of their input.

Display3DMode ViewerContext::display3d ( Display3DMode  mydisplay3d) const

How to draw objects:

Return how to draw 3d objects. object_style3d is the setting on this object's control panel. Current version returns the minimum of this and the viewer's style3d setting, and returns wireframe if this node is not connected to the viewer or if the panel is closed and the viewer control to make closed things wireframe is set.

Referenced by DD::Image::CameraOp::draw_handle(), DD::Image::Transform::draw_handle(), DD::Image::AxisOp::draw_handle(), DD::Image::Primitive::draw_solid_vertex(), and DD::Image::Primitive::getDataArray().

unsigned DD::Image::ViewerContext::node_color ( ) const
inline

Return the color of the current node. This can be used to color things in the viewer to match. The color is 8 bits per channel in the form 0xrrggbbaa. Currently the alpha is ignored.

If event() is DRAW_SHADOW this returns a color to draw shadows.

Referenced by DD::Image::ComplexLightOp::draw_handle(), DD::Image::CameraOp::draw_handle(), DD::Image::Transform::draw_handle(), DD::Image::AxisOp::draw_handle(), and DD::Image::LightOp::draw_handle().

unsigned DD::Image::ViewerContext::fg_color ( ) const
inline

Return the user-selected foreground color for the viewer. This can be used to draw line segments atop your object. We recommend you use node_color() if your object only consists of lines, however.

If event() is DRAW_SHADOW this returns a color to draw shadows.

Referenced by DD::Image::ComplexLightOp::draw_handle(), DD::Image::CameraOp::draw_handle(), DD::Image::AxisOp::draw_handle(), and DD::Image::LightOp::draw_handle().

unsigned DD::Image::ViewerContext::bg_color ( ) const
inline

Return the color of the background of the viewer. This can be used to make sure you contrast with it.

float DD::Image::ViewerContext::devicePixelRatio ( ) const
inline

Return the device pixel ratio for the viewer. This is the ration of screen pixels to UI pixels when on a scaled high-DPI display.

float ViewerContext::zoom ( ) const

Same as zoom(0,0,0). If the viewer is not showing perspective the position does not matter, so it is safe to call this.

float ViewerContext::zoom ( float  x,
float  y,
float  z = 0 
) const

Return how big a 1-unit line segment starting at the given xyz will draw in pixels. This can be used for hit detection or to scale things so they draw a given size on the screen.

This depends on the camera position and 2D zoom factor. These are not decided when build_handles() is called on objects. So you cannot call this at that time, instead you must call and use this in draw_handle(). As this function is somewhat slow (it does 3 matrix multiplications) you should call it once and put the result in a local variable.

Warning: returns INFINITY for things at or behind the camera, or nearer than the near plane. This indicates that things are invisible.

Note that as zoom is mostly intended for drawing handles at a useful size for the user, it works in UI pixels, not device pixels so you may need to scale by devicePixelRatio if using it for other purposes.

References DD::Image::Vector4::divide_w().

float ViewerContext::icon_size ( float  x,
float  y,
float  z = 0 
) const

Return a scale factor to draw things that should be fixed-size on the screen. This takes into account zoom() and the user's preferences for icon size and power factor. The returned value is used as the length of the 3D axis handles and the diameter of the circle in the 2D transform manipulator, scale your icons appropriately to match.

Warning: returns zero (0) for things at or behind the camera, or nearer than the near plane. This indicates that things are invisible.

const Box& DD::Image::ViewerContext::viewport ( ) const
inline

Returns the BBox xywh of the viewer in pixels, in screen space (i.e. not render/format space). To convert the return values from screen-space to render/format-space call viewareaFromScreenToRender()

Referenced by DD::Image::gl_drawTextTopLeftOrthogonal(), and DD::Image::ViewFrustum::ViewFrustum().

const Box& DD::Image::ViewerContext::visibleViewportArea ( ) const
inline

Returns the BBox xywh of the visible viewer in pixels, this value is the same as viewport() but smaller as it removes the width/height of . any toolbars. As with viewport() the return value is in screen space (i.e. not render/format space). To convert from screen-space to render/format-space call viewareaFromScreenToRender()

Referenced by DD::Image::gl_drawTextTopLeftOrthogonal().

const Box& DD::Image::ViewerContext::clipArea ( ) const
inline

Similar to viewport() except this returns the BBox xywh of the area of interest, where interest denotes an area outside of which rendered items can be ignored rather than the full visible area. i.e. will not be considered during some arbritrary calculation. For example during non-PUSH events the return value will be equal to the return value from visibleViewportArea() and during PUSH events it will be whatever region the hit-detect area is interested in (i.e. much smaller). The return value is the screen-space (i.e. not render/format space) BBox xywh of the area of interest. To convert from screen-space to render/format-space call viewAreaFromScreenToRender().

Box ViewerContext::clipAreaFormatSpace ( ) const

Same as the above but converts the clip area into format space

void ViewerContext::getScreenBoundingBox ( const std::vector< DD::Image::Vector3 > &  points,
DD::Image::Box bboxOut 
) const

Get the screen space bounds of a vector of points

References DD::Image::GLProject(), DD::Image::Box::r(), DD::Image::Box::t(), DD::Image::Box::x(), and DD::Image::Box::y().

Box ViewerContext::viewAreaFromScreenToRender ( const Box area) const

Converts a render or viewport area from screen-space for render/format-space, e.g. those returned from viewport(), visibleViewportArea() or renderArea(). Note that this is comparitivly expensive operation.

References DD::Image::Box::r(), DD::Image::Box::t(), DD::Image::Box::x(), and DD::Image::Box::y().

void ViewerContext::expand_bbox ( bool  active,
const Box3 box 
)

build_handles() can call this to indicate the volume that surrounds anything that is being drawn. These are all merged together to produce auto-frame and near/far plane settings in the viewer.

If active is true this indicates that the volume is selected and the "frame" shortcut in the Viewer should show it. If this is not true the volume is only used for setting the near/far planes of the Viewer's OpenGL camera.

References DD::Image::Box3::empty(), and DD::Image::Box3::transform().

Referenced by DD::Image::GeoOp::add_draw_geometry(), and DD::Image::AxisOp::build_handles().

void ViewerContext::expand_bbox ( bool  active,
float  x,
float  y,
float  r,
float  t 
)

Add a flat rectangle in the z=0 plane to the volume that surrounds anything that is being drawn. This is most useful for 2D controls.

void ViewerContext::expand_bbox ( bool  active,
float  x,
float  y,
float  z = 0 
)

Add a point to the volume of things being drawn. Enough slop is added so that the icon_size() surrounding this is visible.

bool ViewerContext::addCamera ( AxisOp newCamera)

build_handles() can call this to set a camera that the user is likely to want to view through. The 'h' key in the viewer will then lock to one of these cameras. AxisOp is a base class common to both Camera and Light, you can put any AxisOp on this list, objects without lens information will use the normal zoom factor of the Viewer.

If there are no other rules, the first camera added takes precedence. Thus a renderer should add the camera before it adds it's input operators.

Returns true if this really is a new camera. Returns false if the camera already exists in the list, possibly from a different operator.

References DD::Image::Op::node_disabled().

Referenced by DD::Image::RenderScene::build_handles().

bool ViewerContext::addLight ( LightOp newLight)

build_handles() can call this to add a light to the OpenGL scene. Returns false if already in scene.

References DD::Image::Op::node_disabled().

void ViewerContext::setSelection ( const Box newSelection)

The width and height of the box you pass in here are expanded by 1 pixel, so that it represents an inclusive range.

Menu* DD::Image::ViewerContext::menu ( ) const
inline

Return the context menu. May not be valid in all circumstances.

Friends And Related Function Documentation

enum Display3DMode
related

Value for GeoOp::display3d() and ViewerContext::display3d()

enum TransformSpace : uint8_t
related
enum ViewerMode
related
enum ViewerEvent
related
enum CameraLockMode
related

Value for camera lock mode

anonymous enum
related

Value for ViewerContext::what_to_draw(). This is a bunch of checkmarks on the viewer. The viewer will implement some of these (such as transparency or lighting) by initializing the OpenGL state, but it may still be useful to check if they are off.

anonymous enum
related

Values for ViewerContext::key() and ViewerContext::is_down(). Same values as Qt. Use lowercase 'x' or the unshifted symbol for the printing character keys.

anonymous enum
related

Values for ViewerContext::state(). On the Macintosh, the Command key gives CTRL and the Ctrl key gives META.

anonymous enum
related

Values for ViewerContext::pointer_type(). Valid for pen types when used with a tablet

enum Cursor
related

Values for ViewerContext::setCursor().

Member Data Documentation

bool(* ViewerContext::is_down)(unsigned)
static

Returns true if the key identified by key is currently held down.

Matrix4 DD::Image::ViewerContext::modelmatrix

In draw_handles this is the current OpenGl model matrix. If you change the OpenGL matrix you should also change this one so that add_handles remembers the correct values. You must restore the OpenGL matrix but you can leave this one changed and the calling code will restore it.

In build_handles whatever value you put in here is remembered for each add_draw_handle(). You can multiply this to change the transform before calling other functions so they get different transforms. You must put the original value back before returning.

Referenced by DD::Image::GeoOp::add_draw_geometry(), DD::Image::TransformGeo::build_handles(), DD::Image::RenderScene::build_handles(), DD::Image::Transform::build_handles(), DD::Image::AxisOp::build_handles(), DD::Image::GeoOp::build_matrix_handles(), DD::Image::ComplexLightOp::draw_handle(), DD::Image::CameraOp::draw_handle(), and DD::Image::LightOp::draw_handle().



©2022 The Foundry Visionmongers, Ltd. All Rights Reserved.
www.thefoundry.co.uk