HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MSS_CustomBrushState.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018
3  * Side Effects Software Inc. All rights reserved.
4  *
5  * Redistribution and use of Houdini Development Kit samples in source and
6  * binary forms, with or without modification, are permitted provided that the
7  * following conditions are met:
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  * 2. The name of Side Effects Software may not be used to endorse or
11  * promote products derived from this software without specific prior
12  * written permission.
13  *
14  * THIS SOFTWARE IS PROVIDED BY SIDE EFFECTS SOFTWARE `AS IS' AND ANY EXPRESS
15  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
17  * NO EVENT SHALL SIDE EFFECTS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
18  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
19  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
20  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
21  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
23  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  *
25  *----------------------------------------------------------------------------
26  * This code is for creating the state to go with this op.
27 */
28 
29 #ifndef __MSS_CustomBrushState_H__
30 #define __MSS_CustomBrushState_H__
31 
32 #include <MSS/MSS_SingleOpState.h>
33 #include <DM/DM_Detail.h>
34 #include <GU/GU_Detail.h>
35 
36 class JEDI_View;
37 
38 namespace HDK_Sample {
40 {
41 public:
42  MSS_CustomBrushState(JEDI_View &view, PI_StateTemplate &templ,
43  BM_SceneManager *scene,
44  const char *cursor = BM_DEFAULT_CURSOR);
45  virtual ~MSS_CustomBrushState();
46 
47  /// used by DM to create our state
48  static BM_State *ourConstructor(BM_View &view, PI_StateTemplate &templ,
49  BM_SceneManager *scene);
50 
51  /// parameters for this state
53 
54  /// The name and type of this class:
55  virtual const char *className() const;
56 
57 protected:
58  /// called when the user enters the state
59  virtual int enter(BM_SimpleState::BM_EntryType how);
60 
61  /// called when the user leaves the state
62  virtual void exit();
63 
64  /// called when the user temporarily leaves the state (mouse leaves the
65  /// viewport)
66  virtual void interrupt(BM_SimpleState * = 0);
67 
68  /// called when the user returns to the state after leaving temporarily
69  /// (mouse re-enters the viewport)
70  virtual void resume(BM_SimpleState * = 0);
71 
72  /// Respond to mouse or keyboard events.
73  virtual int handleMouseEvent(UI_Event *event);
74 
75  /// Render the brush "cursor" geometry:
76  virtual void doRender(RE_Render *r, int x, int y, int ghost);
77 
78  /// sets the prompt's text
79  virtual void updatePrompt();
80 
81  /// repositions the brush's guide geometry
82  void updateBrush(int x, int y);
83 
84 private:
85  bool myIsBrushVisible;
86  DM_Detail myBrushHandle;
87  GU_Detail myBrushCursor;
88  UT_Matrix4 myBrushCursorXform;
89  float myBrushRadius;
90 
91  /// These are used track the resizing of the cursor in the viewport
92  bool myResizingCursor;
93  short myLastCursorX, myLastCursorY;
94  short myResizeCursorX, myResizeCursorY;
95 };
96 } // End HDK_Sample namespace
97 
98 #endif
virtual void exit()
called when the user leaves the state
virtual int enter(BM_SimpleState::BM_EntryType how)
called when the user enters the state
static PRM_Template * ourTemplateList
parameters for this state
virtual void interrupt(BM_SimpleState *=0)
GLint y
Definition: glcorearb.h:102
virtual int handleMouseEvent(UI_Event *event)
Respond to mouse or keyboard events.
struct _cl_event * event
Definition: glcorearb.h:2960
#define BM_DEFAULT_CURSOR
Definition: BM_OpState.h:35
static BM_State * ourConstructor(BM_View &view, PI_StateTemplate &templ, BM_SceneManager *scene)
used by DM to create our state
MSS_CustomBrushState(JEDI_View &view, PI_StateTemplate &templ, BM_SceneManager *scene, const char *cursor=BM_DEFAULT_CURSOR)
virtual void updatePrompt()
sets the prompt's text
virtual void doRender(RE_Render *r, int x, int y, int ghost)
Render the brush "cursor" geometry:
void updateBrush(int x, int y)
repositions the brush's guide geometry
GLint GLenum GLint x
Definition: glcorearb.h:408
GLboolean r
Definition: glcorearb.h:1221
virtual const char * className() const
The name and type of this class:
virtual void resume(BM_SimpleState *=0)