// Copyright (c) Lawrence Livermore National Security, LLC and other VisIt
// Project developers.  See the top-level LICENSE file for dates and other
// details.  No copyright assignment is required to contribute to VisIt.

#ifndef QVISWELLBOREPLOTWINDOW_H
#define QVISWELLBOREPLOTWINDOW_H

#include <QvisPostableWindowObserver.h>
#include <AttributeSubject.h>

class WellBoreAttributes;
class QButtonGroup;
class QCheckBox;
class QComboBox;
class QGroupBox;
class QLabel;
class QLineEdit;
class QListWidget;
class QTextEdit;
class QvisColorButton;
class QvisColorManagerWidget;
class QvisColorTableWidget;
class QvisLineWidthWidget;
class QvisOpacitySlider;

// ****************************************************************************
// Class: QvisWellBorePlotWindow
//
// Purpose:
//    Defines QvisWellBorePlotWindow class.
//
// Notes:      Autogenerated by xml2window.
//
// Programmer: xml2window
// Creation:   omitted
//
// Modifications:
//   Eric Brugger, Mon Nov 10 13:16:16 PST 2008
//   Added the ability to display well bore names and stems.
//   
//   Kathleen Bonnell, Mon Jan 17 18:17:26 MST 2011
//   Change colorTableButton to colorTableWidget to gain invert toggle.
//
// ****************************************************************************

class QvisWellBorePlotWindow : public QvisPostableWindowObserver
{
    Q_OBJECT
  public:
    QvisWellBorePlotWindow(const int type,
                         WellBoreAttributes *subj,
                         const QString &caption = QString(),
                         const QString &shortName = QString(),
                         QvisNotepadArea *notepad = 0);
    virtual ~QvisWellBorePlotWindow();
    virtual void CreateWindowContents();
  public slots:
    virtual void apply();
    virtual void makeDefault();
    virtual void reset();
  protected:
    void UpdateWindow(bool doAll);
    void GetCurrentValues(int which_widget);
    void Apply(bool ignore = false);
    void BlockAllSignals(bool block);

    bool UpdateMultipleAreaColors();
    bool UpdateMultipleAreaNames();
    void UpdateWellName(int index);
    void UpdateWellDefinition(int index);

    void ReadWellDefinition();
  private slots:
    void readWellBoresButtonPressed();
    void writeWellBoresButtonPressed();
    void wellListSelectionChanged();
    void newWellButtonPressed();
    void deleteWellButtonPressed();
    void wellNameTextChanged(const QString &color);
    void wellDefinitionTextChanged();
    void colorModeChanged(int index);
    void singleColorChanged(const QColor &color);
    void singleColorOpacityChanged(int opacity);
    void multipleColorChanged(const QColor &color, int index);
    void opacityChanged(int opacity, int index);
    void colorTableClicked(bool useDefault, const QString &ctName);
    void invertColorTableToggled(bool val);
    void drawWellsAsChanged(int val);
    void wellCylinderQualityChanged(int val);
    void wellRadiusProcessText();
    void wellLineWidthChanged(int style);
    void wellAnnotationChanged(int val);
    void wellStemHeightProcessText();
    void wellNameScaleProcessText();
    void legendFlagChanged(bool val);
  private:
    int                     plotType;
    bool                    wellDefinitionChanged;
    int                     wellIndex;

    QPushButton            *readWellBoresButton;
    QPushButton            *writeWellBoresButton;
    QListWidget               *wellListBox;
    QPushButton            *newWellButton;
    QPushButton            *deleteWellButton;
    QLabel                 *wellNameLabel;
    QLineEdit              *wellName;
    QLabel                 *wellDefinitionLabel;
    QTextEdit              *wellDefinition;
    QGroupBox              *wellColorGroup;
    QButtonGroup           *colorModeButtons;
    QvisColorButton        *singleColor;
    QvisOpacitySlider      *singleColorOpacity;
    QvisColorManagerWidget *multipleColors;
    QvisColorTableWidget   *colorTableWidget;
    QLabel                 *drawWellsAsLabel;
    QComboBox              *drawWellsAs;
    QLabel                 *wellCylinderQualityLabel;
    QComboBox              *wellCylinderQuality;
    QLabel                 *wellRadiusLabel;
    QLineEdit              *wellRadius;
    QLabel                 *wellLineWidthLabel;
    QvisLineWidthWidget    *wellLineWidth;
    QLabel                 *wellAnnotationLabel;
    QComboBox              *wellAnnotation;
    QLabel                 *wellStemHeightLabel;
    QLineEdit              *wellStemHeight;
    QLabel                 *wellNameScaleLabel;
    QLineEdit              *wellNameScale;
    QCheckBox              *legendFlag;

    WellBoreAttributes     *atts;

    // Routines for writing well bore files.
    bool                    GetPoint(int [3], const std::vector<int> &,
                                int &);
    bool                    WritePoint(FILE *, int [3], int [3]);

    // Routines for writing well bore files.
    enum TokenType
    {
        TOKEN_EOF,
        TOKEN_EQUAL,
        TOKEN_STRING,
        TOKEN_SLASH,
        TOKEN_INTEGER,
        TOKEN_WELLS,
        TOKEN_ENDWELLS,
        TOKEN_WELL,
        TOKEN_PERF,
        TOKEN_NAME,
        TOKEN_I,
        TOKEN_J,
        TOKEN_K,
        TOKEN_I_BOTTOM,
        TOKEN_J_BOTTOM,
        TOKEN_K_BOTTOM,
        TOKEN_I_TOP,
        TOKEN_J_TOP,
        TOKEN_K_TOP,
        TOKEN_ERROR
    };

    char                    buf[101];
    TokenType               GetToken(FILE *);
};



#endif
