Cortex  10.0.0-a4
ParameterisedHolder.h
1 //
3 // Copyright (c) 2010, Image Engine Design Inc. All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
7 // met:
8 //
9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 //
12 // * Redistributions in binary form must reproduce the above copyright
13 // notice, this list of conditions and the following disclaimer in the
14 // documentation and/or other materials provided with the distribution.
15 //
16 // * Neither the name of Image Engine Design nor the names of any
17 // other contributors to this software may be used to endorse or
18 // promote products derived from this software without specific prior
19 // written permission.
20 //
21 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
22 // IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
23 // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
25 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
28 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 //
34 
35 #ifndef IECORENUKE_PARAMETERISEDHOLDER_H
36 #define IECORENUKE_PARAMETERISEDHOLDER_H
37 
38 // Forward declaration of Nuke stuff
39 
40 class Node; // Don't know why this isn't in a namespace
41 namespace DD
42 {
43 namespace Image
44 {
45  class Op;
46 } // namespace Image
47 } // namespace DD
48 
49 #include "IECore/Parameter.h"
50 #include "IECore/Parameterised.h"
51 
52 #include "IECoreNuke/ParameterHandler.h"
53 #include "IECoreNuke/ObjectKnob.h"
54 
55 namespace IECoreNuke
56 {
57 
58 template<typename BaseType>
59 class ParameterisedHolder : public BaseType
60 {
61 
62  public :
63 
64  ParameterisedHolder( Node *node );
65  virtual ~ParameterisedHolder();
66 
69 
70  virtual int minimum_inputs() const;
72  virtual int maximum_inputs() const;
73  virtual bool test_input( int input, DD::Image::Op *op ) const;
75  virtual void knobs( DD::Image::Knob_Callback f );
77  virtual int knob_changed( DD::Image::Knob *knob );
79  virtual void _validate( bool forReal );
81 
87  IECore::ConstRunTimeTypedPtr parameterised();
89  const IECore::ParameterisedInterface *parameterisedInterface();
90 
91  protected :
92 
93  void setParameterValuesFromInputs();
94  void setParameterValues();
95  void setKnobValues();
96 
99  void buildParameterKnobHandles( DD::Image::ViewerContext *ctx ) const;
100 
101  private :
102 
103  // class specification
105  ObjectKnob *m_classSpecifierKnob;
106  DD::Image::Knob *m_versionChooserKnob; // for display of class name and user selection of version
107  DD::Image::Knob *m_classReloadKnob; // for user to trigger reloading
108  DD::Image::Knob *m_classDividerKnob;
109  void updateVersionChooser();
110 
111  // class loading
113  IECore::RunTimeTypedPtr m_parameterised;
114  IECore::ConstObjectPtr m_currentClassSpecification; // contents of m_classSpecifierKnob last time we updated
115  // loads and returns an instance of the class specified by m_classSpecifierKnob.
116  // this does not set m_parameterised.
117  IECore::RunTimeTypedPtr loadClass( bool refreshLoader );
118  // makes sure that m_parameterised is up to date with the class and state dictated by
119  // m_classSpecifierKnob, and also makes sure that m_parameterHandler is valid.
120  void updateParameterised( bool reload );
121 
122  // knob creation
124  ParameterHandlerPtr m_parameterHandler;
125  size_t m_numParameterKnobs;
126  void replaceKnobs();
127  static void parameterKnobs( void *that, DD::Image::Knob_Callback f );
128 
129  // FnParameterisedHolder support
131 
132  DD::Image::Knob *m_getParameterisedKnob; // this knob triggers a simulated getParameterised function.
133  static IECore::RunTimeTypedPtr getParameterisedResult(); // and this function retrieves the result
134 
135  DD::Image::Knob *m_modifiedParametersKnob; // this knob triggers a simulated function call to do the work of FnParameterisedHolder.parameterModificationContext()
136  static void setModifiedParametersInput( IECore::RunTimeTypedPtr parameterised ); // and this function specifies the parameter values to set the knobs from
137 
138  friend void bindFnParameterisedHolder();
139 
140 };
141 
142 typedef ParameterisedHolder<DD::Image::Op> ParameterisedHolderOp;
143 
144 } // namespace IECoreNuke
145 
146 #endif // IECORENUKE_PARAMETERISEDHOLDER_H
Definition: ParameterisedInterface.h:50
The IECoreNuke namespace holds all the functionality of libIECoreNuke.
Definition: BoolParameterHandler.h:40
Definition: ParameterisedHolder.h:41