#ifndef _SPRETICLE_LOC_H_
#define _SPRETICLE_LOC_H_
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <maya/MPxLocatorNode.h>
#include <maya/MString.h>
#include <maya/MTypeId.h>
#include <maya/MPlug.h>
#include <maya/MDataBlock.h>
#include <maya/MDataHandle.h>
#include <maya/MColor.h>
#include <maya/M3dView.h>
#include <maya/MFnNumericAttribute.h>
#include <maya/MFnEnumAttribute.h>
#include <maya/MFnCompoundAttribute.h>
#include <maya/MFnUnitAttribute.h>
#include <maya/MFnTypedAttribute.h>
#include <maya/MFnDependencyNode.h>
#include <maya/MIOStream.h>
#include <maya/MDagPath.h>
#include <maya/MFnCamera.h>
#include <maya/MVector.h>
#include <maya/MMatrix.h>
#include <maya/MFnMatrixData.h>
#include <maya/MFnStringData.h>
#include <maya/MTime.h>
#include <maya/MGlobal.h>
#include <maya/MFileIO.h>
#include <maya/MFileObject.h>
#include <maya/MDrawContext.h>
#include <maya/MUserData.h>
#include <maya/MDrawRegistry.h>
#include <maya/MPxDrawOverride.h>
#include <maya/MViewport2Renderer.h>
class Geom
{
public:
double x1, x2;
double y1, y2;
double x, y;
bool isValid;
Geom& operator=(const Geom& rh) {
x1 = rh.x1 ;
x2 = rh.x2 ;
y1 = rh.y1 ;
y2 = rh.y2 ;
x = rh.x ;
y = rh.y ;
lineColor = rh.lineColor ;
maskColor = rh.maskColor ;
isValid = rh.isValid ;
return *this;
}
};
class Aspect_Ratio
{
public:
double aspectRatio;
int displayMode;
bool displaySafeAction;
bool displaySafeTitle;
Geom aspectGeom;
Geom safeActionGeom;
Geom safeTitleGeom;
Aspect_Ratio& operator=(const Aspect_Ratio& rh) {
aspectRatio = rh.aspectRatio ;
displayMode = rh.displayMode ;
displaySafeAction = rh.displaySafeAction;
displaySafeTitle = rh.displaySafeTitle ;
aspectGeom = rh.aspectGeom ;
safeActionGeom = rh.safeActionGeom ;
safeTitleGeom = rh.safeTitleGeom ;
return *this;
}
};
class PanScan : public Aspect_Ratio
{
public:
double panScanRatio;
double panScanOffset;
PanScan& operator= (const PanScan& rh) {
Aspect_Ratio::operator=(rh);
panScanRatio = rh.panScanRatio;
panScanOffset = rh.panScanOffset;
return *this;
}
};
class Filmback
{
public:
double horizontalFilmAperture;
double verticalFilmAperture;
double soundTrackWidth;
double displayFilmGate;
double horizontalImageAperture;
double verticalImageAperture;
double displayProjGate;
double horizontalProjectionGate;
double verticalProjectionGate;
bool displaySafeAction;
double horizontalSafeAction;
double verticalSafeAction;
bool displaySafeTitle;
double horizontalSafeTitle;
double verticalSafeTitle;
Geom filmbackGeom;
Geom safeActionGeom;
Geom safeTitleGeom;
Geom imageGeom;
Geom projGeom;
Filmback& operator=(const Filmback& rh)
{
horizontalFilmAperture = rh.horizontalFilmAperture ;
verticalFilmAperture = rh.verticalFilmAperture ;
soundTrackWidth = rh.soundTrackWidth ;
horizontalImageAperture = rh.horizontalImageAperture ;
verticalImageAperture = rh.verticalImageAperture ;
displayFilmGate = rh.displayFilmGate ;
horizontalProjectionGate = rh.horizontalProjectionGate;
verticalProjectionGate = rh.verticalProjectionGate ;
horizontalSafeAction = rh.horizontalSafeAction ;
verticalSafeAction = rh.verticalSafeAction ;
horizontalSafeTitle = rh.horizontalSafeTitle ;
verticalSafeTitle = rh.verticalSafeTitle ;
displayProjGate = rh.displayProjGate ;
displaySafeAction = rh.displaySafeAction ;
displaySafeTitle = rh.displaySafeTitle ;
filmbackGeom = rh.filmbackGeom ;
safeActionGeom = rh.safeActionGeom ;
safeTitleGeom = rh.safeTitleGeom ;
imageGeom = rh.imageGeom ;
return *this;
}
};
class PadOptions
{
public:
bool usePad;
bool isPadded;
double padAmountX;
double padAmountY;
int displayMode;
Geom padGeom;
PadOptions& operator=(const PadOptions& rh) {
usePad = rh.usePad ;
isPadded = rh.isPadded ;
padAmountX = rh.padAmountX ;
padAmountY = rh.padAmountY ;
displayMode = rh.displayMode;
padGeom = rh.padGeom ;
return *this;
}
};
class Options
{
public:
bool drawingEnabled;
bool enableTextDrawing;
bool displayLineH;
bool displayLineV;
bool displayThirdsH;
bool displayThirdsV;
bool displayCrosshair;
bool useSpRet;
bool driveCameraAperture;
bool useOverscan;
double maximumDistance;
Options& operator=(const Options& rh) {
drawingEnabled = rh.drawingEnabled ;
enableTextDrawing = rh.enableTextDrawing ;
useSpRet = rh.useSpRet ;
displayLineH = rh.displayLineH ;
displayLineV = rh.displayLineV ;
displayThirdsH = rh.displayThirdsH ;
displayThirdsV = rh.displayThirdsV ;
displayCrosshair = rh.displayCrosshair ;
driveCameraAperture = rh.driveCameraAperture;
useOverscan = rh.useOverscan ;
maximumDistance = rh.maximumDistance ;
textColor = rh.textColor ;
lineColor = rh.lineColor ;
return *this;
}
};
class TextData
{
public:
int textType;
int textAlign;
double textPosX;
double textPosY;
int textPosRel;
int textLevel;
int textARLevel;
TextData& operator=(const TextData& rh) {
textType = rh.textType ;
textStr = rh.textStr ;
textAlign = rh.textAlign ;
textPosX = rh.textPosX ;
textPosY = rh.textPosY ;
textPosRel = rh.textPosRel ;
textLevel = rh.textLevel ;
textARLevel = rh.textARLevel;
textColor = rh.textColor ;
return *this;
}
};
class Camera
{
public:
double nearClippingPlane;
double farClippingPlane;
bool isOrtho;
Camera& operator=(const Camera& rh){
nearClippingPlane = rh.nearClippingPlane;
farClippingPlane = rh.farClippingPlane;
isOrtho = rh.isOrtho;
cameraPath = rh.cameraPath;
return *this;
}
};
class spReticleLocData;
{
public:
spReticleLoc();
~spReticleLoc() override;
static void *creator();
bool drawLast()
const override {
return true;}
bool isBounded()
const override {
return true;}
void getDrawData(spReticleLocData& drawData,
const double& portHeight, const double& portWidth);
public:
static MString drawDbClassification;
static MObject HorizontalFilmAperture;
static MObject VerticalFilmAperture;
static MObject HorizontalProjectionGate;
static MObject VerticalProjectionGate;
static MObject DisplayProjectionGate;
static MObject HorizontalSafeAction;
static MObject HorizontalSafeTitle;
static MObject AspectDisplaySafeAction;
static MObject AspectDisplaySafeTitle;
static MObject PanScanDisplaySafeTitle;
static MObject PanScanDisplaySafeAction;
static MObject DriveCameraAperture;
double loadDefault;
bool needRefresh;
private:
MStatus getPadData(spReticleLocData& drawData);
MStatus getFilmbackData(spReticleLocData& drawData);
MStatus getProjectionData(spReticleLocData& drawData);
MStatus getSafeActionData(spReticleLocData& drawData);
MStatus getSafeTitleData(spReticleLocData& drawData);
MStatus getAspectRatioChildren (
MPlug arPlug, Aspect_Ratio & ar );
static bool aspectRatioSortPredicate( const Aspect_Ratio &, const Aspect_Ratio &);
MStatus getAspectRatioData (spReticleLocData& drawData);
bool needToUpdateAspectRatios(spReticleLocData& drawData);
MStatus getPanScanData (PanScan & ps );
MStatus getTextData(spReticleLocData& drawData);
void getCustomTextElement(spReticleLocData& drawData);
bool needToUpdateTextData(spReticleLocData& drawData);
MStatus getOptions(Options& options );
void printAspectRatio ( Aspect_Ratio & ar );
void printPanScan ( PanScan & ps );
void printText ( TextData & td );
void printGeom ( Geom & g );
void printOptions (Options& opt);
void drawMask3D( Geom g1, Geom g2,
double z,
MColor color,
bool sides );
void drawMask( Geom g1, Geom g2,
MColor color,
bool sides,
double ncp);
void drawLine3D(
double x1,
double x2,
double y1,
double y2,
double z,
MColor color,
bool stipple );
void drawLines3D( Geom g,
double z,
MColor color,
bool sides,
bool stipple );
void drawLine(
double x1,
double x2,
double y1,
double y2,
MColor color,
bool stipple,
double ncp );
void drawLines( Geom g,
MColor color,
bool sides,
bool stipple,
double ncp );
void drawInternalTextElements(
M3dView & view);
void drawCustomTextElements(std::vector<TextData> textWhenDraw,
MMatrix wim,
M3dView & view);
};
{
public:
void doCompute();
void calcPortGeom();
void calcFilmbackGeom();
void calcMaskGeom( Geom & g, double w, double h, Geom & gSrc, double wSrc, double hSrc );
void calcFilmbackSafeActionGeom();
void calcFilmbackSafeTitleGeom();
void calcSafeActionGeom( Aspect_Ratio & ar );
void calcSafeTitleGeom( Aspect_Ratio & ar );
void calcAspectGeom( Aspect_Ratio & ar);
void calcPanScanGeom( PanScan & ps );
Filmback oFilmback,filmback;
PadOptions pad;
PanScan panScan;
Geom portGeom;
Options options;
Camera cameraData;
double portWidth;
double portHeight;
double overscan;
double ncp;
int numAspectRatios;
double maximumDist;
std::vector<TextData> text;
std::vector<TextData> textWhenDraw;
std::vector<Aspect_Ratio> ars;
int useReticle;
bool fCustomBoxDraw;
private:
void setDataHelper();
};
{
public:
{
return new spReticleLocDrawOverride(obj);
}
~spReticleLocDrawOverride() override;
const MDagPath& cameraPath)
const override;
const MDagPath& cameraPath)
const override;
protected:
bool mCustomBoxDraw;
private:
spReticleLocDrawOverride(
const MObject& obj);
int loadDefault;
bool needRefresh;
};
#endif