/***************************************************************************
                          myscenedlg.cpp  -  description
                             -------------------
    begin                : Tue Jun 3 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 <myscenedlg.h>

#include <iostream>

#include <qvariant.h>
#include <qcheckbox.h>
#include <qgroupbox.h>
#include <qlabel.h>
#include <qlineedit.h>
#include <qpushbutton.h>
#include <qlayout.h>
#include <qtooltip.h>
#include <qwhatsthis.h>
#include <qcolordialog.h>
#include <qcolor.h>

MySceneEditDlg::MySceneEditDlg( QWidget* parent,  const char* name, bool modal, WFlags fl )
    : SceneEditDlg( parent, name, modal, fl )
{
    point = NULL;
}

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

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

void MySceneEditDlg::slotGetData(FolderListItem *i)
{
    char mybuff[256];
    unsigned int colorr;
    unsigned int colorg;
    unsigned int colorb;

    wgx->setText(i->GetValue("wgx",i));
    wgy->setText(i->GetValue("wgy",i));
    wgz->setText(i->GetValue("wgz",i));

    cgplane->setChecked(i->GetValue("cgplane",i).toInt());

    strncpy(mybuff,i->GetValue("color_back",i),8);
    sscanf(mybuff,"%02X%02X%02X",&colorr,&colorg,&colorb);
    mycolor.setRgb(colorr,colorg,colorb);
    if ( mycolor.isValid() )
    {
      QPixmap pix (100,15);
      pix.fill( mycolor );
      color_back->setPixmap( pix );
    }

    point=i;

    text->setText(i->text(0));


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

void MySceneEditDlg::slotEditData()
{
    char mybuff[256];

    point->setText(0,text->text());

    point->SetValue("wgx",wgx->text());
    point->SetValue("wgy",wgy->text());
    point->SetValue("wgz",wgz->text());

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

    sprintf(mybuff,"%02X%02X%02X",mycolor.red(),mycolor.green(),mycolor.blue());
    point->SetValue("color_back",mybuff);

    point->updategl();

qWarning( "MySceneEditDlg::slotEditData(): Geht !" );

}

void MySceneEditDlg::slotEditColor()
{
    QColor color = QColorDialog::getColor(mycolor,this, "color dialog" );
        if ( color.isValid() ) {
            QPixmap pix (100,15) ;
            pix.fill( color );
            color_back->setPixmap( pix );
            mycolor = color;
        }
    qWarning( "MyLampEditDlg::slotEditColorAmb(): Geht !" );
}
