#include <qwidget.h>
#include <qlabel.h>
#include <qlineedit.h>
#include <qpushbutton.h>
#include <qdialog.h>
#include <qcolor.h>
#include <qfont.h>
#include <qnamespace.h>

#include <klocale.h>

// language file
//#include "language.h"
// end language include(s)

#include "render2d.h"
#include "fixeddialog.h"

FixedDialog::FixedDialog(QWidget *parent, QString name) :
	KDialogBase(parent, name, true,  i18n("Set fixed angle and length"),
                    Ok|Default|Cancel, Ok,  true)
{
    FixedDialogWidget* widget = new FixedDialogWidget(this);
    setMainWidget(widget);
    connect(this, SIGNAL(defaultClicked()), this,SLOT(setDefaults()));

    bond_length = widget->bond_length;
    bond_angle = widget->bond_angle;
    arrow_length = widget->arrow_length;
    arrow_angle = widget->arrow_angle;
    dbond_offset = widget->dbond_offset;

    setDefaults();
}

void FixedDialog::setDefaults() {
  QString n;
  n.setNum(25);
  bond_length->setText(n);
  n.setNum(15);
  bond_angle->setText(n);
  n.setNum(50);
  arrow_length->setText(n);
  n.setNum(15);
  arrow_angle->setText(n);
//  n.setNum(1.0);
  n.setNum(2.0);
  dbond_offset->setText(n);
  //anti_toggle->setChecked(false);
}

void FixedDialog::setLength_bond(double t)
{
  QString n;
  n.setNum(t);

  bond_length->setText(n);
}

void FixedDialog::setAngle_bond(double t)
{
  QString n;
  n.setNum(t);

  bond_angle->setText(n);
}

double FixedDialog::getLength_bond(void)
{
  double t;
  bool b;

  t = bond_length->text().toDouble(&b);
  if (b == true)
    return t;
  return -1.0;
}

double FixedDialog::getAngle_bond(void)
{
  double t;
  bool b;

  t = bond_angle->text().toDouble(&b);
  if (b == true)
    return t;
  return -1.0;
}

void FixedDialog::setLength_arrow(double t)
{
  QString n;
  n.setNum(t);

  arrow_length->setText(n);
}

void FixedDialog::setAngle_arrow(double t)
{
  QString n;
  n.setNum(t);

  arrow_angle->setText(n);
}

double FixedDialog::getLength_arrow(void)
{
  double t;
  bool b;

  t = arrow_length->text().toDouble(&b);
  if (b == true)
    return t;
  return -1.0;
}

double FixedDialog::getAngle_arrow(void)
{
  double t;
  bool b;

  t = arrow_angle->text().toDouble(&b);
  if (b == true)
    return t;
  return -1.0;
}

double FixedDialog::getDoubleBondOffset(void) {
  double t;
  bool b;

  t = dbond_offset->text().toDouble(&b);
  if (b == true)
    return t;
  return -1.0;}

void FixedDialog::setDoubleBondOffset(double t) {
  QString n;
  n.setNum(t);

  dbond_offset->setText(n);
}


#include "fixeddialog.moc"