Commit 6bdc21a5 authored by L. E. Segovia's avatar L. E. Segovia

Hide unused SeExpr controls behind flags

It seems Disney shipped three unaccessible widgets with their library:
- ExprMain (a sorta executable entrypoint inside the library)
- animCurve (SeExpr primitive for animation curves, unavailable in the open source edition of the parser, yet available as an UI widget)
- deepWater (SeExpr primitive for deep water spectrums, same as above)

This commit also enables the relevant features in the SIP header.
parent c9bef137
......@@ -35,19 +35,41 @@ if (Qt5_FOUND OR QT4_FOUND)
BuildParserScanner(ExprSpecParserLex ExprSpecParser ExprSpec
editor_parser_cpp)
option(ENABLE_DEEPWATER "Whether to build controls for displaying a deep water spectrum" FALSE)
option(ENABLE_ANIMCURVE "Whether to build controls for anim curves" FALSE)
option(ENABLE_EXPRMAIN "Whether to build the ExprMain entrypoint" FALSE)
set(EDITOR_MOC_HDRS ExprBrowser.h ExprColorCurve.h
ExprColorSwatch.h ExprControlCollection.h
ExprControl.h ExprCurve.h ExprDialog.h ExprEditor.h
ExprFileDialog.h ExprGrapher2d.h ExprPopupDoc.h
ExprShortEdit.h ExprDeepWater.h)
ExprShortEdit.h)
set(EDITOR_CPPS ExprFileDialog.cpp ExprControl.cpp
ExprEditor.cpp ExprMain.cpp ExprShortEdit.cpp
ExprEditor.cpp ExprShortEdit.cpp
ExprCurve.cpp ExprColorCurve.cpp ExprColorSwatch.cpp
EditableExpression.cpp ExprPopupDoc.cpp
ExprCompletionModel.cpp ExprDialog.cpp
ExprControlCollection.cpp ExprGrapher2d.cpp ExprBrowser.cpp
BasicExpression.cpp ExprDeepWater.cpp)
BasicExpression.cpp)
if (ENABLE_DEEPWATER)
add_definitions(-DSEEXPR_ENABLE_DEEPWATER)
set(EDITOR_MOC_HDRS ${EDITOR_MOC_HDRS} ExprDeepWater.h)
set(EDITOR_CPPS ${EDITOR_CPPS} ExprDeepWater.cpp)
set(PYQT_EXPORT_DEEPWATER "")
else()
set(PYQT_EXPORT_DEEPWATER "-x SEEXPR_ENABLE_DEEPWATER")
endif()
if (ENABLE_ANIMCURVE)
add_definitions(-DSEEXPR_ENABLE_ANIMCURVE)
endif()
if (ENABLE_EXPRMAIN)
set(EDITOR_CPPS ${EDITOR_CPPS} ExprMain.cpp)
endif()
if (ENABLE_QT5)
qt5_wrap_cpp(EDITOR_MOC_SRCS ${EDITOR_MOC_HDRS})
......@@ -135,6 +157,7 @@ if (Qt5_FOUND OR QT4_FOUND)
## Install library and includes
install(TARGETS SeExpr2Editor DESTINATION ${CMAKE_INSTALL_LIBDIR})
# TODO exclude files as per animlib/deepwater/animcurve -- amyspark
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${INCLUDE_DIR}/UI
FILES_MATCHING PATTERN "*.h")
......@@ -187,6 +210,7 @@ if (Qt5_FOUND OR QT4_FOUND)
${PYQT_SIP_FLAGS}
-j 1
-I. -I${PYQT_SIP_DIR} -I${SIP_INCLUDE_DIR}
${PYQT_EXPORT_DEEPWATER}
${CMAKE_CURRENT_SOURCE_DIR}/SeExpr2Editor.sip
VERBATIM)
......
......@@ -24,11 +24,15 @@
#include <SeExpr2/Curve.h>
#include <cstdio>
#include <cstring>
#ifdef SEEXPR_ENABLE_ANIMCURVE
#ifdef SEEXPR_USE_ANIMLIB
#include <animlib/AnimCurve.h>
#include <animlib/AnimKeyframe.h>
#endif
#endif // SEEXPR_USE_ANIMLIB
#endif // SEEXPR_ENABLE_ANIMCURVE
#ifdef SEEXPR_ENABLE_DEEPWATER
#include <ExprDeepWater.h>
#endif
inline void printVal(std::stringstream& stream, double v) { stream << v; }
inline void printVal(std::stringstream& stream, const SeExpr2::Vec3d& v) {
......@@ -212,6 +216,7 @@ struct GenericCurveEditable : public Editable {
typedef GenericCurveEditable<SeExpr2::Vec3d> ColorCurveEditable;
typedef GenericCurveEditable<double> CurveEditable;
#ifdef SEEXPR_ENABLE_ANIMCURVE
class AnimCurveEditable : public Editable {
public:
std::string name;
......@@ -275,6 +280,7 @@ public:
return false;
}
};
#endif
class ColorSwatchEditable : public Editable {
public:
......@@ -330,6 +336,7 @@ public:
}
};
#ifdef SEEXPR_ENABLE_DEEPWATER
class DeepWaterEditable : public Editable {
public:
SeDeepWaterParams params;
......@@ -370,5 +377,6 @@ public:
return false;
}
};
#endif // SEEXPR_ENABLE_DEEPWATER
#endif
......@@ -52,6 +52,7 @@
#include "ExprFileDialog.h"
#include "Editable.h"
#ifdef SEEXPR_ENABLE_ANIMCURVE
/* XPM */
static const char* refreshXPM[] = {
"20 20 4 1", "# c #303030", "a c #585858", "b c #c3c3c3",
......@@ -71,6 +72,7 @@ static const char* graphXPM[] = {
"..bb....bb#bbb......", "##bb####bbbbb#######", ".bb......bbb....c.c.", ".bb.......#......c..",
".b........#.....c.c.", "bb........#.........", "b.........#.........", "..........#.........",
"..........#.........", "..........#........."};
#endif
/* XPM */
static const char* directoryXPM[] = {
......@@ -600,6 +602,7 @@ public:
#endif
};
#ifdef SEEXPR_ENABLE_ANIMCURVE
AnimCurveControl::AnimCurveControl(int id, AnimCurveEditable* editable)
: ExprControl(id, editable, false), _editable(editable) {
......@@ -679,6 +682,7 @@ void AnimCurveControl::editGraphClicked() {
void AnimCurveControl::setAnimCurveCallback(AnimCurveCallback newCallback) { callback = newCallback; }
AnimCurveControl::AnimCurveCallback AnimCurveControl::callback = 0;
#endif
// Editing widget for color swatch
ColorSwatchControl::ColorSwatchControl(int id, ColorSwatchEditable* editable)
......@@ -727,6 +731,8 @@ void ColorSwatchControl::buildSwatchWidget() {
hbox->addWidget(_swatch);
}
#ifdef SEEXPR_ENABLE_DEEPWATER
DeepWaterControl::DeepWaterControl(int id, DeepWaterEditable* editable)
: ExprControl(id, editable, false), _deepWaterEditable(editable) {
_deepWater = new ExprDeepWater(this);
......@@ -742,3 +748,4 @@ void DeepWaterControl::deepWaterChanged() {
emit controlChanged(_id);
}
}
#endif
......@@ -27,7 +27,9 @@
#include "ExprCurve.h"
#include "ExprColorCurve.h"
#ifdef SEEXPR_ENABLE_DEEPWATER
#include "ExprDeepWater.h"
#endif
class QLabel;
class ExprColorCurve;
......@@ -37,18 +39,24 @@ class Editable;
class StringEditable;
class VectorEditable;
class NumberEditable;
#ifdef SEEXPR_ENABLE_ANIMCURVE
class AnimCurveEditable;
#endif
class ColorSwatchEditable;
class ExprColorSwatchWidget;
template <class TVAL>
struct GenericCurveEditable;
typedef GenericCurveEditable<SeExpr2::Vec3d> ColorCurveEditable;
typedef GenericCurveEditable<double> CurveEditable;
#ifdef SEEXPR_ENABLE_DEEPWATER
class DeepWaterEditable;
#endif
#ifdef SEEXPR_ENABLE_ANIMCURVE
namespace animlib {
class AnimCurve;
}
#endif
/// Base class for all controls for Expressions
class ExprControl : public QWidget {
......@@ -278,6 +286,7 @@ Q_SLOTS:
void curveChanged();
};
#ifdef SEEXPR_ENABLE_ANIMCURVE
/// Anim curve control
class ExprGraphPreview;
class AnimCurveControl : public ExprControl {
......@@ -302,6 +311,7 @@ Q_SLOTS:
private:
static AnimCurveCallback callback;
};
#endif
/// A control for editing color swatches
class ColorSwatchControl : public ExprControl {
......@@ -325,6 +335,7 @@ Q_SLOTS:
bool _indexLabel;
};
#ifdef SEEXPR_ENABLE_DEEPWATER
/// Control for displaying a deep water spectrum
class DeepWaterControl : public ExprControl {
Q_OBJECT
......@@ -340,5 +351,6 @@ class DeepWaterControl : public ExprControl {
Q_SLOTS:
void deepWaterChanged();
};
#endif // SEEXPR_ENABLE_DEEPWATER
#endif
......@@ -207,29 +207,31 @@ ExprAddDialog::ExprAddDialog(int& count, QWidget* parent) : QDialog(parent) {
tabWidget->addTab(stringTab, QString(tr("String")));
}
#ifdef SEEXPR_ENABLE_ANIMCURVE
// Anim Curve
{
QWidget* curveTab = new QWidget();
QFormLayout* curveLayout = new QFormLayout(curveTab);
curveLayout->setWidget(0, QFormLayout::LabelRole, new QLabel("Lookup"));
curveLayout->setWidget(1, QFormLayout::LabelRole, new QLabel("Link"));
animCurveLookup = new QLineEdit("$frame");
animCurveLink = new QLineEdit("");
curveLayout->setWidget(0, QFormLayout::LabelRole, new QLabel(tr("Lookup")));
curveLayout->setWidget(1, QFormLayout::LabelRole, new QLabel(tr("Link")));
animCurveLookup = new QLineEdit(QString::fromLatin1("$frame"));
animCurveLink = new QLineEdit(QString());
curveLayout->setWidget(0, QFormLayout::FieldRole, animCurveLookup);
curveLayout->setWidget(1, QFormLayout::FieldRole, animCurveLink);
tabWidget->addTab(curveTab, QString("AnimCurve"));
tabWidget->addTab(curveTab, QString(tr("AnimCurve")));
}
#endif
#ifdef SEEXPR_ENABLE_DEEPWATER
// DeepWater
{
QWidget* deepWaterTab = new QWidget();
QFormLayout* deepWaterLayout = new QFormLayout(deepWaterTab);
deepWaterLayout->setWidget(0, QFormLayout::LabelRole, new QLabel("Lookup"));
deepWaterLookup = new QLineEdit("$u");
deepWaterLayout->setWidget(0, QFormLayout::LabelRole, new QLabel(tr("Lookup")));
deepWaterLookup = new QLineEdit(tr("$u"));
deepWaterLayout->setWidget(0, QFormLayout::FieldRole, deepWaterLookup);
tabWidget->addTab(deepWaterTab, QString("Deep Water"));
tabWidget->addTab(deepWaterTab, QString(tr("Deep Water")));
}
#endif
verticalLayout->addWidget(tabWidget);
......@@ -321,17 +323,21 @@ void ExprControlCollection::addControlDialog() {
.arg(dialog->stringTypeWidget->currentText())
.arg(dialog->stringNameWidget->text());
break;
#ifdef SEEXPR_ENABLE_ANIMCURVE
case 8:
s = QString("%1 = animCurve(%2,\"constant\",\"constant\",0,\"%3\");")
s = QString::fromLatin1("%1 = animCurve(%2,\"constant\",\"constant\",0,\"%3\");")
.arg(dialog->variableName->text())
.arg(dialog->animCurveLookup->text())
.arg(dialog->animCurveLink->text());
break;
#endif
#ifdef SEEXPR_ENABLE_DEEPWATER
case 9:
s = QString("%1 = deepWater(%2,9,30,0,1,0,5,0,0,[0,0,0],0,0,0);\n")
s = QString::fromLatin1("%1 = deepWater(%2,9,30,0,1,0,5,0,0,[0,0,0],0,0,0);\n")
.arg(dialog->variableName->text())
.arg(dialog->deepWaterLookup->text());
break;
#endif
}
emit insertString(s.toStdString());
}
......@@ -390,12 +396,16 @@ bool ExprControlCollection::rebuildControls(const QString& expressionText, std::
widget = new CurveControl(i, x);
else if (ColorCurveEditable* x = dynamic_cast<ColorCurveEditable*>(editable))
widget = new CCurveControl(i, x);
else if (AnimCurveEditable* x = dynamic_cast<AnimCurveEditable*>(editable)) {
#ifdef SEEXPR_ENABLE_ANIMCURVE
else if (AnimCurveEditable* x = dynamic_cast<AnimCurveEditable*>(editable))
widget = new AnimCurveControl(i, x);
} else if (ColorSwatchEditable* x = dynamic_cast<ColorSwatchEditable*>(editable))
#endif
else if (ColorSwatchEditable* x = dynamic_cast<ColorSwatchEditable*>(editable))
widget = new ColorSwatchControl(i, x);
#ifdef SEEXPR_ENABLE_DEEPWATER
else if (DeepWaterEditable* x = dynamic_cast<DeepWaterEditable*>(editable))
widget = new DeepWaterControl(i, x);
#endif
else {
std::cerr << "SeExpr editor logic error, cannot find a widget for the given editable" << std::endl;
}
......@@ -417,6 +427,7 @@ bool ExprControlCollection::rebuildControls(const QString& expressionText, std::
}
void ExprControlCollection::showEditor(int idx) {
#ifdef SEEXPR_ENABLE_ANIMCURVE
if (idx < 0 || idx >= (int)_controls.size()) return;
/* Right now we only launch the anim curve editor.
......@@ -425,6 +436,7 @@ void ExprControlCollection::showEditor(int idx) {
if (!control) return;
control->editGraphClicked();
#endif
}
void ExprControlCollection::linkColorLink(int id) {
......
......@@ -56,10 +56,14 @@ class ExprAddDialog : public QDialog {
QLineEdit *vectorMax;
QLineEdit *curveLookup;
QLineEdit *colorCurveLookup;
#ifdef SEEXPR_ENABLE_ANIMCURVE
QLineEdit *animCurveLookup;
QLineEdit *animCurveLink;
#endif
QLineEdit *swatchLookup;
#ifdef SEEXPR_ENABLE_DEEPWATER
QLineEdit *deepWaterLookup;
#endif
QRadioButton *rainbowPaletteBtn;
QRadioButton *grayPaletteBtn;
QColor color;
......@@ -107,11 +111,12 @@ class ExprControlCollection : public QWidget {
int numControls() { return _controls.size(); }
void showEditor(int idx);
#ifdef SEEXPR_ENABLE_ANIMCURVE
/// Anim curve callback
static void setAnimCurveCallback(AnimCurveControl::AnimCurveCallback callback) {
AnimCurveControl::setAnimCurveCallback(callback);
}
#endif
private
Q_SLOTS:
......
......@@ -22,18 +22,21 @@
#include <string>
#include <cstring>
#include <typeinfo>
#ifdef SEEXPR_USE_ANIMLIB
#include <animlib/AnimCurve.h>
#include <animlib/AnimKeyframe.h>
#else
#define UNUSED(x) (void)(x)
#ifdef SEEXPR_ENABLE_ANIMCURVE
#ifdef SEEXPR_USE_ANIMLIB
#include <animlib/AnimCurve.h>
#include <animlib/AnimKeyframe.h>
#else
#define UNUSED(x) (void)(x)
#endif
#endif
#include <SeExpr2/Platform.h>
#include <SeExpr2/Mutex.h>
#include "ExprSpecType.h"
#include "Editable.h"
#ifdef SEEXPR_ENABLE_DEEPWATER
#include "ExprDeepWater.h"
#endif
/******************
lexer declarations
......@@ -171,6 +174,7 @@ static void specRegisterEditable(const char* var,ExprSpecNode* node)
else delete swatch;
}
}
#ifdef SEEXPR_ENABLE_ANIMCURVE
}else if(ExprSpecAnimCurveNode* n=dynamic_cast<ExprSpecAnimCurveNode*>(node)){
if(ExprSpecListNode* args=dynamic_cast<ExprSpecListNode*>(n->args)){
// need 3 items for pre inf and post inf and weighting, plus 9 items per key
......@@ -225,6 +229,8 @@ static void specRegisterEditable(const char* var,ExprSpecNode* node)
#endif
}
}
#endif
#ifdef SEEXPR_ENABLE_DEEPWATER
}else if(ExprSpecDeepWaterNode* n=dynamic_cast<ExprSpecDeepWaterNode*>(node)){
if(ExprSpecListNode* args=dynamic_cast<ExprSpecListNode*>(n->args)){
if(args->nodes.size()==12){
......@@ -253,6 +259,7 @@ static void specRegisterEditable(const char* var,ExprSpecNode* node)
else delete deepWater;
}
}
#endif
}else{
std::cerr<<"SEEXPREDITOR LOGIC ERROR: We didn't recognize the Spec"<<std::endl;
}
......@@ -404,10 +411,14 @@ e:
$$=remember(new ExprSpecCCurveNode($3));
}else if($3 && strcmp($1,"swatch")==0){
$$=remember(new ExprSpecColorSwatchNode($3));
#ifdef SEEXPR_ENABLE_ANIMCURVE
}else if($3 && strcmp($1,"animCurve")==0){
$$=remember(new ExprSpecAnimCurveNode($3));
#endif
#ifdef SEEXPR_ENABLE_DEEPWATER
}else if($3 && strcmp($1,"deepWater")==0){
$$=remember(new ExprSpecDeepWaterNode($3));
#endif
}else if($3){
// function arguments not parse of curve, ccurve, or animCurve
// check if there are any string args that need to be made into controls
......
......@@ -74,19 +74,23 @@ struct ExprSpecCCurveNode : public ExprSpecNode {
ExprSpecCCurveNode(ExprSpecNode* args) : ExprSpecNode(args->startPos, args->endPos), args(args) {}
};
#ifdef SEEXPR_ENABLE_ANIMCURVE
struct ExprSpecAnimCurveNode : public ExprSpecNode {
ExprSpecNode* args;
ExprSpecAnimCurveNode(ExprSpecNode* args) : ExprSpecNode(args->startPos, args->endPos), args(args) {}
};
#endif
struct ExprSpecColorSwatchNode : public ExprSpecNode {
ExprSpecNode* args;
ExprSpecColorSwatchNode(ExprSpecNode* args) : ExprSpecNode(args->startPos, args->endPos), args(args) {}
};
#ifdef SEEXPR_ENABLE_DEEPWATER
struct ExprSpecDeepWaterNode : public ExprSpecNode {
ExprSpecNode* args;
ExprSpecDeepWaterNode(ExprSpecNode* args) : ExprSpecNode(args->startPos, args->endPos), args(args) {}
};
#endif // SEEXPR_ENABLE_DEEPWATER
#endif
......@@ -17,6 +17,8 @@
#include <string>
%End
%Feature SEEXPR_ENABLE_DEEPWATER
%ConvertFromTypeCode
// convert an std::string to a Python (unicode) string
PyObject* newstring;
......@@ -246,6 +248,7 @@ public:
ExprColorSwatchWidget(bool indexLabel = false, QWidget* parent = NULL);
};
%If (SEEXPR_ENABLE_DEEPWATER)
class ExprDeepWater:QWidget{
%TypeHeaderCode
#include "ExprDeepWater.h"
......@@ -253,3 +256,4 @@ class ExprDeepWater:QWidget{
public:
ExprDeepWater(QWidget* parent = NULL);
};
%End
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment