HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TIL_TileMPlay.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: TIL_TileMPlay (C++)
7  *
8  * COMMENTS: This class writes to deep raster tiles to a Net socket.
9  *
10  */
11 
12 #ifndef __TIL_TileMPlay_H__
13 #define __TIL_TileMPlay_H__
14 
15 #include "TIL_API.h"
16 class TIL_Sequence;
17 class TIL_Tile;
18 class UT_NetPacket;
19 class UT_NetSocket;
20 
21 #include <IMG/IMG_TileDevice.h>
22 #include <UT/UT_IntArray.h>
23 #include <UT/UT_Lock.h>
24 #include <UT/UT_SysClone.h>
25 #include <UT/UT_StopWatch.h>
26 
27 template<typename T>
28 class UT_Vector3T;
29 
30 // The size of the UT_NetPacket buffer
31 static const size_t TIL_MPLAY_PACKETSIZE = 65536;
32 // Tile info data structure size, as a number of integers
33 static const int TIL_MPLAY_TILEDATASIZE = 5;
34 
36 {
37 public:
38  TIL_TileMPlay(int middle, bool isflipbook);
39  ~TIL_TileMPlay() override;
40 
41  // If enabled, this will not start another MPlay session. Instead, the
42  // open will fail. This is generally used for rendering sequences to a
43  // single MPlay session. Interruption to that MPlay (exit, not listening)
44  // will stop the sequence from rendering.
45  void noNewMPlay(bool enable);
46 
47  // If enabled, this class sends the PID to the host, which is
48  // used to terminate this process when rendering is stopped. If disabled,
49  // the PID is not sent and the host does not terminate the client.
50  void setSendPIDFlag(bool flag);
51 
52  const char *className() const override;
53  void getDescription(UT_WorkBuffer &wbuf) const override;
54 
55  int open(const IMG_TileOptions &finfo,
56  int xres, int yres, int twidth, int theight,
57  fpreal aspect) override;
58 
59  int openMulti(IMG_TileOptionList &flist,
60  int xres, int yres,
61  int twidth, int theight, fpreal aspect
62  ) override;
63 
64  void setWhitePoint(fpreal w) override;
65 
66  void writeCustomTag(const char *tagname, int size,
67  const char *const *values) override;
68 
69  int writeTile(const void *data,
70  unsigned x0, unsigned x1,
71  unsigned y0, unsigned y1) override;
72  bool writeSamples(
73  int nsamples,
74  int floats_per_sample,
76  const float *data) override;
77 
78  void flush() override;
79  int close(bool keep_alive=false) override;
80 
81  // more convienient functions for COPs.
82  int openDeep(const char *filename,
83  const TIL_Sequence &info,
84  int tilex, int tiley,
85  bool startnew=false,
86  const IMG_TileOptions *finfo=0);
87 
88  int writeDeepTile(int plane_index, const void *data,
89  int x0, int x1, int y0, int y1);
90  void setStatusMsg(const char *msg);
91 
92  bool isOpen() const { return mySocket && myPacket; }
93  bool checkInterrupt() { drainSocket(); return isOpen(); }
94 
95  bool getMouseClickPosition(int &x, int &y) const override;
96  float getMouseClickRadius() const override;
97 
98  void setMouseClickPosition(int x, int y)
99  { myMouse[0] =x; myMouse[1] =y; }
100 
101  void streakEdges(int x1, int y1, int x2, int y2,
102  int plane = -1);
103 
104  bool wasRemoteQuitRequested() { return myQuitFlag; }
105 
106  // returns the name of the lock file.
107  static void getLockFile(UT_WorkBuffer &buf, bool isflipbook,
108  const char *label);
109 
110  void terminateOnConnectionLost(bool) override;
111 
112  bool wantsHoudiniPort() const override { return true; }
113 
114  bool isInteractive() const override { return true; }
115 
116  static void enableColorCorrection(bool enable);
117  static void setColorCorrectionLUT(bool enable, const char *lut);
118  static void setColorCorrectionGamma(bool enable, fpreal gamma);
119 
120  void setStyleSheets(UT_StringArray& style_sheets) override
121  { myStyleSheetData = style_sheets; }
122 private:
123  int openSocket(const char *host, int port,
124  const char *label);
125  bool drainSocket(bool keep_alive=false);
126  void clean();
127 
128 private:
129  void sendTileOptions(const IMG_TileOptions &options);
130 
131  TIL_Sequence *mySequence;
132  UT_Lock myWriteLock;
133  bool myIsFlipbook;
134  UT_IntArray myPlaneIndex;
135  UT_IntArray myPlaneSize;
136 
137  UT_NetSocket *mySocket;
138  UT_NetPacket *myPacket;
139  int myBPP, myMiddle;
140  float myMouse[2];
141  float myMouseRadius;
142  bool myQuitFlag;
143  UT_StopWatch myFlushTimer;
144  bool myNoNewMPlayFlag;
145  bool mySendPIDFlag;
146 
147  UT_StringArray myStyleSheetData;
148 };
149 
150 #endif
virtual void setWhitePoint(fpreal white)
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glcorearb.h:2540
bool checkInterrupt()
Definition: TIL_TileMPlay.h:93
GT_API const UT_StringHolder filename
virtual void writeCustomTag(const char *tagname, int size, const char *const *values)
GLuint GLsizei const GLchar * label
Definition: glcorearb.h:2545
virtual void getDescription(UT_WorkBuffer &wbuf) const
virtual float getMouseClickRadius() const
virtual int openMulti(IMG_TileOptionList &flist, int xres, int yres, int tile_width, int tile_height, fpreal aspect)
GLint y
Definition: glcorearb.h:103
3D Vector class.
GLdouble GLdouble x2
Definition: glad.h:2349
virtual bool getMouseClickPosition(int &x, int &y) const
void setMouseClickPosition(int x, int y)
Definition: TIL_TileMPlay.h:98
virtual void terminateOnConnectionLost(bool)
virtual bool writeSamples(int nsamples, int floats_per_sample, const UT_Vector3T< int > *samples, const float *data)
virtual const char * className() const =0
virtual int open(const IMG_TileOptions &info, int xres, int yres, int tile_device, int tile_height, fpreal aspect)=0
Open the device.
virtual int close(bool keep_alive=false)=0
GLdouble y1
Definition: glad.h:2349
GLint GLenum GLint x
Definition: glcorearb.h:409
GLsizei samples
Definition: glcorearb.h:1298
virtual int writeTile(const void *data, unsigned x0, unsigned x1, unsigned y0, unsigned y1)=0
GLsizeiptr size
Definition: glcorearb.h:664
bool isInteractive() const override
GLenum GLsizei GLsizei GLint * values
Definition: glcorearb.h:1602
fpreal64 fpreal
Definition: SYS_Types.h:277
bool wasRemoteQuitRequested()
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:857
virtual void flush()
void setStyleSheets(UT_StringArray &style_sheets) override
GLdouble GLdouble GLdouble y2
Definition: glad.h:2349
bool wantsHoudiniPort() const override
bool isOpen() const
Definition: TIL_TileMPlay.h:92
#define TIL_API
Definition: TIL_API.h:10
Definition: format.h:895