/***************************************************************************
                          mycameradlg.cpp  -  description
                             -------------------
    begin                : Mon Feb 10 2003
    copyright            : (C) 2003 by Harald Krippel
    email                : neuro.harald@surfeu.at
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

 #include "mycameradlg.h"

#include <qvariant.h>
#include <qgroupbox.h>
#include <qlabel.h>
#include <qcheckbox.h>
#include <qradiobutton.h>
#include <qlineedit.h>
#include <qpushbutton.h>
#include <qlayout.h>
#include <qtooltip.h>
#include <qwhatsthis.h>
 
MyCameraEditDlg::MyCameraEditDlg( QWidget* parent,  const char* name, bool modal, WFlags fl )
    : CameraEditDlg( parent, name, modal, fl )
{
    point = NULL;
}

/*
 *  Destroys the object and frees any allocated resources
 */
MyCameraEditDlg::~MyCameraEditDlg()
{
    // no need to delete child widgets, Qt does it all for us
}

void MyCameraEditDlg::slotGetData()
{
    if(point != NULL)
    {
      slotGetData(point);
    }
}

void MyCameraEditDlg::slotGetData(FolderListItem *i)
{
    point=i;

    text->setText(i->text(0));
    on->setChecked(i->GetValue("on",i).toInt());

    locx->setText(i->GetValue("x",i));
    locy->setText(i->GetValue("y",i));
    locz->setText(i->GetValue("z",i));

    rotx->setText(i->GetValue("rotx",i));
    roty->setText(i->GetValue("roty",i));
    rotz->setText(i->GetValue("rotz",i));
    
    fovw->setText(i->GetValue("fovw",i));
    fovh->setText(i->GetValue("fovh",i));

    near->setText(i->GetValue("near",i));
    far->setText(i->GetValue("far",i));
    bind->setText(i->GetValue("bind",i));

    camrotw->setText(i->GetValue("camrotw",i));
    camhight->setText(i->GetValue("camhight",i));
    camradius->setText(i->GetValue("camradius",i));

    camego->setChecked(i->GetValue("camego",i).toInt());
    cam2d->setChecked(i->GetValue("cam2d",i).toInt());
    camfix->setChecked(i->GetValue("camfix",i).toInt());
    
    onkey->setText(i->GetValue("onkey",i));

    qWarning( "MyCameraEditDlg::slotGetData(): Geht !" );
}

void MyCameraEditDlg::slotEditData()
{
    point->setText(0,text->text());

    point->SetValue("on", on->isChecked() ? "1" : "0");

    point->SetValue("x",locx->text());
    point->SetValue("y",locy->text());
    point->SetValue("z",locz->text());

    point->SetValue("rotx",rotx->text());
    point->SetValue("roty",roty->text());
    point->SetValue("rotz",rotz->text());

    point->SetValue("fovw",fovw->text());
    point->SetValue("fovh",fovh->text());

    point->SetValue("near",near->text());
    point->SetValue("far",far->text());

    point->SetValue("bind",bind->text());
    
    point->SetValue("camrotw",camrotw->text());
    point->SetValue("camhight",camhight->text());
    point->SetValue("camradius",camradius->text());

    point->SetValue("camego", camego->isChecked() ? "1" : "0");
    point->SetValue("cam2d", cam2d->isChecked() ? "1" : "0");
    point->SetValue("camfix", camfix->isChecked() ? "1" : "0");

    point->SetValue("onkey",onkey->text());

    point->updategl();
    
    qWarning( "MyCameraEditDlg::slotEditData(): Geht !" );
}

