SelectBox::SelectBox(Shape s, QWidget* parent) : QRubberBand(s, parent) { //Default values setColors(QColor(Qt::darkGreen), QColor(Qt::green), QColor(Qt::darkBlue), QColor(Qt::blue), 32); }
int main(int argc, char *argv[]) { int threshold, rh, theta, rows, cols, rScale, tScale, hitImage, i; char *inputo, *inputh, *inpute, *outputl; float r, t, diag, x, y, c, s; Image io, ih, ie; if (argc < 5) { fprintf(stderr, "usage: %s <input original scene image> <input hough image> <input thresholded image> <hough threshold> <cropped line-detected output image>\n", argv[0]); exit(0); } inputo = argv[1]; inputh = argv[2]; inpute = argv[3]; if (sscanf(argv[4], "%d", &threshold) != 1) { fprintf(stderr, "error: threshold not an integer\n"); exit(1); } outputl = argv[5]; if (readImage(&io, inputo) == -1) { std::cerr << "Error reading file " << inputo << "\n"; exit(1); } else if (readImage(&ih, inputh) == -1) { std::cerr << "Error reading file " << inputh << "\n"; exit(1); } else if (readImage(&ie, inpute) == -1) { std::cerr << "Error reading file " << inpute << "\n"; exit(1); } rows = getNRows(&io); cols = getNCols(&io); diag = sqrt(pow(rows, 2) + pow(cols, 2)); rScale = getNRows(&ih); tScale = getNCols(&ih); for (rh = 0; rh < rScale; ++rh) { for (theta = 0; theta < tScale; ++theta) { if (getPixel(&ih, rh, theta) >= threshold) { r = ((2*diag)/rScale)*rh - diag; t = (PI/tScale)*theta - PI/2; c = cos(t); s = sin(t); x = -r*s; // cos(t + pi/2) = -sin(t) y = r*c; // sin(t + pi/2) = cos(t) if (inImage(&io, x, y)) { x -= diag*c; y -= diag*s; } hitImage = 0; i = 0; while (!hitImage || inImage(&io, x + i*c, y + i*s)) { if (!hitImage && inImage(&io, x + i*c, y + i*s)) hitImage = 1; if (hitImage && getPixel(&ie, y + i*s, x + i*c)) { setPixel(&io, y + i*s, x + i*c, 255); } i++; } } } } setColors(&io, 255); if (writeImage(&io, outputl) == -1) { std::cerr << "Error writing file " << outputl << "\n"; } free(io.data); free(ih.data); free(ie.data); }
void caMessageButton::setNormalColors() { setColors(thisBackColor, thisForeColor, thisHoverColor, thisBorderColor, thisDisabledForeColor); }
UINodeSlider::UINodeSlider (IFrontend *frontend, float min, float max, float stepWidth) : UINode(frontend), _value(0), _min(min), _max(max), _stepWidth(stepWidth) { setColors(colorGray, colorWhite); setStandardPadding(); }
MObject createPoly(double iFrame, PolyMeshAndColors & iNode, MObject & iParent) { Alembic::AbcGeom::IPolyMeshSchema schema = iNode.mMesh.getSchema(); MString name(iNode.mMesh.getName().c_str()); MObject obj; // add other properties if (!schema.isConstant()) { MFloatPointArray emptyPt; MIntArray emptyInt; MFnMesh fnMesh; obj = fnMesh.create(0, 0, emptyPt, emptyInt, emptyInt, iParent); fnMesh.setName(name); } else { Alembic::AbcCoreAbstract::index_t index, ceilIndex; double alpha = getWeightAndIndex(iFrame, schema.getTimeSampling(), schema.getNumSamples(), index, ceilIndex); Alembic::AbcGeom::IPolyMeshSchema::Sample samp; schema.get(samp, Alembic::Abc::ISampleSelector(index)); MFloatPointArray ptArray; Alembic::Abc::P3fArraySamplePtr ceilPoints; if (index != ceilIndex) { Alembic::AbcGeom::IPolyMeshSchema::Sample ceilSamp; schema.get(ceilSamp, Alembic::Abc::ISampleSelector(ceilIndex)); ceilPoints = ceilSamp.getPositions(); } fillPoints(ptArray, samp.getPositions(), ceilPoints, alpha); MFnMesh fnMesh; fillTopology(fnMesh, iParent, ptArray, samp.getFaceIndices(), samp.getFaceCounts()); fnMesh.setName(iNode.mMesh.getName().c_str()); setPolyNormals(iFrame, fnMesh, schema.getNormalsParam()); setUVs(iFrame, fnMesh, schema.getUVsParam()); obj = fnMesh.object(); } MFnMesh fnMesh(obj); MString pathName = fnMesh.partialPathName(); setInitialShadingGroup(pathName); setColors(iFrame, fnMesh, iNode.mC3s, iNode.mC4s, true); if ( !schema.getNormalsParam().valid() ) { MFnNumericAttribute attr; MString attrName("noNormals"); MObject attrObj = attr.create(attrName, attrName, MFnNumericData::kBoolean, true); attr.setKeyable(true); attr.setHidden(false); fnMesh.addAttribute(attrObj, MFnDependencyNode::kLocalDynamicAttr); } return obj; }
void *MsgViewBase::processEvent(Event *e) { if ((e->type() == EventRewriteMessage) || (e->type() == EventMessageRead)) { Message *msg = (Message*)(e->param()); if (msg->contact() != m_id) return NULL; unsigned i; for (i = 0; i < (unsigned)paragraphs(); i++) { QString s = text(i); int n = s.find(MSG_ANCHOR); if (n < 0) continue; s = s.mid(n + strlen(MSG_ANCHOR)); n = s.find("\""); if (n < 0) continue; string client; if ((messageId(s.left(n), client) == msg->id()) && (client == msg->client())) break; } if (i >= (unsigned)paragraphs()) return NULL; Msg_Id id; id.id = msg->id(); id.client = msg->client(); m_updated.push_back(id); QTimer::singleShot(0, this, SLOT(update())); return NULL; } if (e->type() == EventCutHistory) { CutHistory *ch = (CutHistory*)(e->param()); if (ch->contact != m_id) return NULL; bool bDelete = false; vector<unsigned> start_pos; vector<unsigned> end_pos; for (unsigned i = 0; i < (unsigned)paragraphs(); i++) { QString s = text(i); int n = s.find(MSG_ANCHOR); if (n < 0) continue; s = s.mid(n + strlen(MSG_ANCHOR)); n = s.find("\""); if (n < 0) continue; string client; unsigned id = messageId(s.left(n), client); if ((client == ch->client) && (id >= ch->from) && (id < ch->from + ch->size)) { if (!bDelete) { bDelete = true; start_pos.push_back(i); } } else { if (bDelete) { bDelete = false; end_pos.push_back(i); } } } if (bDelete) end_pos.push_back(paragraphs()); if (start_pos.size()) { int paraFrom, indexFrom; int paraTo, indexTo; getSelection(¶From, &indexFrom, ¶To, &indexTo); QPoint p = QPoint(0, 0); p = mapToGlobal(p); p = viewport()->mapFromGlobal(p); int x, y; viewportToContents(p.x(), p.y(), x, y); int para; int pos = charAt(QPoint(x, y), ¶); setReadOnly(false); for (unsigned i = 0; i < start_pos.size(); i++) { setSelection(start_pos[i], 0, end_pos[i], 0, 0); removeSelectedText(); if ((unsigned)pos >= start_pos[i]) pos = end_pos[i] - start_pos[i]; } if ((paraFrom == -1) && (paraTo == -1)) { if (pos == -1) { scrollToBottom(); } else { setCursorPosition(para, pos); ensureCursorVisible(); } } else { setSelection(paraFrom, indexFrom, paraTo, indexTo, 0); } setReadOnly(true); repaint(); } m_cut.push_back(*ch); return NULL; } if (e->type() == EventMessageDeleted) { Message *msg = (Message*)(e->param()); if (msg->contact() != m_id) return NULL; for (unsigned i = 0; i < (unsigned)paragraphs(); i++) { QString s = text(i); int n = s.find(MSG_ANCHOR); if (n < 0) continue; s = s.mid(n + strlen(MSG_ANCHOR)); n = s.find("\""); if (n < 0) continue; string client; if ((messageId(s.left(n), client) != msg->id()) || (client != msg->client())) continue; string ss; ss = text(i).local8Bit(); unsigned j; for (j = i + 1; j < (unsigned)paragraphs(); j++) { QString s = text(j); ss = text(j).local8Bit(); int n = s.find(MSG_ANCHOR); if (n < 0) continue; s = s.mid(n + strlen(MSG_ANCHOR)); n = s.find("\""); if (n < 0) continue; string client; if ((messageId(s.left(n), client) != msg->id()) || (client != msg->client())) break; } int paraFrom, indexFrom; int paraTo, indexTo; getSelection(¶From, &indexFrom, ¶To, &indexTo); unsigned pos = 0xFFFF; if (j == (unsigned)paragraphs()) { j++; pos = 0; } setSelection(i, 0, j - 1, pos, 0); setReadOnly(false); removeSelectedText(); setReadOnly(true); if ((paraFrom == -1) && (paraTo == -1)) { scrollToBottom(); } else { setSelection(paraFrom, indexFrom, paraTo, indexTo, 0); } break; } return NULL; } if (e->type() == EventHistoryConfig) { unsigned long id = (unsigned long)(e->param()); if (id && (id != m_id)) return NULL; reload(); } if (e->type() == EventHistoryColors) setColors(); if (e->type() == EventCheckState) { CommandDef *cmd = (CommandDef*)(e->param()); if ((cmd->param != this) || (cmd->menu_id != MenuMsgView)) return NULL; Message *msg; switch (cmd->id) { case CmdCopy: cmd->flags &= ~(COMMAND_DISABLED | COMMAND_CHECKED); if (!hasSelectedText()) cmd->flags |= COMMAND_DISABLED; return e->param(); case CmdMsgOpen: msg = currentMessage(); if (msg) { unsigned type = msg->baseType(); delete msg; CommandDef *def = CorePlugin::m_plugin->messageTypes.find(type); if (def == NULL) return NULL; cmd->icon = def->icon; cmd->flags &= ~COMMAND_CHECKED; return e->param(); } return NULL; case CmdMsgSpecial: msg = currentMessage(); if (msg) { Event eMenu(EventGetMenuDef, (void*)MenuMsgCommand); CommandsDef *cmdsMsg = (CommandsDef*)(eMenu.process()); unsigned n = 0; MessageDef *mdef = NULL; unsigned type = msg->baseType(); const CommandDef *cmdsSpecial = NULL; CommandDef *msgCmd = CorePlugin::m_plugin->messageTypes.find(type); if (msgCmd) mdef = (MessageDef*)(msgCmd->param); if (mdef) { if (msg->getFlags() & MESSAGE_RECEIVED) { cmdsSpecial = mdef->cmdReceived; } else { cmdsSpecial = mdef->cmdSent; } if (cmdsSpecial) for (const CommandDef *d = cmdsSpecial; d->text; d++) n++; } { CommandsList it(*cmdsMsg, true); while (++it) n++; } if (n == 0) return NULL; n++; CommandDef *cmds = new CommandDef[n]; memset(cmds, 0, sizeof(CommandDef) * n); n = 0; if (cmdsSpecial) { for (const CommandDef *d = cmdsSpecial; d->text; d++) { cmds[n] = *d; cmds[n].id = CmdMsgSpecial + n; cmds[n].flags = COMMAND_DEFAULT; n++; } } CommandDef *c; CommandsList it(*cmdsMsg, true); while ((c = ++it) != NULL) { CommandDef cmd = *c; cmd.menu_id = MenuMsgCommand; cmd.param = msg; Event e(EventCheckState, &cmd); if (!e.process()) continue; cmd.flags &= ~COMMAND_CHECK_STATE; cmds[n++] = cmd; } cmd->param = cmds; cmd->flags |= COMMAND_RECURSIVE; delete msg; return e->param(); } return NULL; } } if (e->type() == EventCommandExec) { CommandDef *cmd = (CommandDef*)(e->param()); if ((cmd->param != this) || (cmd->menu_id != MenuMsgView)) return NULL; Message *msg; switch (cmd->id) { case CmdCutHistory: msg = currentMessage(); if (msg) { History::cut(msg, 0, 0); delete msg; return e->param(); } return NULL; case CmdDeleteMessage: msg = currentMessage(); if (msg) { History::del(msg); delete msg; return e->param(); } return NULL; case CmdCopy: copy(); return e->param(); case CmdMsgOpen: msg = currentMessage(); if (msg) { msg->setFlags(msg->getFlags() | MESSAGE_OPEN); Event eOpen(EventOpenMessage, &msg); eOpen.process(); delete msg; return e->param(); } return NULL; default: msg = currentMessage(); if (msg) { if (cmd->id >= CmdMsgSpecial) { MessageDef *mdef = NULL; unsigned type = msg->baseType(); CommandDef *msgCmd = CorePlugin::m_plugin->messageTypes.find(type); if (msgCmd) mdef = (MessageDef*)(msgCmd->param); const CommandDef *cmds = NULL; if (mdef) { if (msg->getFlags() & MESSAGE_RECEIVED) { cmds = mdef->cmdReceived; } else { cmds = mdef->cmdSent; } } if (cmds) { unsigned n = cmd->id - CmdMsgSpecial; for (const CommandDef *d = cmds; d->text; d++) { if (n-- == 0) { CommandDef cmd = *d; cmd.param = msg; cmd.menu_id = 0; Event eCmd(EventCommandExec, &cmd); eCmd.process(); return e->param(); } } } } Command c; c->id = cmd->id; c->menu_id = MenuMsgCommand; c->param = msg; Event e(EventCommandExec, c); void *res = e.process(); delete msg; return res; } return NULL; } } return NULL; }
//-------------------------------------------------------------------------------------------------- /// Sets the colors from a predefined color set that will be used in the legend. /// Will be interpolated when needed. //-------------------------------------------------------------------------------------------------- void ScalarMapperRangeBased::setColors(ColorTable colorTable) { ref<Color3ubArray> baseColors = colorTableArray(colorTable); setColors(*baseColors); }
void SkeletonBlendedGeometry::changed(ConstFieldMaskArg whichField, UInt32 origin, BitVector details) { Inherited::changed(whichField, origin, details); //Do not respond to changes that have a Sync origin if(origin & ChangedOrigin::Sync) { return; } if((whichField & BaseGeometryFieldMask) && getBaseGeometry() != NULL) { if(getBaseGeometry()->getTypes() != NULL) { setTypes(getBaseGeometry()->getTypes()); } if(getBaseGeometry()->getLengths() != NULL) { setLengths(getBaseGeometry()->getLengths()); } if(getBaseGeometry()->getPositions() != NULL) { GeoPropertyUnrecPtr Pos(getBaseGeometry()->getPositions()->clone()); setPositions(dynamic_pointer_cast<GeoVectorProperty>(Pos)); } if(getBaseGeometry()->getNormals() != NULL) { GeoPropertyUnrecPtr Norm(getBaseGeometry()->getNormals()->clone()); setNormals(dynamic_pointer_cast<GeoVectorProperty>(Norm)); } if(getBaseGeometry()->getColors() != NULL) { setColors(getBaseGeometry()->getColors()); } if(getBaseGeometry()->getSecondaryColors() != NULL) { setSecondaryColors(getBaseGeometry()->getSecondaryColors()); } if(getBaseGeometry()->getTexCoords() != NULL) { setTexCoords(getBaseGeometry()->getTexCoords()); } if(getBaseGeometry()->getTexCoords1() != NULL) { setTexCoords1(getBaseGeometry()->getTexCoords1()); } if(getBaseGeometry()->getTexCoords2() != NULL) { setTexCoords2(getBaseGeometry()->getTexCoords2()); } if(getBaseGeometry()->getTexCoords3() != NULL) { setTexCoords3(getBaseGeometry()->getTexCoords3()); } if(getBaseGeometry()->getTexCoords4() != NULL) { setTexCoords4(getBaseGeometry()->getTexCoords4()); } if(getBaseGeometry()->getTexCoords5() != NULL) { setTexCoords5(getBaseGeometry()->getTexCoords5()); } if(getBaseGeometry()->getTexCoords6() != NULL) { setTexCoords6(getBaseGeometry()->getTexCoords6()); } if(getBaseGeometry()->getTexCoords7() != NULL) { setTexCoords7(getBaseGeometry()->getTexCoords7()); } if(getBaseGeometry()->getIndices() != NULL) { setIndices(getBaseGeometry()->getIndices()); } setMaterial(getBaseGeometry()->getMaterial()); } if(whichField & InternalJointsFieldMask) { _JointPoseTransforms.resize(getNumJoints()); } if( (whichField & BaseGeometryFieldMask) || (whichField & InternalJointsFieldMask) || (whichField & InternalWeightIndexesFieldMask) || (whichField & InternalWeightsFieldMask) || (whichField & BindTransformationFieldMask)) { if(getNumJoints() > 0) { _JointPoseTransforms.resize(getNumJoints()); calculatePositions(); } } }
Highlighter::Highlighter(QTextDocument *parent) : QSyntaxHighlighter(parent) { setColors(Qt::darkBlue,Qt::darkMagenta,Qt::red,Qt::darkGreen,Qt::blue); }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void ScalarMapperContinuousLog::setColors(ColorTable colorTable) { ref<Color3ubArray> baseColors = colorTableArray(colorTable); setColors(*baseColors); }
VCSColorsConfigWidget::VCSColorsConfigWidget(FileViewPart *part, const VCSColors &vcsColors, QWidget* parent, const char* name, WFlags fl) : VCSColorsConfigWidgetBase( parent, name, fl ), m_part( part ) { setColors( vcsColors ); }
void SinglePi(const TString ref_vers, const TString val_vers, bool fastsim){ //Warning!!! This rootlogon hacks the root color pallate setColors(); TString ref_file = "pi50scan"+ref_vers+"_fullGeom_ECALHCAL_CaloTowers.root"; TString val_file = "pi50scan"+val_vers+"_fullGeom_ECALHCAL_CaloTowers.root"; TFile f1(ref_file); TFile f2(val_file); // service variables // //Profiles const int Nprof = 12; TProfile* f1_prof[Nprof]; TProfile* f2_prof[Nprof]; char labelp[Nprof][64]; //1D Histos const int Nhist1 = 7; TH1* f1_hist1[Nhist1]; TH1* f2_hist1[Nhist1]; char label1[Nhist1][64]; //Labels //Profiles sprintf(labelp[0], "CaloTowersTask_emean_vs_ieta_E1.gif"); sprintf(labelp[1], "CaloTowersTask_emean_vs_ieta_H1.gif"); sprintf(labelp[2], "CaloTowersTask_emean_vs_ieta_EH1.gif"); sprintf(labelp[3], "RecHitsTask_emean_vs_ieta_E.gif"); sprintf(labelp[4], "RecHitsTask_emean_vs_ieta_H.gif"); sprintf(labelp[5], "RecHitsTask_emean_vs_ieta_EH.gif"); if (!fastsim) { sprintf(labelp[6], "SimHitsTask_emean_vs_ieta_E.gif"); sprintf(labelp[7], "SimHitsTask_emean_vs_ieta_H.gif"); sprintf(labelp[8], "SimHitsTask_emean_vs_ieta_EH.gif"); } sprintf(labelp[9], "RecHitsTask_timing_vs_energy_profile_HB.gif"); sprintf(labelp[10], "RecHitsTask_timing_vs_energy_profile_HE.gif"); sprintf(labelp[11], "RecHitsTask_timing_vs_energy_profile_HF.gif"); //1D Histos sprintf(label1[0], "N_calotowers_HB.gif"); sprintf(label1[1], "N_calotowers_HE.gif"); sprintf(label1[2], "N_calotowers_HF.gif"); sprintf(label1[3], "RecHits_energy_HB.gif"); sprintf(label1[4], "RecHits_energy_HE.gif"); sprintf(label1[5], "RecHits_energy_HO.gif"); sprintf(label1[6], "RecHits_energy_HF.gif"); TDirectory *td = fileDirectory(&f1, "CaloTowersTask"); //f1.cd("DQMData/CaloTowersV/CaloTowersTask"); //gDirectory->pwd(); td->pwd(); f1_prof[0] = (TProfile*)td->Get("emean_vs_ieta_E1"); f1_prof[1] = (TProfile*)td->Get("emean_vs_ieta_H1"); f1_prof[2] = (TProfile*)td->Get("emean_vs_ieta_EH1"); f1_hist1[0] = (TH1*)td->Get("CaloTowersTask_number_of_fired_towers_HB"); f1_hist1[1] = (TH1*)td->Get("CaloTowersTask_number_of_fired_towers_HE"); f1_hist1[2] = (TH1*)td->Get("CaloTowersTask_number_of_fired_towers_HF"); td = fileDirectory(&f1, "HcalRecHitTask"); //f1.cd("DQMData/HcalRecHitsV/HcalRecHitTask"); f1_prof[3] = (TProfile*)td->Get("HcalRecHitTask_En_rechits_cone_profile_vs_ieta_all_depths_E"); f1_prof[4] = (TProfile*)td->Get("HcalRecHitTask_En_rechits_cone_profile_vs_ieta_all_depths"); f1_prof[5] = (TProfile*)td->Get("HcalRecHitTask_En_rechits_cone_profile_vs_ieta_all_depths_EH"); f1_prof[9] = (TProfile*)td->Get("HcalRecHitTask_timing_vs_energy_profile_HB"); f1_prof[10] = (TProfile*)td->Get("HcalRecHitTask_timing_vs_energy_profile_Low_HE"); f1_prof[11] = (TProfile*)td->Get("HcalRecHitTask_timing_vs_energy_profile_Low_HF"); f1_hist1[3] = (TH1*)td->Get("HcalRecHitTask_energy_of_rechits_HB"); f1_hist1[4] = (TH1*)td->Get("HcalRecHitTask_energy_of_rechits_HE"); f1_hist1[5] = (TH1*)td->Get("HcalRecHitTask_energy_of_rechits_HO"); f1_hist1[6] = (TH1*)td->Get("HcalRecHitTask_energy_of_rechits_HF"); if (!fastsim) { td = fileDirectory(&f1, "HcalSimHitTask"); //f1.cd("DQMData/HcalSimHitsV/HcalSimHitTask"); f1_prof[6] = (TProfile*)td->Get("HcalSimHitTask_En_simhits_cone_profile_vs_ieta_all_depths_E"); f1_prof[7] = (TProfile*)td->Get("HcalSimHitTask_En_simhits_cone_profile_vs_ieta_all_depths"); f1_prof[8] = (TProfile*)td->Get("HcalSimHitTask_En_simhits_cone_profile_vs_ieta_all_depths_EH"); } td = fileDirectory(&f2, "CaloTowersTask"); //f2.cd("DQMData/CaloTowersV/CaloTowersTask"); //gDirectory->pwd(); td->pwd(); f2_prof[0] = (TProfile*)td->Get("emean_vs_ieta_E1"); f2_prof[1] = (TProfile*)td->Get("emean_vs_ieta_H1"); f2_prof[2] = (TProfile*)td->Get("emean_vs_ieta_EH1"); f2_hist1[0] = (TH1*)td->Get("CaloTowersTask_number_of_fired_towers_HB"); f2_hist1[1] = (TH1*)td->Get("CaloTowersTask_number_of_fired_towers_HE"); f2_hist1[2] = (TH1*)td->Get("CaloTowersTask_number_of_fired_towers_HF"); td = fileDirectory(&f2, "HcalRecHitTask"); //f2.cd("DQMData/HcalRecHitsV/HcalRecHitTask"); f2_prof[3] = (TProfile*)td->Get("HcalRecHitTask_En_rechits_cone_profile_vs_ieta_all_depths_E"); f2_prof[4] = (TProfile*)td->Get("HcalRecHitTask_En_rechits_cone_profile_vs_ieta_all_depths"); f2_prof[5] = (TProfile*)td->Get("HcalRecHitTask_En_rechits_cone_profile_vs_ieta_all_depths_EH"); f2_prof[9] = (TProfile*)td->Get("HcalRecHitTask_timing_vs_energy_profile_HB"); f2_prof[10] = (TProfile*)td->Get("HcalRecHitTask_timing_vs_energy_profile_Low_HE"); f2_prof[11] = (TProfile*)td->Get("HcalRecHitTask_timing_vs_energy_profile_Low_HF"); f2_hist1[3] = (TH1*)td->Get("HcalRecHitTask_energy_of_rechits_HB"); f2_hist1[4] = (TH1*)td->Get("HcalRecHitTask_energy_of_rechits_HE"); f2_hist1[5] = (TH1*)td->Get("HcalRecHitTask_energy_of_rechits_HO"); f2_hist1[6] = (TH1*)td->Get("HcalRecHitTask_energy_of_rechits_HF"); if (!fastsim) { td = fileDirectory(&f2, "HcalSimHitTask"); //f2.cd("DQMData/HcalSimHitsV/HcalSimHitTask"); f2_prof[6] = (TProfile*)td->Get("HcalSimHitTask_En_simhits_cone_profile_vs_ieta_all_depths_E"); f2_prof[7] = (TProfile*)td->Get("HcalSimHitTask_En_simhits_cone_profile_vs_ieta_all_depths"); f2_prof[8] = (TProfile*)td->Get("HcalSimHitTask_En_simhits_cone_profile_vs_ieta_all_depths_EH"); } //Profiles f1_prof[0]->GetXaxis()->SetTitle("CaloTowers eE (GeV) vs ieta 1 Tower"); f1_prof[1]->GetXaxis()->SetTitle("CaloTowers hE (GeV) vs ieta 1 Tower"); f1_prof[2]->GetXaxis()->SetTitle("CaloTowers eE+hE (GeV) vs ieta 1 Tower"); f1_prof[3]->GetXaxis()->SetTitle("RecHits eE (GeV) vs ieta R = 0.3 Cone"); f1_prof[4]->GetXaxis()->SetTitle("RecHits hE (GeV) vs ieta R = 0.3 Cone"); f1_prof[5]->GetXaxis()->SetTitle("RecHits eE+hE (GeV) vs ieta R = 0.3 Cone"); if (!fastsim) { f1_prof[6]->GetXaxis()->SetTitle("SimHits eE (GeV) vs ieta R = 0.3 Cone"); f1_prof[7]->GetXaxis()->SetTitle("SimHits hE (GeV) vs ieta R = 0.3 Cone"); f1_prof[8]->GetXaxis()->SetTitle("SimHits eE+hE (GeV) vs ieta R = 0.3 Cone"); } f1_prof[9]->GetXaxis()->SetTitle("HB RecHits timing (ns) vs Energy (GeV)"); f1_prof[10]->GetXaxis()->SetTitle("HE RecHits timing (ns) vs Energy (GeV)"); f1_prof[11]->GetXaxis()->SetTitle("HF RecHits timing (ns) vs Energy (GeV)"); //1D Histos f1_hist1[0]->GetXaxis()->SetTitle("Number of HB CaloTowers"); f1_hist1[1]->GetXaxis()->SetTitle("Number of HE CaloTowers"); f1_hist1[2]->GetXaxis()->SetTitle("Number of HF CaloTowers"); f1_hist1[3]->GetXaxis()->SetTitle("HB RecHits energy (GeV)"); f1_hist1[4]->GetXaxis()->SetTitle("HE RecHits energy (GeV)"); f1_hist1[5]->GetXaxis()->SetTitle("HO RecHits energy (GeV)"); f1_hist1[6]->GetXaxis()->SetTitle("HF RecHits energy (GeV)"); // f1_prof[0]->SetMaximum(20.); f1_prof[1]->SetMaximum(40.); f1_prof[2]->SetMaximum(40.); f1_prof[4]->SetMaximum(50.); f1_prof[5]->SetMaximum(50.); f1_prof[0]->SetMinimum(0.); f1_prof[1]->SetMinimum(0.); f1_prof[2]->SetMinimum(0.); f1_prof[3]->SetMinimum(0.); f1_prof[4]->SetMinimum(0.); f1_prof[5]->SetMinimum(0.); if (!fastsim) { f1_prof[6]->SetMinimum(0.); f1_prof[7]->SetMinimum(0.); f1_prof[8]->SetMinimum(0.); } f1_prof[9]->GetXaxis()->SetRangeUser(0.,75.); f1_prof[10]->GetXaxis()->SetRangeUser(0.,75.); f1_prof[11]->GetXaxis()->SetRangeUser(0.,75.); /* f1_prof[9]->SetMinimum(0.); f1_prof[10]->SetMinimum(0.); f1_prof[11]->SetMinimum(0.); */ // f1_hist[2]->GetXaxis()->SetRangeUser(0.,1200.); // f1_hist[7]->GetXaxis()->SetRangeUser(0.,160.); // hist1->GetXaxis()->SetNdivisions(-21); // hist1->GetYaxis()->SetNdivisions(-1003); f1_hist1[0]->GetXaxis()->SetRangeUser(0.,100.); f2_hist1[0]->GetXaxis()->SetRangeUser(0.,100.); f1_hist1[1]->GetXaxis()->SetRangeUser(0.,150.); f2_hist1[1]->GetXaxis()->SetRangeUser(0.,150.); f1_hist1[2]->GetXaxis()->SetRangeUser(0.,100.); f2_hist1[2]->GetXaxis()->SetRangeUser(0.,100.); f1_hist1[3]->GetXaxis()->SetRangeUser(0.,100.); f2_hist1[3]->GetXaxis()->SetRangeUser(0.,100.); f1_hist1[4]->GetXaxis()->SetRangeUser(0.,100.); f2_hist1[4]->GetXaxis()->SetRangeUser(0.,100.); f1_hist1[5]->GetXaxis()->SetRangeUser(0.,100.); f2_hist1[5]->GetXaxis()->SetRangeUser(0.,100.); f1_hist1[6]->GetXaxis()->SetRangeUser(0.,100.); f2_hist1[6]->GetXaxis()->SetRangeUser(0.,100.); f1_hist1[3]->SetMaximum(1.e8); f1_hist1[4]->SetMaximum(1.e8); f1_hist1[5]->SetMaximum(1.e8); f1_hist1[6]->SetMaximum(1.e8); // 1D-histo for (int i = 0; i < Nhist1; i++){ TCanvas *myc = new TCanvas("myc","",800,600); gStyle->SetOptStat(1111); if(i > 2) myc->SetLogy(); f1_hist1[i]->SetStats(kTRUE); // stat box f2_hist1[i]->SetStats(kTRUE); f1_hist1[i]->SetTitle(""); f2_hist1[i]->SetTitle(""); f1_hist1[i]->SetLineWidth(2); f2_hist1[i]->SetLineWidth(2); // diffferent histo colors and styles f1_hist1[i]->SetLineColor(41); f1_hist1[i]->SetLineStyle(1); f2_hist1[i]->SetLineColor(43); f2_hist1[i]->SetLineStyle(2); //Set maximum to the larger of the two if (f1_hist1[i]->GetMaximum() < f2_hist1[i]->GetMaximum()) f1_hist1[i]->SetMaximum(1.05 * f2_hist1[i]->GetMaximum()); TLegend *leg = new TLegend(0.2, 0.91, 0.6, 0.99, "","brNDC"); leg->SetBorderSize(2); // leg->SetFillColor(51); // see new color definition above leg->SetFillStyle(1001); // leg->AddEntry(f1_hist1[i],"CMSSW_"+ref_vers,"l"); leg->AddEntry(f2_hist1[i],"CMSSW_"+val_vers,"l"); TPaveStats *ptstats = new TPaveStats(0.85,0.86,0.98,0.98,"brNDC"); ptstats->SetTextColor(41); f1_hist1[i]->GetListOfFunctions()->Add(ptstats); ptstats->SetParent(f1_hist1[i]->GetListOfFunctions()); TPaveStats *ptstats2 = new TPaveStats(0.85,0.74,0.98,0.86,"brNDC"); ptstats2->SetTextColor(43); f2_hist1[i]->GetListOfFunctions()->Add(ptstats2); ptstats2->SetParent(f2_hist1[i]->GetListOfFunctions()); f1_hist1[i]->Draw(""); // "stat" f2_hist1[i]->Draw("histsames"); leg->Draw(); myc->SaveAs(label1[i]); if(myc) delete myc; } // Profiles for (int i = 0; i < Nprof; i++){ TCanvas *myc = new TCanvas("myc","",800,600); bool skipHisto = false; if (fastsim && i>=6 && i<=8) skipHisto = true; if (!skipHisto) { f1_prof[i]->SetStats(kFALSE); f2_prof[i]->SetStats(kFALSE); f1_prof[i]->SetTitle(""); f2_prof[i]->SetTitle(""); f1_prof[i]->SetLineColor(41); f1_prof[i]->SetLineStyle(1); f1_prof[i]->SetLineWidth(1); f1_prof[i]->SetMarkerColor(41); f1_prof[i]->SetMarkerStyle(21); f1_prof[i]->SetMarkerSize(1.0); f2_prof[i]->SetLineColor(43); f2_prof[i]->SetLineStyle(1); f2_prof[i]->SetLineWidth(1); f2_prof[i]->SetMarkerColor(43); f2_prof[i]->SetMarkerStyle(20); f2_prof[i]->SetMarkerSize(0.8); if(i > 8 ) { f1_prof[i]->SetMarkerSize(0.1); f2_prof[i]->SetMarkerSize(0.3); } myc->SetGrid(); if( i <= 8) { f1_prof[i]->Draw("histpl"); f2_prof[i]->Draw("histplsame"); // esame } else { f1_prof[i]->Draw("pl"); f2_prof[i]->Draw("plsame"); // esame } TLegend *leg = new TLegend(0.40, 0.91, 0.74, 0.99, "","brNDC"); leg->SetBorderSize(2); leg->SetFillStyle(1001); leg->AddEntry(f1_prof[i],"CMSSW_"+ref_vers,"pl"); leg->AddEntry(f2_prof[i],"CMSSW_"+val_vers,"pl"); leg->Draw(""); myc->SaveAs(labelp[i]); } if(myc) delete myc; } TCanvas *myc = new TCanvas("myc","",800,600); TProfile* ratio1 = (TProfile*)f2_prof[2]->Clone(); ratio1->Divide(f1_prof[2]); ratio1->SetMaximum(1.2); ratio1->SetMinimum(0.8); myc->SetGrid(); ratio1->Draw("hist pl"); TLegend *leg = new TLegend(0.20, 0.91, 0.70, 0.99, "","brNDC"); leg->SetBorderSize(2); leg->SetFillStyle(1001); leg->AddEntry(ratio1,"CaloTowers scale (pi50) ratio "+val_vers+"/"+ref_vers+" vs ieta","pl"); leg->Draw(""); // f1_prof[2]->Draw(); myc->SaveAs("Ratio.gif"); // close ROOT files // f1.Close() ; f2.Close() ; return ; }
void SkeletonBlendedGeometry::changed(ConstFieldMaskArg whichField, UInt32 origin, BitVector details) { Inherited::changed(whichField, origin, details); if((whichField & BaseGeometryFieldMask) && getBaseGeometry() != NULL) { if(getBaseGeometry()->getTypes() != NULL) { setTypes(getBaseGeometry()->getTypes()); } if(getBaseGeometry()->getLengths() != NULL) { setLengths(getBaseGeometry()->getLengths()); } if(getBaseGeometry()->getPositions() != NULL) { GeoPropertyUnrecPtr Pos(getBaseGeometry()->getPositions()->clone()); setPositions(dynamic_pointer_cast<GeoVectorProperty>(Pos)); } if(getBaseGeometry()->getNormals() != NULL) { GeoPropertyUnrecPtr Norm(getBaseGeometry()->getNormals()->clone()); setNormals(dynamic_pointer_cast<GeoVectorProperty>(Norm)); } if(getBaseGeometry()->getColors() != NULL) { setColors(getBaseGeometry()->getColors()); } if(getBaseGeometry()->getSecondaryColors() != NULL) { setSecondaryColors(getBaseGeometry()->getSecondaryColors()); } if(getBaseGeometry()->getTexCoords() != NULL) { setTexCoords(getBaseGeometry()->getTexCoords()); } if(getBaseGeometry()->getTexCoords1() != NULL) { setTexCoords1(getBaseGeometry()->getTexCoords1()); } if(getBaseGeometry()->getTexCoords2() != NULL) { setTexCoords2(getBaseGeometry()->getTexCoords2()); } if(getBaseGeometry()->getTexCoords3() != NULL) { setTexCoords3(getBaseGeometry()->getTexCoords3()); } if(getBaseGeometry()->getTexCoords4() != NULL) { setTexCoords4(getBaseGeometry()->getTexCoords4()); } if(getBaseGeometry()->getTexCoords5() != NULL) { setTexCoords5(getBaseGeometry()->getTexCoords5()); } if(getBaseGeometry()->getTexCoords6() != NULL) { setTexCoords6(getBaseGeometry()->getTexCoords6()); } if(getBaseGeometry()->getTexCoords7() != NULL) { setTexCoords7(getBaseGeometry()->getTexCoords7()); } if(getBaseGeometry()->getIndices() != NULL) { setIndices(getBaseGeometry()->getIndices()); } setMaterial(getBaseGeometry()->getMaterial()); } if((whichField & JointsFieldMask) || (whichField & PositionIndexesFieldMask) || (whichField & BlendAmountsFieldMask)) { calculatePositions(); } if(whichField & SkeletonsFieldMask) { for(std::vector<EventConnection>::iterator Itor(_SkeletonListenerConnections.begin()) ; Itor != _SkeletonListenerConnections.end() ; ++Itor) { Itor->disconnect(); } _SkeletonListenerConnections.clear(); for(UInt32 i(0) ; i<getMFSkeletons()->size() ; ++i) { _SkeletonListenerConnections.push_back(getSkeletons(i)->addSkeletonListener(this)); } } }
void KCMLookandFeel::save() { Plasma::Package package = Plasma::PluginLoader::self()->loadPackage(QStringLiteral("Plasma/LookAndFeel")); package.setPath(m_selectedPlugin); if (!package.isValid()) { return; } m_configGroup.writeEntry("LookAndFeelPackage", m_selectedPlugin); if (!package.filePath("defaults").isEmpty()) { KSharedConfigPtr conf = KSharedConfig::openConfig(package.filePath("defaults")); KConfigGroup cg(conf, "kdeglobals"); cg = KConfigGroup(&cg, "KDE"); if (m_applyWidgetStyle) { setWidgetStyle(cg.readEntry("widgetStyle", QString())); } if (m_applyColors) { QString colorsFile = package.filePath("colors"); KConfigGroup cg(conf, "kdeglobals"); cg = KConfigGroup(&cg, "General"); QString colorScheme = cg.readEntry("ColorScheme", QString()); if (!colorsFile.isEmpty()) { if (!colorScheme.isEmpty()) { setColors(colorScheme, colorsFile); } else { setColors(package.metadata().name(), colorsFile); } } else if (!colorScheme.isEmpty()) { colorScheme.remove('\''); // So Foo's does not become FooS QRegExp fixer(QStringLiteral("[\\W,.-]+(.?)")); int offset; while ((offset = fixer.indexIn(colorScheme)) >= 0) { colorScheme.replace(offset, fixer.matchedLength(), fixer.cap(1).toUpper()); } colorScheme.replace(0, 1, colorScheme.at(0).toUpper()); QString src = QStandardPaths::locate(QStandardPaths::GenericDataLocation, "color-schemes/" + colorScheme + ".colors"); setColors(colorScheme, src); } } if (m_applyIcons) { cg = KConfigGroup(conf, "kdeglobals"); cg = KConfigGroup(&cg, "Icons"); setIcons(cg.readEntry("Theme", QString())); } if (m_applyPlasmaTheme) { cg = KConfigGroup(conf, "plasmarc"); cg = KConfigGroup(&cg, "Theme"); setPlasmaTheme(cg.readEntry("name", QString())); } if (m_applyCursors) { cg = KConfigGroup(conf, "kcminputrc"); cg = KConfigGroup(&cg, "Mouse"); setCursorTheme(cg.readEntry("cursorTheme", QString())); } if (m_applyWindowSwitcher) { cg = KConfigGroup(conf, "kwinrc"); cg = KConfigGroup(&cg, "WindowSwitcher"); setWindowSwitcher(cg.readEntry("LayoutName", QString())); } if (m_applyDesktopSwitcher) { cg = KConfigGroup(conf, "kwinrc"); cg = KConfigGroup(&cg, "DesktopSwitcher"); setDesktopSwitcher(cg.readEntry("LayoutName", QString())); } } //TODO: option to enable/disable apply? they don't seem required by UI design setSplashScreen(m_selectedPlugin); setLockScreen(m_selectedPlugin); m_configGroup.sync(); runRdb(KRdbExportQtColors | KRdbExportGtkTheme | KRdbExportColors | KRdbExportQtSettings | KRdbExportXftSettings); }
void TagColorEditor::askGradientChoice() { QString homePath = QDir::homePath(); QFileInfo sfi(homePath, ".drishtigradients.xml"); QString stopsflnm = sfi.absoluteFilePath(); if (!sfi.exists()) copyGradientFile(stopsflnm); QDomDocument document; QFile f(stopsflnm); if (f.open(QIODevice::ReadOnly)) { document.setContent(&f); f.close(); } QStringList glist; QDomElement main = document.documentElement(); QDomNodeList dlist = main.childNodes(); for(int i=0; i<dlist.count(); i++) { if (dlist.at(i).nodeName() == "gradient") { QDomNodeList cnode = dlist.at(i).childNodes(); for(int j=0; j<cnode.count(); j++) { QDomElement dnode = cnode.at(j).toElement(); if (dnode.nodeName() == "name") glist << dnode.text(); } } } bool ok; QString gstr = QInputDialog::getItem(0, "Color Gradient", "Color Gradient", glist, 0, false, &ok); if (!ok) return; int cno = -1; for(int i=0; i<dlist.count(); i++) { if (dlist.at(i).nodeName() == "gradient") { QDomNodeList cnode = dlist.at(i).childNodes(); for(int j=0; j<cnode.count(); j++) { QDomElement dnode = cnode.at(j).toElement(); if (dnode.tagName() == "name" && dnode.text() == gstr) { cno = i; break; } } } } if (cno < 0) return; QGradientStops stops; QDomNodeList cnode = dlist.at(cno).childNodes(); for(int j=0; j<cnode.count(); j++) { QDomElement de = cnode.at(j).toElement(); if (de.tagName() == "gradientstops") { QString str = de.text(); QStringList strlist = str.split(" ", QString::SkipEmptyParts); for(int j=0; j<strlist.count()/5; j++) { float pos, r,g,b,a; pos = strlist[5*j].toFloat(); r = strlist[5*j+1].toInt(); g = strlist[5*j+2].toInt(); b = strlist[5*j+3].toInt(); a = strlist[5*j+4].toInt(); stops << QGradientStop(pos, QColor(r,g,b,a)); } } } int mapSize = QInputDialog::getInt(0, "Number of Colors", "Number of Colors", 50, 2, 255, 1, &ok); if (!ok) mapSize = 50; QGradientStops gstops; gstops = StaticFunctions::resampleGradientStops(stops, mapSize); uchar *colors = Global::tagColors(); for(int i=0; i<gstops.size(); i++) { float pos = gstops[i].first; QColor color = gstops[i].second; int r = color.red(); int g = color.green(); int b = color.blue(); colors[4*i+0] = r; colors[4*i+1] = g; colors[4*i+2] = b; } setColors(); }
void caScriptButton::setForeground(QColor c) { thisForeColor = c; setColors(thisBackColor, thisForeColor, thisHoverColor, thisBorderColor); }
void *MsgViewBase::processEvent(Event *e) { if (e->type() == EventMessageDeleted){ Message *msg = (Message*)(e->param()); if (msg->contact() != m_id) return NULL; for (unsigned i = 0; i < (unsigned)paragraphs(); i++){ QString s = text(i); int n = s.find(MSG_ANCHOR); if (n < 0) continue; s = s.mid(n + strlen(MSG_ANCHOR)); n = s.find("\""); if (n < 0) continue; s = s.left(n); unsigned id = atol(getToken(s, ',').latin1()); if (id != msg->id()) continue; getToken(s, ','); if (s != msg->client()) continue; unsigned j; for (j = i + 1; j < (unsigned)paragraphs(); j++){ QString s = text(j); if (s.find(MSG_ANCHOR) >= 0) break; } int paraFrom, indexFrom; int paraTo, indexTo; getSelection(¶From, &indexFrom, ¶To, &indexTo); setSelection(i, 0, j - 1, 0xFFFF); setReadOnly(false); removeSelectedText(); setReadOnly(true); if ((paraFrom == -1) && (paraTo == -1)){ scrollToBottom(); }else{ setSelection(paraFrom, indexFrom, paraTo, indexTo); } break; } return NULL; } if (e->type() == EventMessageRead){ Message *msg = (Message*)(e->param()); if (msg->contact() != m_id) return NULL; for (unsigned i = 0; i < (unsigned)paragraphs(); i++){ QString s = text(i); int n = s.find(MSG_ANCHOR); if (n < 0) continue; s = s.mid(n + strlen(MSG_ANCHOR)); n = s.find("\""); if (n < 0) continue; s = s.left(n); unsigned id = atol(getToken(s, ',').latin1()); if (id != msg->id()) continue; getToken(s, ','); if (s != msg->client()) continue; int paraFrom, indexFrom; int paraTo, indexTo; getSelection(¶From, &indexFrom, ¶To, &indexTo); setSelection(i, 0, i, 0xFFFF); setBold(false); if ((paraFrom == -1) && (paraTo == -1)){ removeSelection(); scrollToBottom(); }else{ setSelection(paraFrom, indexFrom, paraTo, indexTo); } break; } return NULL; } if (e->type() == EventHistoryConfig){ unsigned id = (unsigned)(e->param()); if (id && (id != m_id)) return NULL; QString t; for (unsigned i = 0; i < (unsigned)paragraphs(); i++){ QString s = text(i); int n = s.find(MSG_ANCHOR); if (n < 0) continue; s = s.mid(n + strlen(MSG_ANCHOR)); n = s.find("\""); if (n < 0) continue; s = s.left(n); unsigned id = atol(getToken(s, ',').latin1()); getToken(s, ','); Message *msg = History::load(id, s.utf8(), m_id); if (msg == NULL) continue; t += messageText(msg, false); delete msg; } QPoint p = QPoint(0, height()); p = mapToGlobal(p); p = viewport()->mapFromGlobal(p); int x, y; viewportToContents(p.x(), p.y(), x, y); int para; int pos = charAt(QPoint(x, y), ¶); setText(t); if (!CorePlugin::m_plugin->getOwnColors()) setBackground(0); if (pos == -1){ scrollToBottom(); }else{ setCursorPosition(para, pos); ensureCursorVisible(); } } if (e->type() == EventHistoryColors) setColors(); if (e->type() == EventCheckState){ CommandDef *cmd = (CommandDef*)(e->param()); if ((cmd->param != this) || (cmd->menu_id != MenuMsgView)) return NULL; Message *msg; switch (cmd->id){ case CmdCopy: cmd->flags &= ~(COMMAND_DISABLED | COMMAND_CHECKED); if (!hasSelectedText()) cmd->flags |= COMMAND_DISABLED; return e->param(); case CmdMsgOpen: msg = currentMessage(); if (msg){ unsigned type = msg->baseType(); delete msg; CommandDef *def = CorePlugin::m_plugin->messageTypes.find(type); if (def == NULL) return NULL; cmd->icon = def->icon; cmd->flags &= ~COMMAND_CHECKED; return e->param(); } return NULL; case CmdMsgSpecial: msg = currentMessage(); if (msg){ Event eMenu(EventGetMenuDef, (void*)MenuMsgCommand); CommandsDef *cmdsMsg = (CommandsDef*)(eMenu.process()); unsigned n = 0; MessageDef *mdef = NULL; if (msg->getFlags() & MESSAGE_RECEIVED){ unsigned type = msg->baseType(); CommandDef *msgCmd = CorePlugin::m_plugin->messageTypes.find(type); if (msgCmd ) mdef = (MessageDef*)(msgCmd->param); } if (mdef && mdef->cmd){ for (const CommandDef *d = mdef->cmd; d->text; d++) n++; } { CommandsList it(*cmdsMsg, true); while (++it) n++; } if (n == 0) return NULL; n++; CommandDef *cmds = new CommandDef[n]; memset(cmds, 0, sizeof(CommandDef) * n); n = 0; if (mdef && mdef->cmd){ for (const CommandDef *d = mdef->cmd; d->text; d++){ cmds[n] = *d; cmds[n].id = CmdMsgSpecial + n; n++; } } CommandDef *c; CommandsList it(*cmdsMsg, true); while ((c = ++it) != NULL){ CommandDef cmd = *c; cmd.menu_id = MenuMsgCommand; cmd.param = msg; Event e(EventCheckState, &cmd); if (!e.process()) continue; cmd.flags &= ~COMMAND_CHECK_STATE; cmds[n++] = cmd; } cmd->param = cmds; cmd->flags |= COMMAND_RECURSIVE; delete msg; return e->param(); } return NULL; } } if (e->type() == EventCommandExec){ CommandDef *cmd = (CommandDef*)(e->param()); if ((cmd->param != this) || (cmd->menu_id != MenuMsgView)) return NULL; Message *msg; switch (cmd->id){ case CmdCopy: copy(); return e->param(); case CmdMsgOpen: msg = currentMessage(); if (msg){ msg->setFlags(msg->getFlags() | MESSAGE_OPEN); Event eOpen(EventOpenMessage, msg); eOpen.process(); delete msg; return e->param(); } return NULL; default: msg = currentMessage(); if (msg){ if (cmd->id >= CmdMsgSpecial){ MessageDef *mdef = NULL; unsigned type = msg->baseType(); CommandDef *msgCmd = CorePlugin::m_plugin->messageTypes.find(type); if (msgCmd) mdef = (MessageDef*)(msgCmd->param); if (mdef && mdef->cmd){ unsigned n = cmd->id - CmdMsgSpecial; for (const CommandDef *d = mdef->cmd; d->text; d++){ if (n-- == 0){ CommandDef cmd = *d; cmd.param = msg; Event eCmd(EventCommandExec, &cmd); eCmd.process(); return e->param(); } } } } Command c; c->id = cmd->id; c->menu_id = MenuMsgCommand; c->param = msg; Event e(EventCommandExec, c); void *res = e.process(); delete msg; return res; } return NULL; } } return NULL; }
void formatedWelcomeMessage(std::string& message, Client& client){ std::ifstream file ( "WelcomeMessage.txt", std::ios::binary | std::ios::in ); std::string stemp, keyword; char ctemp; if( file.fail() ){ file.close(); std::cout << "\t- "; setColors("light red"); std::cout << "error reading WelcomeMessage.txt" << std::endl; setColors("reset"); return; } std::getline(file,stemp,'$'); message = stemp; stemp.erase(); while(std::getline(file,stemp,'$')){ std::istringstream iss (stemp); iss >> ctemp; unsigned int i(0); switch(ctemp){ case '$': message += "$$"; i += 2; break; case '[': i += 3; std::getline(iss,keyword,']'); if(keyword == "user"){ message += client.name(); i += 4; } else if(keyword == "day"){ message += formatedTime().substr(0,3); i += 3; } else if(keyword == "date"){ message += formatedTime().substr(4,8); i += 4; } else if(keyword == "hour"){ message += formatedTime().substr(13,5); i += 4; } else{ message += ("$[" + keyword + "]"); i = static_cast<unsigned short>( i + (keyword.size()) ); } break; default: message += "$"; ++i; break; } i--; stemp.erase(0,i); message += stemp; stemp.erase(); ctemp = 0; } file.close(); }
void Rubik3D::rotate() { for(int x=-isZero(axisX);x<=isZero(axisX);++x) { for(int y=-isZero(axisY);y<=isZero(axisY);++y) { for(int z=-isZero(axisZ);z<=isZero(axisZ);++z) { const int X_from=axisX+x; const int Y_from=axisY+y; const int Z_from=axisZ+z; ; int X_to,Y_to,Z_to; if(twist(axisX, inverse)==1) { X_to = X_from; Y_to = Z_from; Z_to = - Y_from; } else if(twist(axisY, inverse)==1) { X_to = - Z_from; Y_to = Y_from; Z_to = X_from; } else if(twist(axisZ, inverse)==1) { X_to = Y_from; Y_to = - X_from; Z_to = Z_from; }else if(twist(axisX, inverse)==-1) { X_to = X_from; Y_to = - Z_from; Z_to = Y_from; } else if(twist(axisY, inverse)==-1) { X_to = Z_from; Y_to = Y_from; Z_to = - X_from; } else if(twist(axisZ, inverse)==-1) { X_to = - Y_from; Y_to = X_from; Z_to = Z_from; } // swap cube colors if(axisX) { MOVE_TO->left = FROM->Left; MOVE_TO->right = FROM->Right; MOVE_TO->up = MOVE_TO->down = FROM->Front + FROM->Back ; MOVE_TO->front = MOVE_TO->back = FROM->Up + FROM->Down ; } else if(axisY) { MOVE_TO->down = FROM->Down; MOVE_TO->up = FROM->Up; MOVE_TO->left = MOVE_TO->right = FROM->Front + FROM->Back ; MOVE_TO->back = MOVE_TO->front = FROM->Left + FROM->Right ; } else if(axisZ) { MOVE_TO->back = FROM->Back; MOVE_TO->front = FROM->Front; MOVE_TO->right = MOVE_TO->left = FROM->Up + FROM->Down ; MOVE_TO->up = MOVE_TO->down = FROM->Right + FROM->Left ; } } } } setColors(); }
void plSpanInstance::prcParse(const pfPrcTag* tag, const plSpanEncoding& encoding, unsigned int numVerts) { if (tag->getName() != "plSpanInstance") throw pfPrcTagException(__FILE__, __LINE__, tag->getName()); fEncoding = encoding; fNumVerts = numVerts; const pfPrcTag* child = tag->getFirstChild(); while (child != NULL) { if (child->getName() == "Local2World") { std::list<ST::string> contents = child->getContents(); auto iter = contents.begin(); if (*iter++ != "[") throw pfPrcParseException(__FILE__, __LINE__, "L2WMatrix Format error"); fL2W[0][0] = (*iter++).to_float(); if (*iter++ != ",") throw pfPrcParseException(__FILE__, __LINE__, "L2WMatrix Format error"); fL2W[0][1] = (*iter++).to_float(); if (*iter++ != ",") throw pfPrcParseException(__FILE__, __LINE__, "L2WMatrix Format error"); fL2W[0][2] = (*iter++).to_float(); if (*iter++ != ",") throw pfPrcParseException(__FILE__, __LINE__, "L2WMatrix Format error"); fL2W[0][3] = (*iter++).to_float(); if (*iter++ != ";") throw pfPrcParseException(__FILE__, __LINE__, "L2WMatrix Format error"); fL2W[1][0] = (*iter++).to_float(); if (*iter++ != ",") throw pfPrcParseException(__FILE__, __LINE__, "L2WMatrix Format error"); fL2W[1][1] = (*iter++).to_float(); if (*iter++ != ",") throw pfPrcParseException(__FILE__, __LINE__, "L2WMatrix Format error"); fL2W[1][2] = (*iter++).to_float(); if (*iter++ != ",") throw pfPrcParseException(__FILE__, __LINE__, "L2WMatrix Format error"); fL2W[1][3] = (*iter++).to_float(); if (*iter++ != ";") throw pfPrcParseException(__FILE__, __LINE__, "L2WMatrix Format error"); fL2W[2][0] = (*iter++).to_float(); if (*iter++ != ",") throw pfPrcParseException(__FILE__, __LINE__, "L2WMatrix Format error"); fL2W[2][1] = (*iter++).to_float(); if (*iter++ != ",") throw pfPrcParseException(__FILE__, __LINE__, "L2WMatrix Format error"); fL2W[2][2] = (*iter++).to_float(); if (*iter++ != ",") throw pfPrcParseException(__FILE__, __LINE__, "L2WMatrix Format error"); fL2W[2][3] = (*iter++).to_float(); if (*iter++ != "]") throw pfPrcParseException(__FILE__, __LINE__, "L2WMatrix Format error"); } else if (child->getName() == "PosDeltas") { if (child->countChildren() != fNumVerts) throw pfPrcParseException(__FILE__, __LINE__, "Incorrect vertex count"); const pfPrcTag* posChild = child->getFirstChild(); std::vector<hsVector3> verts(fNumVerts); for (size_t i=0; i<fNumVerts; i++) { verts[i].prcParse(posChild); posChild = posChild->getNextSibling(); } setPosDeltas(verts); } else if (child->getName() == "Colors") { if (child->countChildren() != fNumVerts) throw pfPrcParseException(__FILE__, __LINE__, "Incorrect vertex count"); const pfPrcTag* colorChild = child->getFirstChild(); std::vector<unsigned int> colors(fNumVerts); for (size_t i=0; i<fNumVerts; i++) { if (colorChild->getName() != "Color") throw pfPrcTagException(__FILE__, __LINE__, colorChild->getName()); colors[i] = colorChild->getParam("value", "0").to_uint(); colorChild = colorChild->getNextSibling(); } setColors(colors); } else { throw pfPrcTagException(__FILE__, __LINE__, child->getName()); } child = child->getNextSibling(); } }
void caNumeric::setForeground(QColor c) { thisForeColor = c; setColors(thisBackColor, thisForeColor); }
void SearchLineEdit::enterEvent(QEvent * event) { QLineEdit::enterEvent(event); if (m_decoy) { setColors(QColor(0xc8, 0xc8, 0xc8), QColor(0x57, 0x57, 0x57)); } }
void readPoly(double iFrame, MFnMesh & ioMesh, MObject & iParent, PolyMeshAndColors & iNode, bool iInitialized) { Alembic::AbcGeom::IPolyMeshSchema schema = iNode.mMesh.getSchema(); Alembic::AbcGeom::MeshTopologyVariance ttype = schema.getTopologyVariance(); Alembic::AbcCoreAbstract::index_t index, ceilIndex; double alpha = getWeightAndIndex(iFrame, schema.getTimeSampling(), schema.getNumSamples(), index, ceilIndex); MFloatPointArray pointArray; Alembic::Abc::P3fArraySamplePtr ceilPoints; // we can just read the points if (ttype != Alembic::AbcGeom::kHeterogenousTopology && iInitialized) { Alembic::Abc::P3fArraySamplePtr points = schema.getPositionsProperty( ).getValue(Alembic::Abc::ISampleSelector(index)); if (alpha != 0.0) { ceilPoints = schema.getPositionsProperty().getValue( Alembic::Abc::ISampleSelector(ceilIndex) ); } fillPoints(pointArray, points, ceilPoints, alpha); ioMesh.setPoints(pointArray, MSpace::kObject); setColors(iFrame, ioMesh, iNode.mC3s, iNode.mC4s, !iInitialized); if (schema.getNormalsParam().getNumSamples() > 1) { setPolyNormals(iFrame, ioMesh, schema.getNormalsParam()); } if (schema.getUVsParam().getNumSamples() > 1) { setUVs(iFrame, ioMesh, schema.getUVsParam()); } return; } // we need to read the topology Alembic::AbcGeom::IPolyMeshSchema::Sample samp; schema.get(samp, Alembic::Abc::ISampleSelector(index)); if (alpha != 0.0 && ttype != Alembic::AbcGeom::kHeterogenousTopology) { ceilPoints = schema.getPositionsProperty().getValue( Alembic::Abc::ISampleSelector(ceilIndex) ); } fillPoints(pointArray, samp.getPositions(), ceilPoints, alpha); fillTopology(ioMesh, iParent, pointArray, samp.getFaceIndices(), samp.getFaceCounts()); setPolyNormals(iFrame, ioMesh, schema.getNormalsParam()); setUVs(iFrame, ioMesh, schema.getUVsParam()); setColors(iFrame, ioMesh, iNode.mC3s, iNode.mC4s, !iInitialized); }
void SearchLineEdit::leaveEvent(QEvent * event) { QLineEdit::leaveEvent(event); if (m_decoy) { setColors(QColor(0xb3, 0xb3, 0xb3), QColor(0x57, 0x57, 0x57)); } }
MObject createSubD(double iFrame, SubDAndColors & iNode, MObject & iParent) { Alembic::AbcGeom::ISubDSchema schema = iNode.mMesh.getSchema(); Alembic::AbcCoreAbstract::index_t index, ceilIndex; getWeightAndIndex(iFrame, schema.getTimeSampling(), schema.getNumSamples(), index, ceilIndex); Alembic::AbcGeom::ISubDSchema::Sample samp; schema.get(samp, Alembic::Abc::ISampleSelector(index)); MString name(iNode.mMesh.getName().c_str()); MFnMesh fnMesh; MFloatPointArray pointArray; Alembic::Abc::P3fArraySamplePtr emptyPtr; fillPoints(pointArray, samp.getPositions(), emptyPtr, 0.0); fillTopology(fnMesh, iParent, pointArray, samp.getFaceIndices(), samp.getFaceCounts()); fnMesh.setName(iNode.mMesh.getName().c_str()); setInitialShadingGroup(fnMesh.partialPathName()); MObject obj = fnMesh.object(); setUVs(iFrame, fnMesh, schema.getUVsParam()); setColors(iFrame, fnMesh, iNode.mC3s, iNode.mC4s, true); // add the mFn-specific attributes to fnMesh node MFnNumericAttribute numAttr; MString attrName("SubDivisionMesh"); MObject attrObj = numAttr.create(attrName, attrName, MFnNumericData::kBoolean, 1); numAttr.setKeyable(true); numAttr.setHidden(false); fnMesh.addAttribute(attrObj, MFnDependencyNode::kLocalDynamicAttr); if (samp.getInterpolateBoundary() > 0) { attrName = MString("interpolateBoundary"); attrObj = numAttr.create(attrName, attrName, MFnNumericData::kBoolean, samp.getInterpolateBoundary()); numAttr.setKeyable(true); numAttr.setHidden(false); fnMesh.addAttribute(attrObj, MFnDependencyNode::kLocalDynamicAttr); } if (samp.getFaceVaryingInterpolateBoundary() > 0) { attrName = MString("faceVaryingInterpolateBoundary"); attrObj = numAttr.create(attrName, attrName, MFnNumericData::kBoolean, samp.getFaceVaryingInterpolateBoundary()); numAttr.setKeyable(true); numAttr.setHidden(false); fnMesh.addAttribute(attrObj, MFnDependencyNode::kLocalDynamicAttr); } if (samp.getFaceVaryingPropagateCorners() > 0) { attrName = MString("faceVaryingPropagateCorners"); attrObj = numAttr.create(attrName, attrName, MFnNumericData::kBoolean, samp.getFaceVaryingPropagateCorners()); numAttr.setKeyable(true); numAttr.setHidden(false); fnMesh.addAttribute(attrObj, MFnDependencyNode::kLocalDynamicAttr); } #if MAYA_API_VERSION >= 201100 Alembic::Abc::Int32ArraySamplePtr holes = samp.getHoles(); if (holes && !holes->size() == 0) { unsigned int numHoles = (unsigned int)holes->size(); MUintArray holeData(numHoles); for (unsigned int i = 0; i < numHoles; ++i) { holeData[i] = (*holes)[i]; } if (fnMesh.setInvisibleFaces(holeData) != MS::kSuccess) { MString warn = "Failed to set holes on: "; warn += iNode.mMesh.getName().c_str(); printWarning(warn); } } #endif Alembic::Abc::FloatArraySamplePtr creases = samp.getCreaseSharpnesses(); if (creases && !creases->size() == 0) { Alembic::Abc::Int32ArraySamplePtr indices = samp.getCreaseIndices(); Alembic::Abc::Int32ArraySamplePtr lengths = samp.getCreaseLengths(); std::size_t numLengths = lengths->size(); MUintArray edgeIds; MDoubleArray creaseData; std::size_t curIndex = 0; // curIndex incremented here to move on to the next crease length for (std::size_t i = 0; i < numLengths; ++i, ++curIndex) { std::size_t len = (*lengths)[i] - 1; float creaseSharpness = (*creases)[i]; // curIndex incremented here to go between all the edges that make // up a given length for (std::size_t j = 0; j < len; ++j, ++curIndex) { Alembic::Util::int32_t vertA = (*indices)[curIndex]; Alembic::Util::int32_t vertB = (*indices)[curIndex+1]; MItMeshVertex itv(obj); int prev; itv.setIndex(vertA, prev); MIntArray edges; itv.getConnectedEdges(edges); std::size_t numEdges = edges.length(); for (unsigned int k = 0; k < numEdges; ++k) { int oppVert = -1; itv.getOppositeVertex(oppVert, edges[k]); if (oppVert == vertB) { creaseData.append(creaseSharpness); edgeIds.append(edges[k]); break; } } } } if (fnMesh.setCreaseEdges(edgeIds, creaseData) != MS::kSuccess) { MString warn = "Failed to set creases on: "; warn += iNode.mMesh.getName().c_str(); printWarning(warn); } } Alembic::Abc::FloatArraySamplePtr corners = samp.getCornerSharpnesses(); if (corners && !corners->size() == 0) { Alembic::Abc::Int32ArraySamplePtr cornerVerts = samp.getCornerIndices(); unsigned int numCorners = static_cast<unsigned int>(corners->size()); MUintArray vertIds(numCorners); MDoubleArray cornerData(numCorners); for (unsigned int i = 0; i < numCorners; ++i) { cornerData[i] = (*corners)[i]; vertIds[i] = (*cornerVerts)[i]; } if (fnMesh.setCreaseVertices(vertIds, cornerData) != MS::kSuccess) { MString warn = "Failed to set corners on: "; warn += iNode.mMesh.getName().c_str(); printWarning(warn); } } return obj; }
int main(int nargin, char** argv){ if(nargin != 5){ printf("Usage: p5 <input gradient> <seed point> <mask> <output depth>"); return -1; } int index, i,j; mask = (Image*) malloc(sizeof(Image)); readImage(mask, argv[3]); FILE* file = fopen(argv[1], "rb"); FILE* seeds = fopen(argv[2], "r"); Gradient* grid = (Gradient*) malloc(sizeof(Gradient)*getNRows(mask)*getNCols(mask)); fread(grid, getNRows(mask)*getNCols(mask), sizeof(Gradient), file); double** points = (double**) malloc(sizeof(double)*getNRows(mask)); for(i = 0; i < getNRows(mask); i++) points[i] = (double*)malloc(sizeof(double)*getNCols(mask)); double* allpoints = (double*) malloc(sizeof(double)*getNRows(mask)*getNCols(mask)); char line[1024]; int r = getNRows(mask), c = getNCols(mask); int max = 0; while(fgets(line, 1024, seeds) != NULL){ int x0 = atoi(strtok(line, " ")); int y0 = atoi(strtok(NULL, " ")); for(i = 0; i < getNRows(mask); i++) for(j = 0; j < getNCols(mask); j++) points[i][j] = 0; int x, y; for(x = x0-1; x >=0; x--) points[x][y0] = (points[x+1][y0] + (grid+x*r+y0)->p); for(x = x0+1; x < r; x++) points[x][y0] = (points[x-1][y0] - (grid+x*r+y0)->p); for(y = y0-1; y >=0; y--) points[x0][y] = (points[x0][y+1] + (grid+x0*r+y)->q); for(y = y0+1; y < r; y++) points[x0][y] = (points[x0][y-1] - (grid+x0*r+y)->q); for(x = x0-1; x >=0; x--){ for(y = y0-1; y >=0; y--) points[x][y] = (0.5 * points[x][y+1] + (grid+x*r+y)->q + 0.5 * points[x+1][y] + (grid+x*r+y)->p); for(y = y0+1; y < r; y++) points[x][y] = (0.5 * points[x][y-1] - (grid+x*r+y)->q + 0.5 * points[x+1][y] + (grid+x*r+y)->p); } for(x = x0+1; x < r; x++){ for(y = y0-1; y >=0; y--) points[x][y] = (0.5 * points[x][y+1] + (grid+x*r+y)->q + 0.5 * points[x-1][y] - (grid+x*r+y)->p); for(y = y0+1; y < r; y++) points[x][y] = (0.5 * points[x][y-1] - (grid+x*r+y)->q + 0.5 * points[x-1][y] - (grid+x*r+y)->p); } for(x = 0; x < r; x++) for(y = 0; y < r; y++){ allpoints[x*r+y] += points[x][y]; max = (allpoints[x*r+y] > max) ? allpoints[x*r+y] : max; } } Image* im = (Image*) malloc(sizeof(Image)); setSize(im, r, c); setColors(im, 255); int x,y; for(x = 0; x < r; x++) for(y = 0; y < c; y++) setPixel(im, x, y, getPixel(mask,x,y) ? allpoints[x*r+y] / (double) max * 255 : 0); writeImage(im, argv[4]); }
SwitchButton::SwitchButton(QWidget* parent) : QPushButton(parent) { setCheckable(true); // Set default colors and labels setColors(); setLabels(); }
SyntaxHighlighter::SyntaxHighlighter(QTextDocument *parent) : QSyntaxHighlighter(parent) { setColors(); buildRules(); }
void caMessageButton::setForeground(QColor c) { thisForeColor = c; setColors(thisBackColor, thisForeColor, thisHoverColor, thisBorderColor, thisDisabledForeColor); }
void CThemes::saveFile(char * themename) { setColors(themefile); if (!themefile.saveConfig(themename)) printf("[neutrino theme] %s write error\n", themename); }