CQGnuPlotDataDialog::
CQGnuPlotDataDialog(CQGnuPlotMainWindow *window, const CGnuPlotFile &file) :
 window_(window)
{
  setWindowTitle("Data Dialog");

  setObjectName("dataDialog");

  enum_ = new CQGnuPlotEnum;

  enum_->setPlotStyle(CQGnuPlotEnum::PlotLinesPoints);

  QVBoxLayout *layout = new QVBoxLayout(this);
  layout->setMargin(2); layout->setSpacing(2);

  //------

  QGroupBox *loadGroup = new QGroupBox("File Data");

  QVBoxLayout *loadLayout = new QVBoxLayout(loadGroup);
  loadLayout->setMargin(2); loadLayout->setSpacing(2);

  layout->addWidget(loadGroup);

  //--

  QHBoxLayout *fileLayout = new QHBoxLayout;
  fileLayout->setMargin(2); fileLayout->setSpacing(2);

  fileEdit_ = new CQGnuPlotFilename;

  fileEdit_->setName(file.fileName().c_str());
  fileEdit_->setPattern("Text (*.txt);; CSV (*.csv);; File (*.*);; All (*)");

  QPushButton *loadButton = new QPushButton("Load");

  connect(loadButton, SIGNAL(clicked()), this, SLOT(loadSlot()));

  fileLayout->addWidget(new QLabel("File"));
  fileLayout->addWidget(fileEdit_);
  fileLayout->addWidget(loadButton);

  loadLayout->addLayout(fileLayout);

  //------

  QHBoxLayout *numberLayout = new QHBoxLayout;
  numberLayout->setMargin(2); numberLayout->setSpacing(2);

  numberEdit_ = new CQIntegerSpin;

  numberEdit_->setValue(100);

  QPushButton *generateButton = new QPushButton("Generate");

  connect(generateButton, SIGNAL(clicked()), this, SLOT(generateSlot()));

  numberLayout->addWidget(generateButton);
  numberLayout->addWidget(numberEdit_);
  numberLayout->addWidget(new QLabel("Points"));
  numberLayout->addStretch(1);

  loadLayout->addLayout(numberLayout);

  //------

  QHBoxLayout *formatLayout = new QHBoxLayout;
  formatLayout->setMargin(2); formatLayout->setSpacing(2);

  formatLayout->addWidget(csvCheck_ = new QCheckBox("CSV"));
  formatLayout->addWidget(headerCheck_ = new QCheckBox("Header"));
  formatLayout->addStretch(1);

  loadLayout->addLayout(formatLayout);

  //------

  QHBoxLayout *separatorLayout = new QHBoxLayout;
  separatorLayout->setMargin(2); separatorLayout->setSpacing(2);

  separatorLayout->addWidget(new QLabel("Separator"));
  separatorLayout->addWidget(separatorEdit_ = new QLineEdit);
  separatorLayout->addStretch(1);

  loadLayout->addLayout(separatorLayout);

  char sepChar = file.separator();

  std::string sepStr(&sepChar, 1);

  separatorEdit_->setText(sepStr.c_str());

  //------

  QHBoxLayout *missingLayout = new QHBoxLayout;
  missingLayout->setMargin(2); missingLayout->setSpacing(2);

  missingLayout->addWidget(new QLabel("Missing"));
  missingLayout->addWidget(missingEdit_ = new QLineEdit);
  missingLayout->addStretch(1);

  loadLayout->addLayout(missingLayout);

  missingEdit_->setText(file.missingStr().c_str());

  //------

  tree_ = new CQGnuPlotDataTree(file);

  layout->addWidget(tree_);

  //------

  QGroupBox *filterGroup = new QGroupBox("Filter Data");

  QVBoxLayout *filterLayout = new QVBoxLayout(filterGroup);
  filterLayout->setMargin(2); filterLayout->setSpacing(2);

  layout->addWidget(filterGroup);

  //--

  QHBoxLayout *usingLayout = new QHBoxLayout;
  usingLayout->setMargin(2); usingLayout->setSpacing(2);

  usingLayout->addWidget(new QLabel("Using"));
  usingLayout->addWidget(usingEdit_ = new QLineEdit);

  filterLayout->addLayout(usingLayout);

  usingEdit_->setText(window_->qapp()->usingString().c_str());

  //--

  QHBoxLayout *indexLayout = new QHBoxLayout;
  indexLayout->setMargin(2); indexLayout->setSpacing(2);

  indexLayout->addWidget(new QLabel("Index"));
  indexLayout->addWidget(indexEdit_ = new QLineEdit);

  filterLayout->addLayout(indexLayout);

  //--

  QHBoxLayout *everyLayout = new QHBoxLayout;
  everyLayout->setMargin(2); everyLayout->setSpacing(2);

  everyLayout->addWidget(new QLabel("Every"));
  everyLayout->addWidget(everyEdit_ = new QLineEdit);

  filterLayout->addLayout(everyLayout);

  //--

  QHBoxLayout *whereLayout = new QHBoxLayout;
  whereLayout->setMargin(2); whereLayout->setSpacing(2);

  whereLayout->addWidget(new QLabel("Where"));
  whereLayout->addWidget(whereEdit_ = new QLineEdit);

  filterLayout->addLayout(whereLayout);

  //--

  QHBoxLayout *filterOptionsLayout = new QHBoxLayout;
  filterOptionsLayout->setMargin(2); filterOptionsLayout->setSpacing(2);

  filterOptionsLayout->addWidget(averageCheck_ = new QCheckBox("Average"));
  filterOptionsLayout->addWidget(summedCheck_  = new QCheckBox("Summed" ));
  filterOptionsLayout->addStretch(1);

  filterLayout->addLayout(filterOptionsLayout);

  //------

  QGroupBox *plotGroup = new QGroupBox("Plot Style");

  QVBoxLayout *plotPlayout = new QVBoxLayout(plotGroup);
  plotPlayout->setMargin(2); plotPlayout->setSpacing(2);

  layout->addWidget(plotGroup);

  //--

  enum_->setPlotStyle(CQGnuPlotEnum::plotStyleConv(window_->qapp()->plotStyle()));

  QHBoxLayout *styleLayout = new QHBoxLayout;
  styleLayout->setMargin(2); styleLayout->setSpacing(2);

  CQEnumCombo *styleCombo = new CQEnumCombo(this, enum_, "plotStyle");

  styleLayout->addWidget(new QLabel("Style"));
  styleLayout->addWidget(styleCombo);
  styleLayout->addStretch(1);

  plotPlayout->addLayout(styleLayout);

  //--

  QHBoxLayout *dimensionLayout = new QHBoxLayout;
  dimensionLayout->setMargin(2); dimensionLayout->setSpacing(2);

  dimensionLayout->addWidget(new QLabel("Dimension"));
  dimensionLayout->addWidget(dimension2DRadio_ = new QRadioButton("2D"));
  dimensionLayout->addWidget(dimension3DRadio_ = new QRadioButton("3D"));
  dimensionLayout->addStretch(1);

  dimension2DRadio_->setChecked(true);

  plotPlayout->addLayout(dimensionLayout);

  //--

  QHBoxLayout *lineStyleLayout = new QHBoxLayout;
  lineStyleLayout->setMargin(2); lineStyleLayout->setSpacing(2);

  lineStyleLayout->addWidget(new QLabel("Line Style"));
  lineStyleLayout->addWidget(lineTypeEdit_ = new CQIntegerSpin);
  lineStyleLayout->addStretch(1);

  lineTypeEdit_->setValue(-1);

  plotPlayout->addLayout(lineStyleLayout);

  //--

  QHBoxLayout *plotButtonsLayout = new QHBoxLayout;
  plotButtonsLayout->setMargin(2); plotButtonsLayout->setSpacing(2);

  QPushButton *filterButton      = new QPushButton("Filter");
  QPushButton *overlayPlotButton = new QPushButton("Overlay Plot");
  QPushButton *addPlotButton     = new QPushButton("Add Plot");

  connect(filterButton     , SIGNAL(clicked()), this, SLOT(filterSlot()));
  connect(overlayPlotButton, SIGNAL(clicked()), this, SLOT(overlayPlotSlot()));
  connect(addPlotButton    , SIGNAL(clicked()), this, SLOT(addPlotSlot()));

  plotButtonsLayout->addWidget(filterButton);
  plotButtonsLayout->addWidget(overlayPlotButton);
  plotButtonsLayout->addWidget(addPlotButton);
  plotButtonsLayout->addStretch(1);

  layout->addLayout(plotButtonsLayout);

  //---

  QHBoxLayout *buttonLayout = new QHBoxLayout;
  buttonLayout->setMargin(2); buttonLayout->setSpacing(2);

  buttonLayout->addStretch(1);

  QPushButton *closeButton  = new QPushButton("Close");

  buttonLayout->addWidget(closeButton);

  connect(closeButton, SIGNAL(clicked()), this, SLOT(closeSlot()));

  layout->addLayout(buttonLayout);
}
Exemple #2
0
AttachForm::AttachForm(QWidget *parent, const char *name,
		       bool modal, Qt::WFlags f)
  : QDialog( parent, name, modal, f ), mNumSims(0),
    mLibReturnStatus(REG_SUCCESS), mSimGSHSelected(kNULL),
    mSimName(kNULL), mSimGSH(kNULL), mTable(kNULL),
    mFilterLineEdit(kNULL), mAttachButton(kNULL), mCancelButton(kNULL)
{
  struct registry_contents content;
  int i, count;
  QString lString;
  bool ok;
  REG_DBGCON("AttachForm");

  // set up arrays for ReG lib call
  // max list can be is REG_MAX_NUM_STEERED_SIM
  mSimName = new char *[REG_MAX_NUM_STEERED_SIM];
  mSimGSH = new char *[REG_MAX_NUM_STEERED_SIM];

  for (i=0; i<REG_MAX_NUM_STEERED_SIM; i++){
    mSimName[i] = new char[REG_MAX_STRING_LENGTH + 1];
    mSimGSH[i] = new char[REG_MAX_STRING_LENGTH + 1];
  }

  SteererConfig *lConfig = ((SteererMainWindow *)parent)->getConfig();
// #ifdef REG_WSRF
  if( !(lConfig->mRegistrySecurity.passphrase[0]) ){

    // Get the passphrase for the user's key if registry is using
    // SSL
    if( lConfig->mRegistrySecurity.use_ssl == REG_TRUE){

      lString = QInputDialog::getText("RealityGrid Steerer",
				      "Enter passphrase for X.509 key:",
				      QLineEdit::Password,
				      QString::null, &ok, this );
      if ( !ok ) return; // Cancel if user didn't press OK
    }
    else{
      lString = QInputDialog::getText("RealityGrid Steerer",
				      "Enter passphrase for registry:",
				      QLineEdit::Password,
				      QString::null, &ok, this );
      if ( !ok ) return; // Cancel if user didn't press OK
    }
    strncpy(lConfig->mRegistrySecurity.passphrase,
	    lString.ascii(), REG_MAX_STRING_LENGTH);
  }
  // Now find out what's in the registry...
  //..._secure only available in steering library >= 2.0
  mLibReturnStatus = Get_registry_entries_secure(lConfig->mTopLevelRegistry,
						 &(lConfig->mRegistrySecurity),
						 &content);
// #else
//   mLibReturnStatus = Get_registry_entries((char *)(lConfig->mTopLevelRegistry.ascii()),
// 					  &content);
// #endif // defined REG_WSRF

  if(mLibReturnStatus != REG_SUCCESS) return;

  count = 0;
  for (i=0; i<content.numEntries; i++){
    if(!strcmp(content.entries[i].service_type, "SWS") ||
       !strcmp(content.entries[i].service_type, "SGS")){
      sprintf(mSimName[count], "%s %s %s", content.entries[i].application,
	      content.entries[i].user, content.entries[i].start_date_time);
      sprintf(mSimGSH[count], "%s", content.entries[i].gsh);
      count++;
    }
  }
  Delete_registry_table(&content);

  mNumSims = count;

  // only continue if there is some info to show
  if(mNumSims>0)
  {
    this->setCaption( "Grid Attach" );
    resize( 520, 350 );

    // create the layouts for the form
    Q3VBoxLayout *lFormLayout = new Q3VBoxLayout(this, 10, 10,
					       "attachformlayout");
    Q3HBoxLayout *lFilterLayout = new Q3HBoxLayout(6, "filterlayout");
    Q3VBoxLayout *lListLayout = new Q3VBoxLayout(6, "attachlistlayout");
    Q3HBoxLayout *lButtonLayout = new Q3HBoxLayout(6, "attachbuttonlayout");
    QSpacerItem* lSpacer = new QSpacerItem( 200, 0, QSizePolicy::Expanding,
					    QSizePolicy::Minimum );

    // create the list box for the applications on the grid
    lListLayout->addWidget(new TableLabel("Steerable Applications", this));
    mTable = new Q3Table(0, 2, this);
    mTable->setSelectionMode( Q3Table::Single );
    mTable->verticalHeader()->hide();
    mTable->setLeftMargin(0);

    mTable->horizontalHeader()->setLabel(0, "Application");
    mTable->horizontalHeader()->setLabel(1, "Handle");

    connect(mTable, SIGNAL(valueChanged(int, int)), this,
	    SLOT(editHandleSlot(int, int)));

    // populate the list box - each listboxitem holds array index
    // information - this is what is used by the calling code
    // (via  aSimIndexSelected) to identify the aSimGSH selected
    for (int i=0; i<mNumSims; i++)
    {
      REG_DBGMSG1("mSimName ", mSimName[i]);
      REG_DBGMSG1("mSimGSH ", mSimGSH[i]);

      mTable->insertRows(mTable->numRows(),1);
      mTable->setItem(mTable->numRows()-1, 0,
		      new Q3TableItem(mTable, Q3TableItem::Never,
				     QString(mSimName[i])));
      mTable->setItem(mTable->numRows()-1, 1,
		      new Q3TableItem(mTable, Q3TableItem::WhenCurrent,
				     QString(mSimGSH[i])));
    }
    mTable->adjustColumn(0);
    mTable->adjustColumn(1);
    // We checked that mNumSims was > 0 earlier...
    mTable->selectRow(0);

    mFilterLineEdit = new QLineEdit(this, "containsfilter");
    connect(mFilterLineEdit, SIGNAL(returnPressed()), this,
	    SLOT(filterSlot()));

    // Initialize the filter with the user's username - might be handy
    mFilterLineEdit->setText(QString(getenv("USER")));
    mFilterLineEdit->selectAll();

    lFilterLayout->addWidget(new QLabel("Contains", this));
    lFilterLayout->addWidget(mFilterLineEdit);


    lListLayout->addWidget(mTable);
    lListLayout->addLayout(lFilterLayout);

    mAttachButton = new QPushButton("Attach", this, "attachbutton");
    mAttachButton->setMinimumSize(mAttachButton->sizeHint());
    mAttachButton->setMaximumSize(mAttachButton->sizeHint());
    mAttachButton->setAutoDefault(FALSE);
    QToolTip::add(mAttachButton, "Attach to selected application");
    connect(mAttachButton, SIGNAL(clicked()), this, SLOT(attachSlot()));


    mCancelButton = new QPushButton("Cancel", this, "cancelbutton");
    mCancelButton->setMinimumSize(mCancelButton->sizeHint());
    mCancelButton->setMaximumSize(mCancelButton->sizeHint());
    mCancelButton->setAutoDefault(FALSE);
    connect(mCancelButton,  SIGNAL(clicked()), this, SLOT( reject()));


    lButtonLayout->addItem(lSpacer);
    lButtonLayout->addWidget(mCancelButton);
    lButtonLayout->addWidget(mAttachButton);

    lFormLayout->addLayout(lListLayout);
    lFormLayout->addLayout(lButtonLayout);
  }