void CDialogHolder::AddDialogToRender(CUIWindow* pDialog) { dlgItem itm(pDialog); xr_vector<dlgItem>::iterator it = std::find(m_dialogsToRender.begin(),m_dialogsToRender.end(),itm); if( (it == m_dialogsToRender.end()) || ( it != m_dialogsToRender.end() && (*it).enabled==false) ) { m_dialogsToRender.push_back(itm); pDialog->Show(true); } }
void MainWindow::RefreshProductFeatureDropdownContent(int SelectedProductIndex) { int DropdownIndex = 0; //populate the dropdown with product names ProjectFeatureKeyDB *ProjectFeatureDropdownList; ProjectFeatureDropdownList = new ProjectFeatureKeyDB; if(ProjectFeatureDropdownList!=NULL) { //do we need to clear the current content int HasContent = ui->CB_ProductIdPicker->count(); //add new content int SelectedProductId = -1; std::set<int> UniqueProducts; for (ProjectFeatureKeyStore *itr = ProjectFeatureDropdownList->ListStart(); itr != NULL; itr = ProjectFeatureDropdownList->ListNext()) { if(DropdownIndex == SelectedProductIndex) SelectedProductId = itr->ProjectID; if(UniqueProducts.find(itr->ProjectID)==UniqueProducts.end()) { UniqueProducts.insert(itr->ProjectID); DropdownIndex++; if(HasContent == 0) { QString itm( itr->ProjectName ); ui->CB_ProductIdPicker->addItem( itm ); } } } //populate feature list based on first product ui->CB_FeatureIdPicker->clear(); if(SelectedProductId!=-1) { for (ProjectFeatureKeyStore *itr = ProjectFeatureDropdownList->ListStart(); itr != NULL; itr = ProjectFeatureDropdownList->ListNext()) if(itr->ProjectID == SelectedProductId) { QString itm( itr->FeatureName ); ui->CB_FeatureIdPicker->addItem( itm ); } } } }
void CDialogHolder::RemoveDialogToRender(CUIWindow* pDialog) { dlgItem itm(pDialog); xr_vector<dlgItem>::iterator it = std::find(m_dialogsToRender.begin(),m_dialogsToRender.end(),itm); if(it != m_dialogsToRender.end()) { (*it).wnd->Show(false); (*it).wnd->Enable(false); (*it).enabled = false; } }
void CUIArtefactDetectorElite::RegisterItemToDraw(const Fvector& p, const shared_str& palette_idx) { xr_map<shared_str,CUIStatic*>::iterator it = m_palette.find(palette_idx); if(it==m_palette.end()) { Msg("! RegisterItemToDraw. static not found for [%s]", palette_idx.c_str()); return; } CUIStatic* S = m_palette[palette_idx]; SDrawOneItem itm(S, p); m_items_to_draw.push_back (itm); }
void cSpawnScripted::removeObject( pItem pi ) { SPAWNAREA_VECTOR::iterator iter( this->singles.begin() ), end( this->singles.end() ); for( ; iter!=end; iter++ ) { uint32_set::iterator itm( (*iter).items_spawned.find( pi->getSerial() ) ); if( itm!=(*iter).items_spawned.end() ) { (*iter).items_spawned.erase( itm ); if( (*iter).current>0 ) (*iter).current--; return; } } }
//! Redraw grid, curves, and markers. The draw code // does not clear clipRegion prior to painting. // \param p painter used for drawing void QwtPlot::drawCanvas(QPainter *p) { QwtDiMap map[axisCnt]; for ( int axis = 0; axis < axisCnt; axis++ ) map[axis] = canvasMap(axis); QRect rect = d_canvas->contentsRect(); // // draw grid // if ( d_grid.enabled() && axisEnabled( d_grid.xAxis() ) && axisEnabled( d_grid.yAxis() ) ) { d_grid.draw(p, rect, map[d_grid.xAxis()], map[d_grid.yAxis()]); } // // draw curves // QIntDictIterator<QwtPlotCurve> itc(*d_curves); for (QwtPlotCurve *curve = itc.toFirst(); curve != 0; curve = ++itc ) { if ( curve->enabled() && axisEnabled( curve->xAxis() ) && axisEnabled( curve->yAxis() ) ) { curve->draw(p, map[curve->xAxis()], map[curve->yAxis()]); } } // // draw markers // QIntDictIterator<QwtPlotMarker> itm(*d_markers); for (QwtPlotMarker *marker = itm.toFirst(); marker != 0; marker = ++itm ) { if ( marker->enabled() && axisEnabled( marker->xAxis() ) && axisEnabled( marker->yAxis() ) ) { marker->draw(p, map[marker->xAxis()].transform(marker->xValue()), map[marker->yAxis()].transform(marker->yValue()), rect); } } }
void SdDurationCanvas::propag_visible(Q3PtrList<SdDurationCanvas> & l, bool y) { Q3PtrListIterator<SdDurationCanvas> itd(l); SdDurationCanvas * d; for ( ; (d = itd.current()) != 0; ++itd ) { d->Q3CanvasItem::setVisible(y); Q3PtrListIterator<SdMsgBaseCanvas> itm(d->msgs); for ( ; itm.current(); ++itm ) itm.current()->Q3CanvasItem::setVisible(y); propag_visible(d->durations, y); } }
void State::throw_on_illegal_move(const PlayerMove& pm, boost::unordered_map<Player, boost::unordered_set<Move> >& legals) const { typedef boost::unordered_map<Player, boost::unordered_set<Move> > tmp_t; const Player& p = pm.first; const Move& m = pm.second; tmp_t::const_iterator itp(legals.find(p)); if (itp == legals.end()) { throw HSFCValueError() << ErrorMsgInfo("Illegal PlayerMove: unknown player"); } boost::unordered_set<Move>::const_iterator itm(itp->second.find(m)); if (itm == itp->second.end()) { throw HSFCValueError() << ErrorMsgInfo("Illegal PlayerMove: unknown move"); } }
unsigned SdDurationCanvas::count_msg(int api_format) const { unsigned count = 0; Q3PtrListIterator<SdMsgBaseCanvas> itm(msgs); double maxy = 0; bool isreturn = FALSE; for (; itm.current(); ++itm) { switch (itm.current()->type()) { case UmlSyncMsg: case UmlAsyncMsg: case UmlReturnMsg: if (itm.current()->get_dest() == (const SdMsgSupport *) this) break; // no break default: // msg starts from duration or duration ends a found msg count += 1; } if (itm.current()->y() > maxy) { maxy = itm.current()->y(); switch (itm.current()->type()) { case UmlReturnMsg: case UmlSelfReturnMsg: isreturn = TRUE; break; default: isreturn = FALSE; } } } if (!isreturn) count += 1; Q3PtrListIterator<SdDurationCanvas> itd(durations); for (; itd.current(); ++itd) count += itd.current()->count_msg(api_format); return count; }
Pnode Confinement::item(Pnode ts) { Token tok = ts->tok(); Pnode cnst(new Cnst(tok, ts, Cnst::eTsnum)); Pnode term(new Term(tok, cnst, Term::eCnst)); Expr * r_expr = new Expr(tok); r_expr->typ = Expr::eTerm; r_expr->addChild(term); Pnode expr(r_expr); Item * r_item = new Item(tok); r_item->typ = Item::eExpr; r_item->addChild(expr); Pnode itm(r_item); return itm; }
void SdDurationCanvas::send(ToolCom * com, int id) const { Q3PtrListIterator<SdMsgBaseCanvas> itm(msgs); double maxy = 0; bool isreturn = FALSE; for (; itm.current(); ++itm) { switch (itm.current()->type()) { case UmlSyncMsg: case UmlAsyncMsg: case UmlReturnMsg: if (itm.current()->get_dest() == (const SdMsgSupport *) this) break; // no break default: // msg start from duration, except for found msg itm.current()->send(com, id); } if (itm.current()->y() > maxy) { maxy = itm.current()->y(); switch (itm.current()->type()) { case UmlReturnMsg: case UmlSelfReturnMsg: isreturn = TRUE; break; default: isreturn = FALSE; } } } if (!isreturn) SdMsgBaseCanvas::send(com, id, (unsigned) x() + width(), (unsigned) y() + height(), anImplicitReturn, "", "", ""); Q3PtrListIterator<SdDurationCanvas> itd(durations); for (; itd.current(); ++itd) itd.current()->send(com, id); }
Menu * Menu::subMenu(PGM_P key_str, PGM_P help_str) { #ifdef SUI_DYNAMIC_MEMORY_ALLOCATION_ENABLE // dynamic memory is enabled, so we malloc a pointer to fresh // memory, and keep a reference to this block within the // MenuItem: Menu * sub_men = (Menu*) malloc(sizeof(Menu)); #else // we'll just use the next available sub-menu slot if (submenu_static_idx >= SUI_STATIC_MEMORY_NUM_SUBMENUS_TOTAL_MAXIMUM) return NULL; Menu * sub_men = &(submenu_staticlist[submenu_static_idx]); submenu_static_idx++; #endif if (!sub_men) { SUI_MENU_DEBUG_OUTPUT("Submenu creation fail"); #ifdef SUI_SERIALUI_ECHO_WARNINGS returnMessage(error_cantalloc_submenu); #endif return NULL; } sub_men->init(sui_driver, key_str, 0, this); MenuItem itm(key_str, help_str, sub_men, NULL); if (!addMenuItem(&itm)) { MENUFREE(sub_men); return NULL; } #ifdef SUI_INCLUDE_DEBUG SUI_MENU_DEBUG_OUTPUT("Added submenu"); sui_driver->showFreeRAM(); #endif return sub_men; }
bool Menu::addCommand(PGM_P key_str, MenuCommand_Callback callback, PGM_P help_str) { MenuItem itm(key_str, help_str, NULL, callback); #ifdef SUI_INCLUDE_EXTRA_SAFETYCHECKS if (itm.key_size > SUI_MENU_PROGMEM_STRING_ABS_MAXLEN) { returnMessage(PSTR(SUI_ERRORMSG_MENUITEM_KEY_TOOLONG)); } if (help_str && strlen_P(help_str) > SUI_MENU_PROGMEM_STRING_ABS_MAXLEN) { sui_driver->println_P(help_str); returnMessage(PSTR(SUI_ERRORMSG_MENUITEM_HELP_TOOLONG)); } #endif return addMenuItem(&itm); }
void idCollisionModelManagerLocal::DebugOutput( const idVec3& origin ) { int i, k, t; char buf[128]; idVec3 end; idAngles boxAngles; idMat3 modelAxis, boxAxis; idBounds bounds; trace_t trace; if( !cm_testCollision.GetBool() ) { return; } testend = ( idVec3* ) Mem_Alloc( cm_testTimes.GetInteger() * sizeof( idVec3 ), TAG_COLLISION ); if( cm_testReset.GetBool() || ( cm_testWalk.GetBool() && !start.Compare( start ) ) ) { total_translation = total_rotation = 0; min_translation = min_rotation = 999999; max_translation = max_rotation = -999999; num_translation = num_rotation = 0; cm_testReset.SetBool( false ); } if( cm_testWalk.GetBool() ) { start = origin; cm_testOrigin.SetString( va( "%1.2f %1.2f %1.2f", start[0], start[1], start[2] ) ); } else { sscanf( cm_testOrigin.GetString(), "%f %f %f", &start[0], &start[1], &start[2] ); } sscanf( cm_testBox.GetString(), "%f %f %f %f %f %f", &bounds[0][0], &bounds[0][1], &bounds[0][2], &bounds[1][0], &bounds[1][1], &bounds[1][2] ); sscanf( cm_testBoxRotation.GetString(), "%f %f %f", &boxAngles[0], &boxAngles[1], &boxAngles[2] ); boxAxis = boxAngles.ToMat3(); modelAxis.Identity(); idTraceModel itm( bounds ); idRandom random( 0 ); idTimer timer; if( cm_testRandomMany.GetBool() ) { // if many traces in one random direction for( i = 0; i < 3; i++ ) { testend[0][i] = start[i] + random.CRandomFloat() * cm_testLength.GetFloat(); } for( k = 1; k < cm_testTimes.GetInteger(); k++ ) { testend[k] = testend[0]; } } else { // many traces each in a different random direction for( k = 0; k < cm_testTimes.GetInteger(); k++ ) { for( i = 0; i < 3; i++ ) { testend[k][i] = start[i] + random.CRandomFloat() * cm_testLength.GetFloat(); } } } // translational collision detection timer.Clear(); timer.Start(); for( i = 0; i < cm_testTimes.GetInteger(); i++ ) { Translation( &trace, start, testend[i], &itm, boxAxis, CONTENTS_SOLID | CONTENTS_PLAYERCLIP, cm_testModel.GetInteger(), vec3_origin, modelAxis ); } timer.Stop(); t = timer.Milliseconds(); if( t < min_translation ) min_translation = t; if( t > max_translation ) max_translation = t; num_translation++; total_translation += t; if( cm_testTimes.GetInteger() > 9999 ) { sprintf( buf, "%3dK", ( int )( cm_testTimes.GetInteger() / 1000 ) ); } else { sprintf( buf, "%4d", cm_testTimes.GetInteger() ); } common->Printf( "%s translations: %4d milliseconds, (min = %d, max = %d, av = %1.1f)\n", buf, t, min_translation, max_translation, ( float ) total_translation / num_translation ); if( cm_testRandomMany.GetBool() ) { // if many traces in one random direction for( i = 0; i < 3; i++ ) { testend[0][i] = start[i] + random.CRandomFloat() * cm_testRadius.GetFloat(); } for( k = 1; k < cm_testTimes.GetInteger(); k++ ) { testend[k] = testend[0]; } } else { // many traces each in a different random direction for( k = 0; k < cm_testTimes.GetInteger(); k++ ) { for( i = 0; i < 3; i++ ) { testend[k][i] = start[i] + random.CRandomFloat() * cm_testRadius.GetFloat(); } } } if( cm_testRotation.GetBool() ) { // rotational collision detection idVec3 vec( random.CRandomFloat(), random.CRandomFloat(), random.RandomFloat() ); vec.Normalize(); idRotation rotation( vec3_origin, vec, cm_testAngle.GetFloat() ); timer.Clear(); timer.Start(); for( i = 0; i < cm_testTimes.GetInteger(); i++ ) { rotation.SetOrigin( testend[i] ); Rotation( &trace, start, rotation, &itm, boxAxis, CONTENTS_SOLID | CONTENTS_PLAYERCLIP, cm_testModel.GetInteger(), vec3_origin, modelAxis ); } timer.Stop(); t = timer.Milliseconds(); if( t < min_rotation ) min_rotation = t; if( t > max_rotation ) max_rotation = t; num_rotation++; total_rotation += t; if( cm_testTimes.GetInteger() > 9999 ) { sprintf( buf, "%3dK", ( int )( cm_testTimes.GetInteger() / 1000 ) ); } else { sprintf( buf, "%4d", cm_testTimes.GetInteger() ); } common->Printf( "%s rotation: %4d milliseconds, (min = %d, max = %d, av = %1.1f)\n", buf, t, min_rotation, max_rotation, ( float ) total_rotation / num_rotation ); } Mem_Free( testend ); testend = NULL; }
/*! Reset color and fonts of a plot \sa QwtPlotPrintFilter::apply */ void QwtPlotPrintFilter::reset(QwtPlot *plot) const { if ( d_cache == 0 ) return; QFont *font; QColor *color; if ( plot->d_lblTitle ) { QPalette palette = plot->d_lblTitle->palette(); palette.setColor( QPalette::Active, QColorGroup::Foreground, d_cache->titleColor); plot->d_lblTitle->setPalette(palette); plot->d_lblTitle->setFont(d_cache->titleFont); } if ( plot->d_legend ) { QIntDictIterator<QWidget> it = plot->d_legend->itemIterator(); for ( QWidget *w = it.toFirst(); w != 0; w = ++it) { const int key = it.currentKey(); font = d_cache->legendFonts.find(key); if ( font ) w->setFont(*font); if ( w->inherits("QwtLegendButton") ) { QwtLegendButton *btn = (QwtLegendButton *)w; QwtSymbol symbol = btn->symbol(); color = d_cache->curveSymbolPenColors.find(key); if ( color ) { QPen pen = symbol.pen(); pen.setColor(*color); symbol.setPen(pen); } color = d_cache->curveSymbolBrushColors.find(key); if ( color ) { QBrush brush = symbol.brush(); brush.setColor(*color); symbol.setBrush(brush); } btn->setSymbol(symbol); color = d_cache->curveColors.find(key); if ( color ) { QPen pen = btn->curvePen(); pen.setColor(*color); btn->setCurvePen(pen); } } } } for ( int axis = 0; axis < QwtPlot::axisCnt; axis++ ) { QwtScale *scale = plot->d_scale[axis]; if ( scale ) { QPalette palette = scale->palette(); palette.setColor(QPalette::Active, QColorGroup::Foreground, d_cache->scaleColor[axis]); scale->setPalette(palette); scale->setFont(d_cache->scaleFont[axis]); scale->setTitleColor(d_cache->scaleTitleColor[axis]); scale->setTitleFont(d_cache->scaleTitleFont[axis]); int startDist, endDist; scale->minBorderDist(startDist, endDist); scale->setBorderDist(startDist, endDist); } } plot->setBackgroundColor(d_cache->widgetBackground); plot->setCanvasBackground(d_cache->canvasBackground); QPen pen = plot->d_grid->majPen(); pen.setColor(d_cache->gridColors[0]); plot->d_grid->setMajPen(pen); pen = plot->d_grid->minPen(); pen.setColor(d_cache->gridColors[1]); plot->d_grid->setMinPen(pen); QIntDictIterator<QwtPlotCurve> itc(*plot->d_curves); for (QwtPlotCurve *c = itc.toFirst(); c != 0; c = ++itc ) { const int key = itc.currentKey(); QwtSymbol symbol = c->symbol(); color = d_cache->curveSymbolPenColors.find(key); if ( color ) { QPen pen = symbol.pen(); pen.setColor(*color); symbol.setPen(pen); } color = d_cache->curveSymbolBrushColors.find(key); if ( color ) { QBrush brush = symbol.brush(); brush.setColor(*color); symbol.setBrush(brush); } c->setSymbol(symbol); color = d_cache->curveColors.find(key); if ( color ) { QPen pen = c->pen(); pen.setColor(*color); c->setPen(pen); } } QIntDictIterator<QwtPlotMarker> itm(*plot->d_markers); for (QwtPlotMarker *m = itm.toFirst(); m != 0; m = ++itm ) { const int key = itm.currentKey(); font = d_cache->markerFonts.find(key); if ( font ) m->setFont(*font); color = d_cache->markerLabelColors.find(key); if ( color ) { QPen pen = m->labelPen(); pen.setColor(*color); m->setLabelPen(pen); } color = d_cache->markerLineColors.find(key); if ( color ) { QPen pen = m->linePen(); pen.setColor(*color); m->setLinePen(pen); } QwtSymbol symbol = m->symbol(); color = d_cache->markerSymbolPenColors.find(key); if ( color ) { QPen pen = symbol.pen(); pen.setColor(*color); symbol.setPen(pen); } color = d_cache->markerSymbolBrushColors.find(key); if ( color ) { QBrush brush = symbol.brush(); brush.setColor(*color); symbol.setBrush(brush); } m->setSymbol(symbol); } QwtPlotPrintFilter *that = (QwtPlotPrintFilter *)this; delete that->d_cache; that->d_cache = 0; }
/*! Change color and fonts of a plot \sa QwtPlotPrintFilter::apply */ void QwtPlotPrintFilter::apply(QwtPlot *plot) const { QwtPlotPrintFilter *that = (QwtPlotPrintFilter *)this; delete that->d_cache; that->d_cache = new QwtPlotPrintFilterCache; QwtPlotPrintFilterCache &cache = *that->d_cache; if ( plot->d_lblTitle ) { QPalette palette = plot->d_lblTitle->palette(); cache.titleColor = palette.color( QPalette::Active, QColorGroup::Foreground); palette.setColor(QPalette::Active, QColorGroup::Foreground, color(cache.titleColor, Title)); plot->d_lblTitle->setPalette(palette); cache.titleFont = plot->d_lblTitle->font(); plot->d_lblTitle->setFont(font(cache.titleFont, Title)); } if ( plot->d_legend ) { QIntDictIterator<QWidget> it = plot->d_legend->itemIterator(); for ( QWidget *w = it.toFirst(); w != 0; w = ++it) { const int key = it.currentKey(); cache.legendFonts.insert(it.currentKey(), new QFont(w->font())); w->setFont(font(w->font(), Legend, key)); if ( w->inherits("QwtLegendButton") ) { QwtLegendButton *btn = (QwtLegendButton *)w; QwtSymbol symbol = btn->symbol(); QPen pen = symbol.pen(); QBrush brush = symbol.brush(); pen.setColor(color(pen.color(), CurveSymbol, key)); brush.setColor(color(brush.color(), CurveSymbol, key)); symbol.setPen(pen); symbol.setBrush(brush); btn->setSymbol(symbol); pen = btn->curvePen(); pen.setColor(color(pen.color(), Curve, key)); btn->setCurvePen(pen); } } } for ( int axis = 0; axis < QwtPlot::axisCnt; axis++ ) { QwtScale *scale = plot->d_scale[axis]; if ( scale ) { cache.scaleColor[axis] = scale->palette().color( QPalette::Active, QColorGroup::Foreground); QPalette palette = scale->palette(); palette.setColor(QPalette::Active, QColorGroup::Foreground, color(cache.scaleColor[axis], AxisScale, axis)); scale->setPalette(palette); cache.scaleFont[axis] = scale->font(); scale->setFont(font(cache.scaleFont[axis], AxisScale, axis)); cache.scaleTitleColor[axis] = scale->titleColor(); scale->setTitleColor( color(cache.scaleTitleColor[axis], AxisTitle, axis)); cache.scaleTitleFont[axis] = scale->titleFont(); scale->setTitleFont( font(cache.scaleTitleFont[axis], AxisTitle, axis)); int startDist, endDist; scale->minBorderDist(startDist, endDist); scale->setBorderDist(startDist, endDist); } } cache.widgetBackground = plot->backgroundColor(); plot->setBackgroundColor(color(cache.widgetBackground, WidgetBackground)); cache.canvasBackground = plot->canvasBackground(); plot->setCanvasBackground(color(cache.canvasBackground, CanvasBackground)); QPen pen = plot->d_grid->majPen(); cache.gridColors[0] = pen.color(); pen.setColor(color(pen.color(), MajorGrid)); plot->d_grid->setMajPen(pen); pen = plot->d_grid->minPen(); cache.gridColors[1] = pen.color(); pen.setColor(color(pen.color(), MinorGrid)); plot->d_grid->setMinPen(pen); QIntDictIterator<QwtPlotCurve> itc(*plot->d_curves); for (QwtPlotCurve *c = itc.toFirst(); c != 0; c = ++itc ) { const int key = itc.currentKey(); QwtSymbol symbol = c->symbol(); QPen pen = symbol.pen(); cache.curveSymbolPenColors.insert(key, new QColor(pen.color())); pen.setColor(color(pen.color(), CurveSymbol, key)); symbol.setPen(pen); QBrush brush = symbol.brush(); cache.curveSymbolBrushColors.insert(key, new QColor(brush.color())); brush.setColor(color(brush.color(), CurveSymbol, key)); symbol.setBrush(brush); c->setSymbol(symbol); pen = c->pen(); cache.curveColors.insert(key, new QColor(pen.color())); pen.setColor(color(pen.color(), Curve, key)); c->setPen(pen); } QIntDictIterator<QwtPlotMarker> itm(*plot->d_markers); for (QwtPlotMarker *m = itm.toFirst(); m != 0; m = ++itm ) { const int key = itm.currentKey(); cache.markerFonts.insert(key, new QFont(m->font())); m->setFont(font(m->font(), Marker, key)); QPen pen = m->labelPen(); cache.markerLabelColors.insert(key, new QColor(pen.color())); pen.setColor(color(pen.color(), Marker, key)); m->setLabelPen(pen); pen = m->linePen(); cache.markerLineColors.insert(key, new QColor(pen.color())); pen.setColor(color(pen.color(), Marker, key)); m->setLinePen(pen); QwtSymbol symbol = m->symbol(); pen = symbol.pen(); cache.markerSymbolPenColors.insert(key, new QColor(pen.color())); pen.setColor(color(pen.color(), MarkerSymbol, key)); symbol.setPen(pen); QBrush brush = symbol.brush(); cache.markerSymbolBrushColors.insert(key, new QColor(brush.color())); brush.setColor(color(brush.color(), MarkerSymbol, key)); symbol.setBrush(brush); m->setSymbol(symbol); } }