// Set color for one object void imodvOlistSetColor(ImodvApp *a, int ob) { Iobj *obj; if (!Oolist_dialog || ob >= numOolistButtons || ob >= a->imod->objsize) return; obj = &a->imod->obj[ob]; diaSetWidgetColor (OolistButtons[ob], QColor((int)(255 * obj->red), (int)(255 * obj->green), (int)(255 * obj->blue))); }
void imodvOlistUpdateOnOffs(ImodvApp *a) { int ob; bool state, nameChgd = false; QString qstr; char obname[MAX_LIST_NAME]; int len; QColor bkgColor; QColor gray; if (!Oolist_dialog || !numOolistButtons) return; QPalette palette = Oolist_dialog->palette(); gray = palette.color(Oolist_dialog->backgroundRole()); // Hiding seems to help the updates some, especially if there are text // changes or massive turning off of buttons, but processing events after // hiding doesn't help the time on Linux and leaves it gray (3/26/09) if (numOolistButtons > 256) Oolist_dialog->mFrame->hide(); for (ob = 0; ob < numOolistButtons; ob++) { if (ob < a->imod->objsize) { // Get a truncated name // DMN 9/20/04: just truncate all columns a little bit now len = strlen(a->imod->obj[ob].name); if (len > MAX_LIST_NAME - 1) len = MAX_LIST_NAME - 1; strncpy(obname, a->imod->obj[ob].name, len); obname[len] = 0x00; qstr.sprintf("%d: %s",ob + 1, obname); state = !(a->imod->obj[ob].flags & IMOD_OBJFLAG_OFF); bkgColor.setRgb((int)(255. * a->imod->obj[ob].red), (int)(255. * a->imod->obj[ob].green), (int)(255. * a->imod->obj[ob].blue)); if (OolistButtons[ob]->isHidden()) { OolistButtons[ob]->show(); nameChgd = true; } if (qstr != OolistButtons[ob]->text()) { OolistButtons[ob]->setText(qstr); nameChgd = true; } diaSetWidgetColor(OolistButtons[ob], bkgColor); diaSetChecked(OolistButtons[ob], state); } else if (!OolistButtons[ob]->isHidden()) { OolistButtons[ob]->hide(); nameChgd = true; } } if (numOolistButtons > 256) Oolist_dialog->mFrame->show(); if (nameChgd) Oolist_dialog->adjustFrameSize(); }
/* Modify the mouse function labels as appropriate */ void MidasGL::manageMouseLabel(const char *string) { int i, active = 0; QString ctap = QString(CTRL_STRING).left(2); QString label; if (VW->ctrlPressed) active = 2; else if (VW->shiftPressed) active = 1; for (i = 0; i < 3; i++) diaSetWidgetColor(VW->mouseLabel[i], QColor(i == active ? "red" : "blue"), QPalette::Foreground); if (mMousePressed) VW->mouseLabel[active]->setText(QString(string)); if (!mMousePressed || active != 0) { label = VW->editWarps ? "shift/sel -- " : "shift -- "; if (VW->xtype == XTYPE_MONT) label += " -- "; else label += VW->editWarps ? "add pt -- " : "rotate -- "; if (VW->xtype != XTYPE_MONT) label += VW->editWarps ? "move pt" : (VW->useFixed ? "2 pt stretch" : "stretch"); VW->mouseLabel[0]->setText(label); } if (!mMousePressed || active != 1) { if (VW->editWarps) label = "Sh: Select pt -- -- "; else label = QString("Sh: -- -- ") + (VW->xtype != XTYPE_MONT ? "magnify " : " "); VW->mouseLabel[1]->setText(label); } if (!mMousePressed || active != 2) { label = ctap + ": pan -"; if (VW->editWarps) label += "- -- "; else { label += " new center - "; label += VW->xtype == XTYPE_MONT ? " " : (VW->useFixed ? "no 2 pt" : "fixed pt"); } VW->mouseLabel[2]->setText(label); } }
/* * 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(); }