interactiverender.h

Go to the documentation of this file.
00001 /* -----------------------------------------------------------------------------
00002 // -----------------------------------------------------------------------------
00003 
00004    FILE: interactiveRender.h
00005 
00006      DESCRIPTION: interactive rendering interface
00007 
00008      CREATED BY: michael malone (mjm)
00009 
00010      HISTORY: created September 9, 2000
00011 
00012      Copyright (c) 2000, All Rights Reserved
00013 
00014 // -----------------------------------------------------------------------------
00015 // -------------------------------------------------------------------------- */
00016 #pragma once
00017 
00018 #include "notify.h"
00019 #include "iImageViewer.h"
00020 #include "render.h"
00021 
00022 // -----------------------------------------------------------------------------
00023 // -----------------------------------------------------------------------------
00024 
00034 class IRenderProgressCallback : public RendProgressCallback
00035 
00036 //  PURPOSE:
00037 //    Progress callback for interactive rendering
00038 //
00039 //  NOTES:
00040 //    created:  04.13.00 - mjm
00041 //
00042 //    information set via RendProgressCallback::SetCurField() or RendProgressCallback::SetSceneStats() will be
00043 //    ignored. if a title is set via the inherited method SetTitle(), it will appear in the main status bar,
00044 //    but will be replaced by the 'IRenderTitle' when necessary.
00045 //
00046 //    an interactive renderer should abort if RendProgressCallback::Progress() returns RENDPROG_ABORT
00047 //
00048 // -----------------------------------------------------------------------------
00049 // -----------------------------------------------------------------------------
00050 
00051 {
00052 public:
00053     // LO_Horizontal indicates that a single pixel-wide line will grow from left to right,
00054     // at the top of the rendered region, as the interactive rendering progresses
00055     // LO_Vertical indicates that the line will grow from top to bottom,
00056     // at the right of the rendered region.
00057     enum LineOrientation { LO_Horizontal = 0, LO_Vertical };
00058 
00059     // sets/gets progress line orientation
00066     virtual void SetProgressLineOrientation(LineOrientation orientation) = 0;
00071     virtual LineOrientation GetProgressLineOrientation() const = 0;
00072 
00073     // sets/gets progress line color
00079     virtual void SetProgressLineColor(const Color& color) = 0;
00082     virtual const Color& GetProgressLineColor() const = 0;
00083 
00084     // sets/gets the current title. it will appear in the main status bar as "'Title': xx% complete".
00085     // if no title is provided, 'ActiveShade' will be used instead.
00092     virtual void SetIRenderTitle(const MCHAR *pProgressTitle) = 0;
00094     virtual const MCHAR *GetIRenderTitle() const = 0;
00095 };
00096 
00097 
00098 // -----------------------------------------------------------------------------
00099 // -----------------------------------------------------------------------------
00100 
00107 class IIRenderMgrSelector : public InterfaceServer
00108 {
00109 public:
00110     // Is the node selected? Default behaviors shades all nodes
00118     virtual BOOL IsSelected(INode* pINode) { UNUSED_PARAM(pINode); return TRUE; }
00119 };
00120 
00121 // -----------------------------------------------------------------------------
00122 //
00123 //  Action Table Ids for the default ActiveShade renderer
00124 //
00125 #define ID_IRENDER_PRESHADE             40601
00126 #define ID_IRENDER_RESHADE              40602
00127 #define ID_IRENDER_AUTOMATIC_PRESHADE   40603
00128 #define ID_IRENDER_AUTOMATIC_RESHADE    40604
00129 #define ID_IRESHADE_TOGGLE_TOOLBAR_DOCKED 40710
00130 #define ID_IRESHADE_ACT_ONLY_MOUSE_UP   40714
00131 
00132 
00133 
00134 // -----------------------------------------------------------------------------
00135 
00141 class IIRenderMgr : public InterfaceServer
00142 
00143 //  PURPOSE:
00144 //    Abstract class (Interface) for an interactive rendering manager
00145 //
00146 //  NOTES:
00147 //    created:  04.13.00 - mjm
00148 //
00149 // -----------------------------------------------------------------------------
00150 // -----------------------------------------------------------------------------
00151 
00152 {
00153 public:
00154     enum CommandMode
00155     {
00156         CMD_MODE_NULL = 0,
00157         CMD_MODE_DRAW_REGION,
00158         CMD_MODE_SELECT_OBJECT,
00159     }; // may later add modes for camera control
00160 
00163     virtual bool CanExecute() = 0;
00169     virtual void SetActive(bool active) = 0;
00171     virtual MCHAR* GetName() = 0;
00174     virtual bool IsActive() = 0;
00177     virtual HWND GetHWnd() const = 0;
00180     virtual ViewExp *GetViewExp() = 0;
00188     virtual void SetPos(int X, int Y, int W, int H) = 0;
00191     virtual void Show() = 0;
00194     virtual void Hide() = 0;
00196     virtual void UpdateDisplay() = 0;
00198     virtual void Render() = 0;
00201     virtual void SetDelayTime(int msecDelay) = 0;
00203     virtual int GetDelayTime() = 0;
00206     virtual void Close() = 0;
00208     virtual void Delete() = 0;
00209 
00210     // sets and gets the command mode
00216     virtual void SetCommandMode(CommandMode commandMode) = 0;
00220     virtual CommandMode GetCommandMode() const = 0;
00221 
00222     // sets and gets the update state
00230     virtual void SetActOnlyOnMouseUp(bool actOnlyOnMouseUp) = 0;
00234     virtual bool GetActOnlyOnMouseUp() const = 0;
00235 
00236     // toggles the toolbar display mode (for docked windows)
00239     virtual void ToggleToolbar() const = 0;
00240 
00241     // gets the display style
00245     virtual IImageViewer::DisplayStyle GetDisplayStyle() const = 0;
00246 
00247     // find out if the renderer is currently rendering
00250     virtual BOOL IsRendering() = 0;
00251 
00252     // Has the rendering manager selected any nodes.
00255     virtual BOOL AreAnyNodesSelected() const = 0;
00256 
00257     // Get interface that determines whether nodes are selected
00260     virtual IIRenderMgrSelector* GetNodeSelector() = 0;
00261 
00262     // ---------------------
00263     // static public methods
00264     // ---------------------
00266     static IIRenderMgr* GetActiveIIRenderMgr();
00268     static unsigned int GetNumIIRenderMgrs();
00270     static IIRenderMgr* GetIIRenderMgr(unsigned int i);
00271 };
00272 
00273 
00274 class IQuadMenuContext;
00275 
00276 // I_RENDER is passed as the id parameter to a renderer's implementation of
00277 // virtual void* Animatable::GetInterface(ULONG id)
00278 // the renderer returns a pointer to a class IInteractiveRender instance if it supports interactive rendering,
00279 // otherwise the default implementation will return NULL, indicating that interactive rendering is not supported.
00280 // NOTE: The value must be greather than I_USERINTERFACE in AnimatableInterfaceIDs.h
00281 enum { I_RENDER_ID = 0x12345678 }; 
00282 
00283 // Abstract interface class for a renderer supporting reshading - version 1
00284 // -----------------------------------------------------------------------------
00285 // -----------------------------------------------------------------------------
00286 
00314 class IInteractiveRender : public InterfaceServer
00315 
00316 //  PURPOSE:
00317 //    Abstract class (Interface) for a a renderer supporting interactive rendering
00318 //
00319 //  NOTES:
00320 //    created:  04.13.00 - mjm
00321 //
00322 // -----------------------------------------------------------------------------
00323 // -----------------------------------------------------------------------------
00324 
00325 {
00326 public:
00327     // notification of begin and end of interactive rendering
00355     virtual void BeginSession() = 0;
00358     virtual void EndSession() = 0;
00359 
00360     // sets/gets the owner window (to be passed to renderer, if necessary)
00368     virtual void SetOwnerWnd(HWND hOwnerWnd) = 0;
00370     virtual HWND GetOwnerWnd() const = 0;
00371 
00372     // sets/gets the pointer to the interactive rendering manager
00378     virtual void SetIIRenderMgr(IIRenderMgr *pIIRenderMgr) = 0;
00385     virtual IIRenderMgr *GetIIRenderMgr(IIRenderMgr *pIIRenderMgr) const = 0;
00386 
00387     // sets/gets the bitmap to be rendered to
00396     virtual void SetBitmap(Bitmap *pDestBitmap) = 0;
00403     virtual Bitmap *GetBitmap(Bitmap *pDestBitmap) const = 0;
00404 
00405     // sets/gets the scene root node
00414     virtual void SetSceneINode(INode *pSceneINode) = 0;
00416     virtual INode *GetSceneINode() const = 0;
00417 
00418     // sets/gets whether to use the ViewINode. if false, ViewParams should be used
00426     virtual void SetUseViewINode(bool bUseViewINode) = 0;
00429     virtual bool GetUseViewINode() const = 0;
00430 
00431     // sets/gets the ViewINode
00437     virtual void SetViewINode(INode *pViewINode) = 0;
00440     virtual INode *GetViewINode() const = 0;
00441 
00442     // sets/gets the ViewExp
00449     virtual void SetViewExp(ViewExp *pViewExp) = 0;
00452     virtual ViewExp *GetViewExp() const = 0;
00453 
00454     // sets/gets the region of the bitmap to be rendered. if Box2::IsEmpty() returns true, it indicates to render entire bitmap
00466     virtual void SetRegion(const Box2 &region) = 0;
00470     virtual const Box2 &GetRegion() const = 0;
00471 
00472     // sets/gets the lights to be used in abscence of scene lights
00483     virtual void SetDefaultLights(DefaultLight *pDefLights, int numDefLights) = 0;
00489     virtual const DefaultLight *GetDefaultLights(int &numDefLights) const = 0;
00490 
00491     // sets/gets the pointer to progress callback object
00500     virtual void SetProgressCallback(IRenderProgressCallback *pProgCB) = 0;
00503     virtual const IRenderProgressCallback *GetProgressCallback() const = 0;
00504 
00505     // renders the bitmap using default rendering functionality
00512     virtual void Render(Bitmap *pDestBitmap) = 0;
00513 
00514     // returns the NodeRenderID for a given bitmap pixel location
00515     // Return 0 if there is no node
00524     virtual ULONG GetNodeHandle(int x, int y) = 0;
00525 
00526     // fills the sBBox parameter with the screen space bounding box for a given INode. returns true if successful, otherwise false.
00535     virtual bool GetScreenBBox(Box2& sBBox, INode *pINode) = 0;
00536 
00537     // returns ActionTableId for any action items the reshading renderer may implement. returns 0 if none.
00542     virtual ActionTableId GetActionTableId() = 0;
00543 
00544     // returns ActionCallback for any action items the reshading renderer may implement. returns NULL if none.
00548     virtual ActionCallback *GetActionCallback() = 0;
00549 
00550     // access to additional method interfaces
00555     virtual void *GetInterface() { return NULL; }
00556 
00557     // find out if the renderer is currently rendering
00569     virtual BOOL IsRendering() = 0;
00570 
00571 };