#include <helixQtCmd.h>
#include <math.h>
#include <maya/MDoubleArray.h> 
#include <maya/MFnDependencyNode.h>
#include <maya/MFnNurbsCurve.h>
#include <maya/MFnPlugin.h>
#include <maya/MGlobal.h>
#include <maya/MObject.h>
#include <maya/MPoint.h>
#include <maya/MPointArray.h>
HelixButton::HelixButton(const QString& text, QWidget* parent)
:   QPushButton(text, parent)
{}
HelixButton::~HelixButton()
{}
void HelixButton::createHelix(bool )
{
    const unsigned deg    = 3;             
    const unsigned ncvs   = 20;            
    const unsigned spans  = ncvs - deg;    
    const unsigned nknots = spans+2*deg-1; 
    double         radius = 4.0;           
    double         pitch  = 0.5;           
    unsigned       i;
    
    for (i = 0; i < ncvs; i++) {
                radius * cos((double) i),
                pitch * (double) i,
                radius * sin((double) i)
            )
        );
    }
    
    for (i = 0; i < nknots; i++)
        knotSequences.
append((
double) i);
    
        controlVertices,
        knotSequences,
        deg,
        false,
        false,
        &st
    );
    if (!st) {
            HelixQtCmd::commandName + " - could not create helix: "
        );
    }
}
QPointer<HelixButton>   HelixQtCmd::button;
const MString           HelixQtCmd::commandName(
"helixQt");
 
void HelixQtCmd::cleanup()
{
    if (!button.isNull()) delete button;
}
{
    
    
    if (button.isNull()) {
        button = new HelixButton("Create Helix");
        button->connect(button, SIGNAL(clicked(bool)), button, SLOT(createHelix(bool)));
        button->show();
    }
    else {
        button->showNormal();
        button->raise();
    }
}
{
    MFnPlugin   pluginFn(plugin, 
"Autodesk, Inc.", 
"1.0", 
"Any", &st);
 
    if (!st) {
            MString(
"helixQtCmd - could not initialize plugin: ")
 
        );
        return st;
    }
    
    st = pluginFn.registerCommand(HelixQtCmd::commandName, HelixQtCmd::creator);
    if (!st) {
            MString(
"helixQtCmd - could not register '")
 
            + HelixQtCmd::commandName + "' command: "
        );
        return st;
    }
    return st;
}
{
    MFnPlugin   pluginFn(plugin, 
"Autodesk, Inc.", 
"1.0", 
"Any", &st);
 
    if (!st) {
            MString(
"helixQtCmd - could not uninitialize plugin: ")
 
        );
        return st;
    }
    
    HelixQtCmd::cleanup();
    
    st = pluginFn.deregisterCommand(HelixQtCmd::commandName);
    if (!st) {
            MString(
"helixQtCmd - could not deregister '")
 
            + HelixQtCmd::commandName + "' command: "
        );
        return st;
    }
    return st;
}