Beispiel #1
0
/*! Makes a scrolled text window with the text taken from the array of 
  character strings in [msg] */
void dia_smsg(const char **msg)
{
  char *p;
  char *buf;
  char *lineStart;
  char *temp;
  int maxline, maxrow, linesize;
  long bufsize;
  int i, twidth, doline;
  int lastspace, curpos;
  int maxWidth = (int)(0.8 * QApplication::desktop()->width());
  int maxHeight = (int)(0.8 * QApplication::desktop()->height());
  int height, width = 0;
  QString test;

  QDialog *dlg = new QDialog();
  dlg->setAttribute(Qt::WA_DeleteOnClose);

  for (i = 0, bufsize = 0; msg[i]; i++){
    linesize = strlen(msg[i]);
    bufsize += linesize;
  }

  buf = (char *)malloc(bufsize + i + 1);
  p = buf;
  for (p = buf, i = 0; msg[i]; i++) {
    p += strlen (strcpy (p, msg[i]));
    /* DNM: this macro call caused program built on Irix 6.5 to not run
       on earlier Irix's.  Casting as (int) didn't help - just do 
       explicit tests */
    /*if (!isspace (p[-1]))  spaces, tabs and newlines are spaces.. */
    if (p[-1] != ' ' && p[-1] != '\t' && p[-1] != '\n')
      *p++ = ' '; /* lines are concatenated, insert a space */
  }
  *--p = 0; /* get rid of trailing space... */

  // DNM: count the actual lines and their lengths to get the right size window

  maxline = 0;
  maxrow = 1;
  curpos = 0;
  lastspace = 40;
  lineStart = buf;

  for (p = buf; *p; p++) {
    doline = 0;
    if (*p == '\t')
      curpos = 8 * (curpos/ 8 + 1);
    else if (*p == ' ') {
      lastspace = curpos;
      curpos++;
    } else if (*p == '\n') {
      if (curpos >= maxline)
        maxline = curpos + 1;
      curpos = 0;
      doline = p + 1 - lineStart;
    } else if (curpos > 78 ) {
      if (lastspace >= maxline)
        maxline = lastspace + 1;
      curpos -= lastspace;
      doline = lastspace;
    } else
      curpos++;
    
    if (doline) {
      temp = (char *)malloc(doline + 1);
      if (temp) {
	strncpy(temp, lineStart, doline);
	temp[doline] = 0x00;
	test = temp;
	twidth = dlg->fontMetrics().width(test);
	if (width < twidth)
	  width = twidth;
	free(temp);
      }
      lineStart = p + 1;
      lastspace = 40;
      maxrow++;
    }
  }

  if (!maxline & !width) {
    maxline = curpos + 1;
    test = "";
    for (i = 0; i < maxline + 2; i++)
      test += "8";
    width = dlg->fontMetrics().width(test);
  }

  if (maxrow > 50)
    maxrow = 40;

  QString qmsg = buf;

  // Make a vertical layout with the text edit and a close button
  QVBoxLayout *vbox = new QVBoxLayout(dlg);
  QTextEdit *edit = new QTextEdit(dlg);
  edit->setText(qmsg);
  edit->setReadOnly(true);
  vbox->addWidget(edit);
  QHBoxLayout *hbox = diaHBoxLayout(vbox);
  QPushButton *button = diaPushButton("Close", dlg, hbox);
  diaSetButtonWidth(button, true, 1.4, "Close");
  QObject::connect(button, SIGNAL(clicked()), dlg, SLOT(close()));

  // Figure out width and height of text and height of button, and set size
  if (width > maxWidth)
    width = maxWidth;
  height = (maxrow + 5) * edit->fontMetrics().height();
  if (height > maxHeight)
    height = maxHeight;
  QSize hint = hbox->sizeHint();

  // This was width + 20 when the width was based on character count alone
  dlg->resize(width + 60, height + hint.height());

  // Set title
  test = Dia_title;
  test += " Help";
  dlg->setWindowTitle(test);
  dlg->show();
}
Beispiel #2
0
                ", in each button");
  mGridValBox->setEnabled(fileReadable(App->cvi, iz));

  mConvertBox = NULL;
  if (App->cvi->rgbStore) {
    mConvertBox = diaCheckBox("Convert RGB to gray scale", this, hBox);
    diaSetChecked(mConvertBox, convertRGB);
    connect(mConvertBox, SIGNAL(toggled(bool)), this, 
            SLOT(convertToggled(bool)));
    mConvertBox->setToolTip("Show luminance values instead of RGB triplets"
                  );
  }

  hBox->addStretch();
  hBox->setSpacing(5);
  mHelpButton = diaPushButton("Help", this, hBox);
  connect(mHelpButton, SIGNAL(clicked()), this, SLOT(helpClicked()));

  // Make the grid
  QGridLayout *layout = new QGridLayout();
  layout->setSpacing(5);
  vBox->addLayout(layout);
  vBox->setContentsMargins(7,7,7,7);

  // Add labels on left
  for (i = 0; i < PV_ROWS; i++) {
    mLeftLabels[i] = new QLabel("88888", this);
    mLeftLabels[i]->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
    layout->addWidget(mLeftLabels[i], PV_ROWS - 1 - i, 0);
  }
Beispiel #3
0
TumblerWindow::TumblerWindow(TumblerStruct *xtum, bool rgba,
            bool doubleBuffer, bool enableDepth, QWidget * parent,
            const char * name, Qt::WindowFlags f)
  : QMainWindow(parent, f)
{
  int j;
  QString str;
  mTum = xtum;
  setAttribute(Qt::WA_DeleteOnClose);
  setAttribute(Qt::WA_AlwaysShowToolTips);

  if (firstTime) 
    utilFileListsToIcons(fileList, icons, MAX_XTUM_TOGGLES);
  firstTime = 0;
  
  // Make central vbox and top frame containing an hboxlayout
  QWidget *central = new QWidget(this);
  setCentralWidget(central);
  QVBoxLayout *cenlay = new QVBoxLayout(central);
  cenlay->setContentsMargins(0,0,0,0);
  cenlay->setSpacing(0);
  QFrame * topFrame = new QFrame(central);
  cenlay->addWidget(topFrame);
  topFrame->setFrameStyle(QFrame::Raised | QFrame::StyledPanel);

  QHBoxLayout *topLayout = new QHBoxLayout(topFrame);
  topLayout->setContentsMargins(2,2,2,2);
  topLayout->setSpacing(3);
  
  QVBoxLayout *topVBox = diaVBoxLayout(topLayout);
  topVBox->setSpacing(4);
  QHBoxLayout *topHBox = diaHBoxLayout(topVBox);
  topHBox->setContentsMargins(0,0,0,0);
  topHBox->setSpacing(3);

  // Add the toolbar widgets
  // Zoom spin box
  // If you try to make a spin box narrower, it makes the arrows tiny
  mZoomBox = (QSpinBox *)diaLabeledSpin(0, 1., XTUM_MAX_ZOOM, 1., "Zoom",
                                        topFrame, topHBox);
  mZoomBox->setValue(xtum->zoom);
  connect(mZoomBox, SIGNAL(valueChanged(int)), this, 
	  SLOT(zoomChanged(int)));
  mZoomBox->setToolTip("Change zoom of display");

  // Make the 2 toggle buttons and their signal mapper
  QSignalMapper *toggleMapper = new QSignalMapper(topFrame);
  connect(toggleMapper, SIGNAL(mapped(int)), this, SLOT(toggleClicked(int)));
  for (j = 0; j < 2; j++) {
    utilSetupToggleButton(topFrame, NULL, topHBox, toggleMapper, icons, 
                          toggleTips, mToggleButs, mToggleStates, j);
    connect(mToggleButs[j], SIGNAL(clicked()), toggleMapper, SLOT(map()));
  }

  // Help button
  mHelpButton = diaPushButton("Help", topFrame, topHBox);
  connect(mHelpButton, SIGNAL(clicked()), this, SLOT(help()));
  setFontDependentWidths();

  topHBox->addStretch();

  // Make second row for size spin boxes, and signal map them
  QHBoxLayout *botHBox = diaHBoxLayout(topVBox);
  botHBox->setContentsMargins(0,0,0,0);
  botHBox->setSpacing(3);
  QSignalMapper *sizeMapper = new QSignalMapper(topFrame);
  connect(sizeMapper, SIGNAL(mapped(int)), this, SLOT(sizeChanged(int)));

  // Make the spin boxes
  for (j = 0; j < 3; j++) {
    str = xyzLabels[j];
    mSizeBoxes[j] = (QSpinBox *)diaLabeledSpin(0, XTUM_SIZE_MIN, XTUM_SIZE_MAX,
                                               XTUM_SIZE_INC, LATIN1(str), 
                                               topFrame, botHBox);
    mSizeBoxes[j]->setValue(XTUM_SIZE_INI);
    sizeMapper->setMapping(mSizeBoxes[j], j);
    connect(mSizeBoxes[j], SIGNAL(valueChanged(int)), sizeMapper, SLOT(map()));
    mSizeBoxes[j]->setToolTip("Change size of box in " + str);
  }

  // Spacer for the second row
  botHBox->addStretch();

  // Add a vertical line
  QFrame *vertLine = new QFrame(topFrame);
  vertLine->setFrameStyle(QFrame::Sunken | QFrame::VLine);
  topLayout->addWidget(vertLine);

  // Threshold sliders
  mSliders = new MultiSlider(topFrame, 2, sliderLabels);
  topLayout->addLayout(mSliders->getLayout());
  connect(mSliders, SIGNAL(sliderChanged(int, int, bool)), this, 
	  SLOT(thresholdChanged(int, int, bool)));
  mSliders->setValue(0, xtum->minval);
  mSliders->setValue(1, xtum->maxval);
  mSliders->getSlider(0)->setToolTip(
		"Level below which pixels will be set to black");
  mSliders->getSlider(1)->setToolTip(
		"Level above which pixels will be set to white");


  QGLFormat glFormat;
  glFormat.setRgba(rgba);
  glFormat.setDoubleBuffer(doubleBuffer);
  glFormat.setDepth(enableDepth);
  mGLw = new TumblerGL(xtum, glFormat, central);
  cenlay->addWidget(mGLw);
  cenlay->setStretchFactor(mGLw, 1);

  resize(XTUM_WIDTH, XTUM_HEIGHT);
  setFocusPolicy(Qt::StrongFocus);
}
Beispiel #4
0
ImodvImage::ImodvImage(QWidget *parent, bool fillBut, const char *name)
  : DialogFrame(parent, fillBut ? 3 : 2, 1, buttonLabels, buttonTips, true, 
                ImodPrefs->getRoundedStyle(), "3dmodv Image View", "", name)
{
  mCtrlPressed = false;

  // Make view checkboxes
  mViewXBox = diaCheckBox("View X image", this, mLayout);
  mViewXBox->setChecked(sFlags & IMODV_DRAW_CX);
  connect(mViewXBox, SIGNAL(toggled(bool)), this, SLOT(viewXToggled(bool)));
  mViewYBox = diaCheckBox("View Y image", this, mLayout);
  mViewYBox->setChecked(sFlags & IMODV_DRAW_CY);
  connect(mViewYBox, SIGNAL(toggled(bool)), this, SLOT(viewYToggled(bool)));
  mViewZBox = diaCheckBox("View Z image", this, mLayout);
  mViewZBox->setChecked(sFlags & IMODV_DRAW_CZ);
  connect(mViewZBox, SIGNAL(toggled(bool)), this, SLOT(viewZToggled(bool)));
  mViewXBox->setToolTip("Display YZ plane at current X");
  mViewYBox->setToolTip("Display XZ plane at current Y");
  mViewZBox->setToolTip("Display XY plane at current Z");

  // Make multisliders
  mSliders = new MultiSlider(this, 10, sliderLabels);

  mSliders->setRange(IIS_X_COORD, 1, Imodv->vi->xsize);
  mSliders->setRange(IIS_X_SIZE, 1, Imodv->vi->xsize);
  if (sLastYsize < 0) {
    sXdrawSize = Imodv->vi->xsize;
    sYdrawSize = Imodv->vi->ysize;
    sZdrawSize = Imodv->vi->zsize;
    sLastYsize = Imodv->vi->ysize;
  }
  updateCoords();
  mSliders->setValue(IIS_X_SIZE, sXdrawSize);
  mSliders->setValue(IIS_Y_SIZE, sYdrawSize);
  mSliders->setValue(IIS_Z_SIZE, sZdrawSize);
  mSliders->setRange(IIS_SLICES, 1, 64);
  mSliders->setValue(IIS_SLICES, sNumSlices);
  mSliders->setRange(IIS_TRANSPARENCY, 0, 100);
  mSliders->setValue(IIS_TRANSPARENCY, sImageTrans);
  mSliders->setValue(IIS_BLACK, sBlackLevel);
  mSliders->setValue(IIS_WHITE, sWhiteLevel);
  mLayout->addLayout(mSliders->getLayout());
  (mSliders->getLayout())->setSpacing(4);
  connect(mSliders, SIGNAL(sliderChanged(int, int, bool)), this, 
          SLOT(sliderMoved(int, int, bool)));
  mSliders->getSlider(IIS_X_COORD)->setToolTip("Set current image X coordinate");
  mSliders->getSlider(IIS_Y_COORD)->setToolTip("Set current image Y coordinate");
  mSliders->getSlider(IIS_Z_COORD)->setToolTip("Set current image Z coordinate");
  mSliders->getSlider(IIS_X_SIZE)->setToolTip("Set image size to display in X");
  mSliders->getSlider(IIS_Y_SIZE)->setToolTip("Set image size to display in Y");
  mSliders->getSlider(IIS_Z_SIZE)->setToolTip("Set image size to display in Z");
  mSliders->getSlider(IIS_SLICES)->setToolTip("Set number of slices to display");
  mSliders->getSlider(IIS_TRANSPARENCY)->setToolTip("Set percent transparency");
  mSliders->getSlider(IIS_BLACK)->setToolTip("Set minimum black level of contrast ramp");
  mSliders->getSlider(IIS_WHITE)->setToolTip("Set maximum white level of contrast ramp");

  QPushButton *copyBut = diaPushButton("Use 3dmod Black/White", this, mLayout);
  copyBut->setToolTip("Set black and white levels from sliders in 3dmod Info window");
  connect(copyBut, SIGNAL(clicked()), this, SLOT(copyBWclicked()));

  // Make false color checkbox
  mFalseBox = diaCheckBox("False color", this, mLayout);
  mFalseBox->setChecked(sFalsecolor);
  connect(mFalseBox, SIGNAL(toggled(bool)), this, SLOT(falseToggled(bool)));
  mFalseBox->setToolTip("Display image in false color");

  if (Imodv->vi->colormapImage) {
    mFalseBox->setEnabled(false);
    copyBut->setEnabled(false);
    mSliders->getSlider(IIS_SLICES)->setEnabled(false);
    mSliders->getSlider(IIS_BLACK)->setEnabled(false);
    mSliders->getSlider(IIS_WHITE)->setEnabled(false);
  }

  connect(this, SIGNAL(actionClicked(int)), this, SLOT(buttonPressed(int)));
}
Beispiel #5
0
/*
 * Object list class constructor
 */
ImodvOlist::ImodvOlist(QWidget *parent, Qt::WFlags fl)
  : QWidget(parent, fl)
{
  int nPerCol, olistNcol, ob, i;
  QString qstr;
  QLabel *label;
  const char *labels[] = {"New", "Delete", "Clear", "Add All", "Swap", "ON", "OFF",
                    "On", "Off"};
  const char *tips[] = {"Start a new object group, copied from current group",
                  "Remove the current object group from list of groups",
                  "Remove all objects from the current group",
                  "Add all objects to the current group",
                  "Remove current members and add all non-members",
                  "Turn ON all objects in the current group",
                  "Turn OFF all objects in the current group",
                  "Turn ON objects NOT in the current group",
                  "Turn OFF objects NOT in the current group"};
  
  setAttribute(Qt::WA_DeleteOnClose);
  setAttribute(Qt::WA_AlwaysShowToolTips);
  QVBoxLayout *layout = new QVBoxLayout(this);
  layout->setContentsMargins(5, 5, 5, 5);
  layout->setSpacing(6);

  QGroupBox *grpbox = new QGroupBox("Object Group Selection");
  layout->addWidget(grpbox);
  QVBoxLayout *gblay = new QVBoxLayout(grpbox);
  gblay->setContentsMargins(6, 3, 6, 6);
  gblay->setSpacing(6);
  QHBoxLayout *hbox = diaHBoxLayout(gblay); 
  
  mGroupSpin = (QSpinBox *)diaLabeledSpin(0, 0., 0., 1., "Group", grpbox,hbox);
  mGroupSpin->setSpecialValueText("None");
  connect(mGroupSpin, SIGNAL(valueChanged(int)), this, 
          SLOT(curGroupChanged(int)));
  mGroupSpin->setToolTip("Select the current object group or turn off "
                "selection");

  mNumberLabel = diaLabel("/99", grpbox, hbox);
  mNameEdit = new QLineEdit(grpbox);
  hbox->addWidget(mNameEdit);
  mNameEdit->setMaxLength(OBJGRP_STRSIZE - 1);
  mNameEdit->setFocusPolicy(Qt::ClickFocus);
  connect(mNameEdit, SIGNAL(returnPressed()), this,
          SLOT(returnPressed()));
  connect(mNameEdit, SIGNAL(textChanged(const QString&)), this,
          SLOT(nameChanged(const QString&)));
  mNameEdit->setToolTip("Enter a name for the current group");

  QSignalMapper *clickMapper = new QSignalMapper(this);
  connect(clickMapper, SIGNAL(mapped(int)), this,
          SLOT(actionButtonClicked(int)));

  // Make the buttons and put in hbox
  for (i = 0; i < OBJLIST_NUMBUTTONS; i++) {

    if (i == 0 || i == 5)
      hbox = diaHBoxLayout(gblay);
    if (i == 7) {
      label = diaLabel("Others:", grpbox, hbox);
      label->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
    }

    qstr = labels[i];
    mButtons[i] = diaPushButton(LATIN1(qstr), grpbox, hbox);
    clickMapper->setMapping(mButtons[i], i);
    connect(mButtons[i], SIGNAL(clicked()), clickMapper, SLOT(map()));
    mButtons[i]->setToolTip(tips[i]);
  }

  mScroll = new QScrollArea(this);
  layout->addWidget(mScroll);
  mFrame = new QFrame();
  mScroll->setAutoFillBackground(true);
  QPalette palette = mFrame->palette();
  QColor bkg = palette.color(mFrame->backgroundRole());
  diaSetWidgetColor(mScroll->viewport(), bkg);
  mGrid = new QGridLayout(mFrame);
  mGrid->setSpacing(2);
  olistNcol = (numOolistButtons + MAX_LIST_IN_COL - 1) / MAX_LIST_IN_COL;
  nPerCol = (numOolistButtons + olistNcol - 1) / olistNcol;

  // Get a signal mapper, connect to the slot for these buttons
  QSignalMapper *mapper = new QSignalMapper(this);
  connect(mapper, SIGNAL(mapped(int)), this, SLOT(toggleListSlot(int)));
  QSignalMapper *gmapper = new QSignalMapper(this);
  connect(gmapper, SIGNAL(mapped(int)), this, SLOT(toggleGroupSlot(int)));
  
  // Make the buttons, set properties and map them
  for (ob = 0; ob < numOolistButtons; ob++) {
    QHBoxLayout *hLayout = new QHBoxLayout();
    mGrid->addLayout(hLayout, ob % nPerCol, ob / nPerCol);
    groupButtons[ob] = diaCheckBox("", mFrame, hLayout);
    qstr.sprintf("%d: ",ob + 1);
    OolistButtons[ob] = diaCheckBox(LATIN1(qstr), mFrame, hLayout);
    OolistButtons[ob]->setAutoFillBackground(true);
    mapper->setMapping(OolistButtons[ob], ob);
    connect(OolistButtons[ob], SIGNAL(toggled(bool)), mapper, SLOT(map()));
    gmapper->setMapping(groupButtons[ob], ob);
    connect(groupButtons[ob], SIGNAL(toggled(bool)), gmapper, SLOT(map()));
    hLayout->setStretchFactor(OolistButtons[ob], 100);

    // Hide the buttons later after window size is set
    grouping = true;
  }
  mScroll->setWidget(mFrame);

  // Make a line
  QFrame *line = new QFrame(this);
  line->setFrameShape( QFrame::HLine );
  line->setFrameShadow( QFrame::Sunken );
  layout->addWidget(line);

  QHBoxLayout *box = diaHBoxLayout(layout);
  mDoneButton = diaPushButton("Done", this, box);
  connect(mDoneButton, SIGNAL(clicked()), this, SLOT(donePressed()));
  mHelpButton = diaPushButton("Help", this, box);
  connect(mHelpButton, SIGNAL(clicked()), this, SLOT(helpPressed()));
  setFontDependentWidths();
}