HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MSS_CustomBrushState.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2021
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  ~MSS_CustomBrushState() override;
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  const char *className() const override;
56 
57 protected:
58  /// called when the user enters the state
59  int enter(BM_SimpleState::BM_EntryType how) override;
60 
61  /// called when the user leaves the state
62  void exit() override;
63 
64  /// called when the user temporarily leaves the state (mouse leaves the
65  /// viewport)
66  void interrupt(BM_SimpleState * = 0) override;
67 
68  /// called when the user returns to the state after leaving temporarily
69  /// (mouse re-enters the viewport)
70  void resume(BM_SimpleState * = 0) override;
71 
72  /// Respond to mouse or keyboard events.
73  int handleMouseEvent(UI_Event *event) override;
74 
75  /// Render the brush "cursor" geometry:
76  void doRender(RE_Render *r, int x, int y,
77  int ghost) override;
78 
79  /// sets the prompt's text
80  virtual void updatePrompt();
81 
82  /// repositions the brush's guide geometry
83  void updateBrush(int x, int y);
84 
85 private:
86  bool myIsBrushVisible;
87  DM_Detail myBrushHandle;
88  GU_Detail myBrushCursor;
89  UT_Matrix4 myBrushCursorXform;
90  float myBrushRadius;
91 
92  /// These are used track the resizing of the cursor in the viewport
93  bool myResizingCursor;
94  short myLastCursorX, myLastCursorY;
95  short myResizeCursorX, myResizeCursorY;
96 };
97 } // End HDK_Sample namespace
98 
99 #endif
void interrupt(BM_SimpleState *=0) override
static PRM_Template * ourTemplateList
parameters for this state
int enter(BM_SimpleState::BM_EntryType how) override
called when the user enters the state
#define BM_DEFAULT_CURSOR
Definition: BM_OpState.h:37
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)
GLint GLint GLint GLint GLint x
Definition: glew.h:1252
GLint GLint GLint GLint GLint GLint y
Definition: glew.h:1252
void exit() override
called when the user leaves the state
virtual void updatePrompt()
sets the prompt's text
void updateBrush(int x, int y)
repositions the brush's guide geometry
void resume(BM_SimpleState *=0) override
cl_event event
Definition: glew.h:3695
GLdouble GLdouble GLdouble r
Definition: glew.h:1406
int handleMouseEvent(UI_Event *event) override
Respond to mouse or keyboard events.
const char * className() const override
The name and type of this class:
void doRender(RE_Render *r, int x, int y, int ghost) override
Render the brush "cursor" geometry: