HxCompModule.h
1 /*
2 Copyright 1999-2016 FEI, SAS
3 Copyright 1995-2016, ZIB Berlin
4 ALL RIGHTS RESERVED.
5 
6 AvizoŽ is a registered trademark of FEI, SAS
7 AmiraŽ is a registered trademark of ZIB.
8 
9 AvizoŽ and AmiraŽ are being jointly developed by Zuse Institute Berlin and FEI, SAS.
10 HardCopy, MeshViz, VolumeViz, TerrainViz are marks of FEI, SAS
11 FEI, SAS is a source licensee of OpenGLŽ, Open InventorŽ
12 from Silicon Graphics, Inc. OpenGLŽ and Open InventorŽ are
13 registered trademark of Silicon Graphics, Inc. All other products and
14 company names are trademarks or registered trademarks of
15 their respective companies.
16 
17 FEI, SAS accepts no liability to any
18 party for loss or damage caused by errors or omissions or by
19 statements of any kind in this publication, whether such errors
20 result from accident, negligence or any other cause. FEI assumes
21 no liability for incidental or consequential damages arising
22 from the use of information in this publication. FEI provides no
23 warranties regarding the information contained in this
24 publication, whether expressed, implied, or statutory, including
25 implied warranties of merchantability or fitness for a
26 particular purpose.
27 
28 FEI also does not assume any liability for links from this
29 publication to publications from other companies, organizations
30 or individuals. FEI does not imply endorsement of any specific
31 company, organization or individual through offering links to
32 this content. All information provided within this publication
33 is subject to change at any time and is provided for
34 informational purposes only by FEI. Copyright 1994-2016 by
35 FEI, SAS Merignac, France.
36 
37 */
38 
39 #if defined(HX_INTERNAL_CLASS_WARN)
40 #undef HX_INTERNAL_CLASS_WARN
41 #define HX_INTERNAL_CLASS_WARN_HXCOMPMODULE
42 #endif
43 #pragma warning(push)
44 #pragma warning(disable:4996)
45 
48 #ifndef _HX_COMP_MODULE_
49 #define _HX_COMP_MODULE_
50 
51 #include <hxcore/HxBatchModule.h>
52 #include <hxcore/HxData.h>
53 #include <mclib/McHandle.h>
54 
55 class HxMasterConnection;
56 
77 class HXCORE_API HxCompModule : public HxBatchModule {
78 
79  HX_ABSTRACT_HEADER(HxCompModule);
80 
81  public:
91  void setNameOfResultSlot(int id, const char* name);
92 
112  void setResult(int id, HxData* result, unsigned int mask=0xffffffff);
113 
124  void insertResult(int pos, HxData* result, unsigned int mask=0xffffffff);
125 
132  void removeResult(int pos);
133 
142  void setResult(HxData* result, unsigned int mask=0xffffffff);
143 
153  void setResult(const char* name, HxData* result, unsigned int mask=0xffffffff);
154 
162  HxData* getResult(int id=0) const;
163 
172  HxData* getResult(const char* name) const;
173 
184  int getTouchTime(int id=0) const;
185 
202  virtual int checkResult(int& id, HxData* result);
203 
211  virtual void resultChanged(int id);
212 
226  virtual void fire(int shouldCompute=1);
227 
228 
234  virtual McColor getIconColor();
235 
244  virtual int parse(Tcl_Interp* interpreter, int argc, char **argv);
245 
252  virtual void saveUpdate(FILE* fp);
253 
259  int getNumResultSlots() const;
260 
266  int getNewResultSlotID() const;
267 
273  void setApplyTransfOfSourceToResult(bool apply);
274 
280  bool getApplyTransfOfSourceToResult();
281 
285  void applyTransformToResult();
286 
290  virtual void update();
291 
299  virtual bool canCreateData(HxData* data, QString &createCmd);
300 
301  protected:
307  HxCompModule(const McTypeInfo* dataType, McInterfaceOwner* owner = 0, QxObjectNotifier* notifier = 0);
308 
312  virtual ~HxCompModule();
313 
322  virtual HxData* createResult(const QString & name);
323 
324  /* Global touch time of the compute module. This time will be set
325  whenever setResult() is called. It will be reset back to -1
326  if any port has changed and fire is called. */
327  HxINTERNAL int resultTouchTime;
328  HxINTERNAL int blockNotify;
329 
330  class ResultSlot;
331  HxINTERNAL McDArray<ResultSlot*> resultSlots;
332 
339  HxINTERNAL ResultSlot* findResultSlot(int id) const;
340 
347  HxINTERNAL ResultSlot* findResultSlotFromString(const char* str) const;
348 
355  HxINTERNAL ResultSlot* findResultSlotFromData(HxData * data) const;
356 
357  HxINTERNAL bool m_applyTransfOfSourceToResult;
358 
367  HxINTERNAL void recordNewResultInHistoryLog( int id, HxData* res );
368 
374  HxINTERNAL void recordInputUpdateInHistoryLog( HxConnection* inputPort );
375 
382  HxINTERNAL void customizeApplyCommandInHistoryLog( HxData* resultData, QString customApplyCommand );
383 
389  HxINTERNAL void updateInputStateCommandInHistoryLog( HxConnection* inputPort );
390 
396  HxINTERNAL int getModuleTouchTime();
397 
398  friend class HxMasterConnection;
399 
405  bool isRangeCalibrationCopyEnabled() const;
411  void enableRangeCalibrationCopy( bool enable );
412 
426  virtual void copyRangeCalibration( const HxData* input, HxData* output, float scale = 1.0f, float offset = 0.0f ) const;
427 
432  bool isMaterialBundlesCopyEnabled() const;
433 
438  void enableMaterialBundlesCopy( bool isEnabled );
439 
444  void copyMaterialBundles( HxData* output ) const;
445 
446  // Flag indicating whether the range calibration of module input should be copied to the output or not
447  bool m_isRangeCalibrationCopyEnabled;
448 
449  // Flag indicating whether the material bundle of module input should be copied to the output or not
450  bool m_isMaterialBundlesCopyEnabled;
451 
452  HxINTERNAL int touchTime;
453 };
454 
455 #endif
456 
458 
459 #pragma warning(pop)
460 
461 #if defined(HX_INTERNAL_CLASS_WARN_HXCOMPMODULE)
462 #undef HX_INTERNAL_CLASS_WARN_HXCOMPMODULE
463 #define HX_INTERNAL_CLASS_WARN
464 #endif
Port representing inter-object connections.
Definition: HxConnection.h:78
Base class for compute modules.
Definition: HxCompModule.h:77