/* Called when a DrawingArea has input (either mouse or keyboard). */ static void _do_input(Widget w, void *data, XADCS *call_data) { char *input; DrawInfo *di = (DrawInfo *) data; SetDrawArea(w); if (call_data->event->type == ButtonPress) { if (di->button_down) di->button_down(w, call_data->event->xbutton.button, call_data->event->xbutton.x,call_data->event->xbutton.y, di->user_data); } else if (call_data->event->type == ButtonRelease) { if (di->button_up) di->button_up(w, call_data->event->xbutton.button, call_data->event->xbutton.x, call_data->event->xbutton.y, di->user_data); } else if (call_data->event->type == KeyPress) { input = TranslateKeyCode(call_data->event); if (input && *input != '\0' && di->keypress) di->keypress(w, input, 0, di->user_data); } else if (call_data->event->type == KeyRelease) { input = TranslateKeyCode(call_data->event); if (input && *input != '\0' && di->keypress) di->keypress(w, input, 1, di->user_data); } }
wxString DrawsWidget::GetUrl(bool with_infinity) { Draw* d = m_draws_controller->GetSelectedDraw(); if (d == NULL) return wxEmptyString; time_t t; if (with_infinity && m_draws_controller->AtTheNewestValue()) { t = std::numeric_limits<time_t>::max(); } else { t = GetCurrentTime().GetTicks(); } wxString prefix = m_draws_controller->GetSet()->GetDrawsSets()->GetPrefix(); DrawInfo* di = d->GetDrawInfo(); SetInfoDataObject* wido = new SetInfoDataObject(prefix, di->GetSetName(), d->GetPeriod(), t , d->GetDrawNo()); wxString tmp = wido->GetUrl(); delete wido; return tmp; }
void RemarksFetcher::RemarksReceived(std::vector<Remark>& remarks) { Draw* d = m_draws_controller->GetSelectedDraw(); if (d == NULL) return; DrawInfo* di = d->GetDrawInfo(); wxDateTime start = d->GetTimeOfIndex(0); wxDateTime end = d->GetTimeOfIndex(d->GetValuesTable().size()); wxString prefix = di->GetBasePrefix(); wxString set = di->GetSetName(); std::vector<wxDateTime> remarks_times; for (std::vector<Remark>::iterator i = remarks.begin(); i != remarks.end(); i++) { wxDateTime rt = i->GetTime(); std::wstring rset = i->GetSet(); if (prefix != i->GetAttachedPrefix() || (!rset.empty() && set != rset) || rt < start || rt >= end) continue; remarks_times.push_back(rt); m_remarks[i->GetId()] = *i; } if (remarks_times.size()) { d->SetRemarksTimes(remarks_times); } }
void WxGraphs::SetMargins() { int leftmargin = 36; int bottommargin = 12; int topmargin = 24; wxClientDC dc(this); dc.SetFont(GetFont()); for (size_t i = 0; i < m_graphs.size(); i++) { int tw, th; DrawInfo *di = m_draws[i]->GetDrawInfo(); wxString sval = di->GetValueStr(di->GetMax(), _T("")); dc.GetTextExtent(sval, &tw, &th); if (leftmargin < tw + 1) leftmargin = tw + 1; if (bottommargin < th + 1) bottommargin = th + 1; if (topmargin < th + m_screen_margins.infotopmargin) topmargin = th + m_screen_margins.infotopmargin; } m_screen_margins.leftmargin = leftmargin; m_screen_margins.bottommargin = bottommargin; m_screen_margins.topmargin = topmargin; m_bg_view->SetMargins(m_screen_margins.leftmargin, m_screen_margins.rightmargin, m_screen_margins.topmargin, m_screen_margins.bottommargin); for (size_t i = 0; i < m_graphs.size(); i++) m_graphs.at(i)->SetMargins(m_screen_margins.leftmargin, m_screen_margins.rightmargin, m_screen_margins.topmargin, m_screen_margins.bottommargin); }
void SelectDrawWidget::OnAverageValueCalucatedMethodChange(wxCommandEvent &event) { int i = GetClicked(event); if (i == -1) return; DrawInfo *d = m_draws_wdg->GetDrawInfo(i); AverageValueCalculationMethod qt = d->GetAverageValueCalculationMethod(); switch (event.GetId()) { case seldrawID_CTX_AVERAGE_VALUE: if (qt == AVERAGE_VALUE_CALCULATION_AVERAGE) return; d->SetAverageValueCalculationMethod(AVERAGE_VALUE_CALCULATION_AVERAGE); break; case seldrawID_CTX_LAST_VALUE: if (qt == AVERAGE_VALUE_CALCULATION_LAST) return; d->SetAverageValueCalculationMethod(AVERAGE_VALUE_CALCULATION_LAST); break; case seldrawID_CTX_DIFFERENCE_VALUE: if (qt == AVERAGE_VALUE_CALCULATION_LAST_FIRST) return; d->SetAverageValueCalculationMethod(AVERAGE_VALUE_CALCULATION_LAST_FIRST); break; } m_cfg->DrawInfoAverageValueCalculationChanged(d); }
void GrDrawTarget::drawNonIndexed(GrPrimitiveType type, int startVertex, int vertexCount, const SkRect* devBounds) { if (vertexCount > 0 && this->checkDraw(type, startVertex, -1, vertexCount, -1)) { DrawInfo info; info.fPrimitiveType = type; info.fStartVertex = startVertex; info.fStartIndex = 0; info.fVertexCount = vertexCount; info.fIndexCount = 0; info.fInstanceCount = 0; info.fVerticesPerInstance = 0; info.fIndicesPerInstance = 0; if (NULL != devBounds) { info.setDevBounds(*devBounds); } // TODO: We should continue with incorrect blending. if (!this->setupDstReadIfNecessary(&info)) { return; } this->onDraw(info); } }
void XYDialog::OnDrawChange(wxCommandEvent &event) { DrawInfo **draw; wxButton *button; int i = event.GetId() - XY_XAXIS_BUTTON; draw = &m_di[i]; button = wxDynamicCast(FindWindowById(event.GetId()), wxButton); if (m_draw_search->ShowModal() == wxID_CANCEL) return; #ifdef __WXMSW__ //hilarious... Raise(); #endif long previous = -1; DrawInfo *choosen = m_draw_search->GetDrawInfo(&previous); if (choosen == NULL) return; *draw = choosen; button->SetLabel(choosen->GetName()); }
void WxGraphs::DrawCurrentParamName(wxDC *dc) { DrawInfo *di = m_draws_wdg->GetCurrentDrawInfo(); if (di == NULL) return; wxFont f = GetFont(); int ps = f.GetPointSize(); int fw = f.GetWeight(); f.SetWeight(wxFONTWEIGHT_BOLD); f.SetPointSize(ps * 1.25); dc->SetFont(f); wxString text = m_cfg_mgr->GetConfigTitles()[di->GetBasePrefix()] + _T(":") + di->GetParamName(); int tw, th; dc->GetTextExtent(text, &tw, &th); int w, h; GetSize(&w, &h); dc->SetTextForeground(di->GetDrawColor()); dc->SetBrush(*wxBLACK_BRUSH); dc->SetPen(*wxWHITE_PEN); dc->DrawRectangle(w / 2 - tw / 2 - 1, h / 2 - th / 2 - 1, tw + 2, th + 2); dc->DrawText(text, w / 2 - tw / 2, h / 2 - th / 2); f.SetPointSize(ps); f.SetWeight(fw); dc->SetFont(f); }
void GCDCGraphs::RecalculateMargins(wxGraphicsContext &dc) { if (!m_recalulate_margins) return; double leftmargin = 36; double bottommargin = 12; double topmargin = 24; for (size_t i = 0; i < m_draws.size(); i++) { double tw, th, td, tel; DrawInfo *di = m_draws[i]->GetDrawInfo(); wxString sval = di->GetValueStr(di->GetMax(), _T("")); dc.GetTextExtent(sval, &tw, &th, &td, &tel); if (leftmargin < tw + 1) leftmargin = tw + 1; if (bottommargin < th + 1) bottommargin = th + 1; if (topmargin < th + m_screen_margins.infotopmargin) topmargin = th + m_screen_margins.infotopmargin; dc.GetTextExtent(di->GetUnit(), &tw, &th, &td, &tel); if (leftmargin < tw + 6) leftmargin = tw + 6; } m_screen_margins.leftmargin = leftmargin; m_screen_margins.bottommargin = bottommargin; m_screen_margins.topmargin = topmargin; m_recalulate_margins = false; }
void GrInOrderDrawBuffer::onDraw(const DrawInfo& info) { GeometryPoolState& poolState = fGeoPoolStateStack.back(); const GrDrawState& drawState = this->getDrawState(); AutoClipReenable acr; if (drawState.isClipState() && info.getDevBounds() && this->quickInsideClip(*info.getDevBounds())) { acr.set(this->drawState()); } this->recordClipIfNecessary(); this->recordStateIfNecessary(); const GrVertexBuffer* vb; if (kBuffer_GeometrySrcType == this->getGeomSrc().fVertexSrc) { vb = this->getGeomSrc().fVertexBuffer; } else { vb = poolState.fPoolVertexBuffer; } const GrIndexBuffer* ib = NULL; if (info.isIndexed()) { if (kBuffer_GeometrySrcType == this->getGeomSrc().fIndexSrc) { ib = this->getGeomSrc().fIndexBuffer; } else { ib = poolState.fPoolIndexBuffer; } } Draw* draw; if (info.isInstanced()) { int instancesConcated = this->concatInstancedDraw(info); if (info.instanceCount() > instancesConcated) { draw = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, Draw, (info, vb, ib)); draw->fInfo.adjustInstanceCount(-instancesConcated); } else { return; } } else { draw = GrNEW_APPEND_TO_RECORDER(fCmdBuffer, Draw, (info, vb, ib)); } this->recordTraceMarkersIfNecessary(); // Adjust the starting vertex and index when we are using reserved or array sources to // compensate for the fact that the data was inserted into a larger vb/ib owned by the pool. if (kBuffer_GeometrySrcType != this->getGeomSrc().fVertexSrc) { size_t bytes = (info.vertexCount() + info.startVertex()) * drawState.getVertexStride(); poolState.fUsedPoolVertexBytes = SkTMax(poolState.fUsedPoolVertexBytes, bytes); draw->fInfo.adjustStartVertex(poolState.fPoolStartVertex); } if (info.isIndexed() && kBuffer_GeometrySrcType != this->getGeomSrc().fIndexSrc) { size_t bytes = (info.indexCount() + info.startIndex()) * sizeof(uint16_t); poolState.fUsedPoolIndexBytes = SkTMax(poolState.fUsedPoolIndexBytes, bytes); draw->fInfo.adjustStartIndex(poolState.fPoolStartIndex); } }
void SelectDrawWidget::OnPSC(wxCommandEvent &event) { int i = GetClicked(event); if (i == -1) return; DrawInfo* info = m_draws_wdg->GetDrawInfo(i); m_cfg->EditPSC(info->GetBasePrefix(), info->GetParamName()); }
void GrGpu::onDraw(const DrawInfo& info) { this->handleDirtyContext(); GrDrawState::AutoRestoreEffects are; if (!this->setupClipAndFlushState(PrimTypeToDrawType(info.primitiveType()), info.getDstCopy(), &are, info.getDevBounds())) { return; } this->onGpuDraw(info); }
void InfoWidget::SetDrawInfo(Draw *draw) { DrawInfo *info = draw->GetDrawInfo(); if (info == NULL) return; SetUnit(info->GetUnit()); SetColor(info->GetDrawColor()); SetPrec(info->GetPrec()); SetPeriod(draw->GetPeriod()); }
static void _do_motion(Widget w, void *data, XADCS *call_data) { DrawInfo *di = (DrawInfo *) data; SetDrawArea(w); if (di->motion) di->motion(w, call_data->event->xmotion.x, call_data->event->xmotion.y, di->user_data); }
void SelectDrawValidator::OnMouseRightDown(wxMouseEvent &event) { DrawInfo* di = m_draws_wdg->GetDrawInfo(m_index); if (di == NULL) return; wxMenu menu; DrawParam* dp = di->GetParam(); if (di->IsValid() && dp->GetIPKParam()->GetPSC()) menu.Append(seldrawID_PSC,_("Set parameter")); menu.SetClientData(m_cb); if (m_draws_wdg->GetDrawBlocked(m_index)) { wxMenuItem* item = menu.AppendCheckItem(seldrawID_CTX_BLOCK_MENU, _("Draw blocked\tCtrl-B")); item->Check(); } else { int non_blocked_count = 0; for (unsigned int i = 0; i < m_draws_wdg->GetDrawsCount(); ++i) if (!m_draws_wdg->GetDrawBlocked(i)) non_blocked_count++; //one draw shall be non-blocked if (non_blocked_count > 1) menu.AppendCheckItem(seldrawID_CTX_BLOCK_MENU, _("Draw blocked\tCtrl-B")); } menu.Append(seldrawID_CTX_DOC_MENU, _("Parameter documentation\tCtrl-H")); menu.Append(seldrawID_CTX_COPY_PARAM_NAME_MENU, _("Copy parameter name\tCtrl+Shift+C")); wxMenu* submenu = new wxMenu(); submenu->SetClientData(m_cb); wxMenuItem* averageItem = submenu->AppendRadioItem(seldrawID_CTX_AVERAGE_VALUE, _("Average value for selected period")); wxMenuItem* lastItem = submenu->AppendRadioItem(seldrawID_CTX_LAST_VALUE, _("Last value")); wxMenuItem* diffItem = submenu->AppendRadioItem(seldrawID_CTX_DIFFERENCE_VALUE, _("Difference between last and first value")); menu.AppendSubMenu(submenu, _("Type of average values shown")); switch (di->GetAverageValueCalculationMethod()) { case AVERAGE_VALUE_CALCULATION_AVERAGE: averageItem->Check(true); break; case AVERAGE_VALUE_CALCULATION_LAST: lastItem->Check(true); break; case AVERAGE_VALUE_CALCULATION_LAST_FIRST: diffItem->Check(true); break; } if (dynamic_cast<DefinedParam*>(dp) != NULL) menu.Append(seldrawID_CTX_EDIT_PARAM, _("Edit parameter associated with graph\tCtrl-E")); m_cb->PopupMenu(&menu); }
void WxGraphs::OnMouseRightDown(wxMouseEvent &event) { if (m_draws_wdg->GetSelectedDrawIndex() == -1) return; Draw *d = m_draws[m_draws_wdg->GetSelectedDrawIndex()]; DrawInfo *di = d->GetDrawInfo(); SetInfoDataObject wido(di->GetBasePrefix(), di->GetSetName(), d->GetPeriod(), d->GetCurrentTime().GetTicks(), m_draws_wdg->GetSelectedDrawIndex()); wxDropSource ds(wido, this); ds.DoDragDrop(0); }
void WxGraphs::DrawWindowInfo(wxDC * dc, const wxRegion & repainted_region) { if (repainted_region.IsEmpty()) return; int info_left_marg = m_screen_margins.leftmargin + 8; int param_name_shift = 5; if (m_draws.size() < 1) return; int w, h; dc->GetSize(&w, &h); DrawInfo *info = m_draws[0]->GetDrawInfo(); wxString name = info->GetSetName().c_str(); int namew, nameh; dc->GetTextExtent(name, &namew, &nameh); if (repainted_region.Contains(info_left_marg, m_screen_margins.infotopmargin, w - m_screen_margins.infotopmargin, nameh) == wxOutRegion) return; dc->SetTextForeground(*wxWHITE); dc->DrawText(name, info_left_marg, m_screen_margins.infotopmargin); wxColor color = dc->GetTextForeground(); int xpos = info_left_marg + namew + param_name_shift; for (int i = 0; i < (int)m_draws.size(); ++i) { if (!m_draws[i]->GetEnable()) continue; DrawInfo *info = m_draws[i]->GetDrawInfo(); dc->SetTextForeground(info->GetDrawColor()); name = info->GetShortName().c_str(); dc->GetTextExtent(name, &namew, &nameh); dc->DrawText(name, xpos, m_screen_margins.infotopmargin); xpos += namew + param_name_shift; } dc->SetTextForeground(color); }
/* Called when a DrawingArea is resized. */ static void _resize(Widget w, void *data, XADCS *call_data) { int new_width, new_height; DrawInfo *di = (DrawInfo *) data; if (call_data->event->xexpose.count != 0) /* Wait until last expose event */ return; SetDrawArea(w); GetDrawAreaSize(&new_width, &new_height); /* get the new draw area size */ if (di->redisplay) di->redisplay(w, new_width, new_height, di->user_data); }
void GrDrawTarget::drawIndexed(GrPipelineBuilder* pipelineBuilder, const GrGeometryProcessor* gp, GrPrimitiveType type, int startVertex, int startIndex, int vertexCount, int indexCount, const SkRect* devBounds) { SkASSERT(pipelineBuilder); if (indexCount > 0 && this->checkDraw(*pipelineBuilder, gp, type, startVertex, startIndex, vertexCount, indexCount)) { // Setup clip GrScissorState scissorState; GrPipelineBuilder::AutoRestoreFragmentProcessors arfp; GrPipelineBuilder::AutoRestoreStencil ars; if (!this->setupClip(pipelineBuilder, &arfp, &ars, &scissorState, devBounds)) { return; } DrawInfo info; info.fPrimitiveType = type; info.fStartVertex = startVertex; info.fStartIndex = startIndex; info.fVertexCount = vertexCount; info.fIndexCount = indexCount; info.fInstanceCount = 0; info.fVerticesPerInstance = 0; info.fIndicesPerInstance = 0; if (devBounds) { info.setDevBounds(*devBounds); } GrDrawTarget::PipelineInfo pipelineInfo(pipelineBuilder, &scissorState, gp, devBounds, this); if (pipelineInfo.mustSkipDraw()) { return; } this->setDrawBuffers(&info, gp->getVertexStride()); this->onDraw(gp, info, pipelineInfo); } }
void GrDrawTarget::drawIndexedInstances(GrPrimitiveType type, int instanceCount, int verticesPerInstance, int indicesPerInstance, const SkRect* devBounds) { if (!verticesPerInstance || !indicesPerInstance) { return; } int maxInstancesPerDraw = this->indexCountInCurrentSource() / indicesPerInstance; if (!maxInstancesPerDraw) { return; } DrawInfo info; info.fPrimitiveType = type; info.fStartIndex = 0; info.fStartVertex = 0; info.fIndicesPerInstance = indicesPerInstance; info.fVerticesPerInstance = verticesPerInstance; // Set the same bounds for all the draws. if (NULL != devBounds) { info.setDevBounds(*devBounds); } // TODO: We should continue with incorrect blending. if (!this->setupDstReadIfNecessary(&info)) { return; } while (instanceCount) { info.fInstanceCount = SkTMin(instanceCount, maxInstancesPerDraw); info.fVertexCount = info.fInstanceCount * verticesPerInstance; info.fIndexCount = info.fInstanceCount * indicesPerInstance; if (this->checkDraw(type, info.fStartVertex, info.fStartIndex, info.fVertexCount, info.fIndexCount)) { this->onDraw(info); } info.fStartVertex += info.fVertexCount; instanceCount -= info.fInstanceCount; } }
void DrawsWidget::CopyToClipboard() { Draw *d = m_draws_controller->GetSelectedDraw(); if (d == NULL) return; if (wxTheClipboard->Open() == false) return; DrawInfo *di = d->GetDrawInfo(); SetInfoDataObject* wido = new SetInfoDataObject(di->GetBasePrefix(), di->GetSetName(), d->GetPeriod(), d->GetCurrentTime().GetTicks(), d->GetDrawNo()); wxTheClipboard->SetData(wido); wxTheClipboard->Close(); }
void SelectDrawWidget::OpenParameterDoc(int i) { DrawInfo* d; if (i == -1) d = m_draws_wdg->GetCurrentDrawInfo(); else d = m_draws_wdg->GetDrawInfo(i); if (d == NULL) return; if (DefinedParam* dp = dynamic_cast<DefinedParam*>(d->GetParam())) ShowDefinedParamDoc(dp); else GoToWWWDocumentation(d); #ifdef __WXMSW__ m_draws_wdg->SetFocus(); #endif }
void SelectDrawWidget::OnEditParam(wxCommandEvent &event) { int i = GetClicked(event); if (i == -1) return; DrawInfo *d = m_draws_wdg->GetDrawInfo(i); DefinedParam *dp = dynamic_cast<DefinedParam*>(d->GetParam()); if (dp == NULL) return; wxWindow *w = this; while (!w->IsTopLevel()) w = w->GetParent(); ParamEdit pe(w, m_cfg, m_dbmgr, m_remarks_handler); pe.SetCurrentConfig(d->GetBasePrefix()); pe.Edit(dp); }
void GCDCGraphs::DrawWindowInfo(wxGraphicsContext &dc) { double info_left_marg = m_screen_margins.leftmargin + 8; double param_name_shift = 5; if (m_draws.size() < 1) return; int w, h; GetClientSize(&w, &h); DrawInfo *info = m_draws[0]->GetDrawInfo(); wxString name = info->GetSetName().c_str(); double namew, nameh, th, tsel; dc.GetTextExtent(name, &namew, &nameh, &th, &tsel); dc.DrawText(name, info_left_marg, m_screen_margins.infotopmargin); int xpos = info_left_marg + namew + param_name_shift; for (int i = 0; i < (int)m_draws.size(); ++i) { if (!m_draws[i]->GetEnable()) continue; DrawInfo *info = m_draws[i]->GetDrawInfo(); dc.SetFont(GetFont(), info->GetDrawColor()); name = info->GetShortName().c_str(); if (!name.IsEmpty()) { dc.GetTextExtent(name, &namew, &nameh, &th, &tsel); dc.DrawText(name, xpos, m_screen_margins.infotopmargin); xpos += namew + param_name_shift; } else { xpos += param_name_shift; } } }
void RemarksFetcher::Fetch() { if (!m_remarks_handler->Configured()) return; Draw* d = m_draws_controller->GetSelectedDraw(); if (d == NULL) return; wxDateTime start = d->GetTimeOfIndex(0); if (!start.IsValid()) return; wxDateTime end = d->GetTimeOfIndex(d->GetValuesTable().size()); DrawInfo *di = d->GetDrawInfo(); m_remarks_handler->GetStorage()->GetRemarks( di->GetBasePrefix(), di->GetSetName(), start.GetTicks(), end.GetTicks(), this); }
int GrInOrderDrawBuffer::concatInstancedDraw(const DrawInfo& info) { GrAssert(info.isInstanced()); const GeometrySrcState& geomSrc = this->getGeomSrc(); const GrDrawState& drawState = this->getDrawState(); // we only attempt to concat the case when reserved verts are used with a client-specified index // buffer. To make this work with client-specified VBs we'd need to know if the VB was updated // between draws. if (kReserved_GeometrySrcType != geomSrc.fVertexSrc || kBuffer_GeometrySrcType != geomSrc.fIndexSrc) { return 0; } // Check if there is a draw info that is compatible that uses the same VB from the pool and // the same IB if (kDraw_Cmd != fCmds.back()) { return 0; } DrawRecord* draw = &fDraws.back(); GeometryPoolState& poolState = fGeoPoolStateStack.back(); const GrVertexBuffer* vertexBuffer = poolState.fPoolVertexBuffer; if (!draw->isInstanced() || draw->verticesPerInstance() != info.verticesPerInstance() || draw->indicesPerInstance() != info.indicesPerInstance() || draw->fVertexBuffer != vertexBuffer || draw->fIndexBuffer != geomSrc.fIndexBuffer) { return 0; } // info does not yet account for the offset from the start of the pool's VB while the previous // draw record does. int adjustedStartVertex = poolState.fPoolStartVertex + info.startVertex(); if (draw->startVertex() + draw->vertexCount() != adjustedStartVertex) { return 0; } GrAssert(poolState.fPoolStartVertex == draw->startVertex() + draw->vertexCount()); // how many instances can be concat'ed onto draw given the size of the index buffer int instancesToConcat = this->indexCountInCurrentSource() / info.indicesPerInstance(); instancesToConcat -= draw->instanceCount(); instancesToConcat = GrMin(instancesToConcat, info.instanceCount()); // update the amount of reserved vertex data actually referenced in draws size_t vertexBytes = instancesToConcat * info.verticesPerInstance() * drawState.getVertexSize(); poolState.fUsedPoolVertexBytes = GrMax(poolState.fUsedPoolVertexBytes, vertexBytes); draw->adjustInstanceCount(instancesToConcat); return instancesToConcat; }
void ParamEdit::OnFormulaInsertParam(wxCommandEvent &event) { DrawsSets* drawsets = m_cfg_mgr->GetConfigByPrefix(m_base_prefix); assert(drawsets); wxString ct = drawsets->GetID(); if (m_inc_search == NULL) m_inc_search = new IncSearch(m_cfg_mgr, m_remarks_handler, ct, this, -1, _("Find"), false, false); else m_inc_search->SetConfigName(ct); if (m_inc_search->ShowModal() != wxID_OK) return; long prev = -1; DrawInfo *draw; while ((draw = m_inc_search->GetDrawInfo(&prev)) != NULL) { DrawParam *p = draw->GetParam(); wxString pname = p->GetParamName(); m_formula_input->AddText(wxString::Format(_T("p(\"%s:%s\", t, pt) "), draw->GetBasePrefix().c_str(), pname.c_str())); } }
void GCDCGraphs::DrawGraph(wxGraphicsContext &dc, Draw* d) { static const int ellipse_size = 5; if (d->GetEnable() == false) return; DrawInfo *di = d->GetDrawInfo(); bool double_cursor = d->GetSelected() && d->GetDoubleCursor(); wxGraphicsPath path1 = dc.CreatePath(); wxGraphicsPath path2 = dc.CreatePath(); wxGraphicsPath *path = &path1; const wxColour &wc = di->GetDrawColor(); dc.SetPen(wxPen(wc, double_cursor ? 4 : 2, wxSOLID)); int pc = d->GetValuesTable().size(); bool prev_data = false; bool switched_to_alternate = false; bool switched_back = false; int dcs = -1, dce = -1; if (double_cursor) { dcs = d->GetValuesTable().m_stats.Start() - d->GetValuesTable().m_view.Start(); dce = d->GetValuesTable().m_stats.End() - d->GetValuesTable().m_view.Start(); } std::vector<std::pair<double,double> > p1circles; std::vector<std::pair<double,double> > p2circles; std::vector<std::pair<double,double> >* pcircles = &p1circles; bool draw_circle = d->GetPeriod() != PERIOD_T_DAY && d->GetPeriod() != PERIOD_T_30MINUTE && d->GetPeriod() != PERIOD_T_5MINUTE && d->GetPeriod() != PERIOD_T_MINUTE && d->GetPeriod() != PERIOD_T_30SEC; for (int i = 0; i < pc; i++) { if (!d->GetValuesTable().at(i).IsData()) { prev_data = false; continue; } double x = GetX(i); double y = GetY(d->GetValuesTable().at(i).val, di); bool drawn = false; if (i >= dcs && i <= dce && !switched_to_alternate) { if (prev_data) path->AddLineToPoint(x, y); path = &path2; pcircles = &p2circles; if (draw_circle || (!prev_data && ((i + 1) < pc) && !d->GetValuesTable().at(i + 1).IsData())) pcircles->push_back(std::make_pair(x, y)); path->MoveToPoint(x, y); switched_to_alternate = true; drawn = true; } if (i >= dce && switched_to_alternate && !switched_back) { if (prev_data) path->AddLineToPoint(x, y); std::vector<std::pair<double, double> > *p; if (i == dce) p = &p2circles; else p = &p1circles; if (draw_circle || (!prev_data && ((i + 1) < pc) && !d->GetValuesTable().at(i + 1).IsData())) p->push_back(std::make_pair(x, y)); path = &path1; pcircles = &p1circles; path->MoveToPoint(x, y); switched_back = true; drawn = true; } if (!drawn) { if (prev_data) path->AddLineToPoint(x, y); else path->MoveToPoint(x, y); if (draw_circle || (!prev_data && ((i + 1) < pc) && !d->GetValuesTable().at(i + 1).IsData())) pcircles->push_back(std::make_pair(x, y)); } prev_data = true; } for (std::vector<std::pair<double, double> >::iterator i = p1circles.begin(); i != p1circles.end(); i++) if (draw_circle) path1.AddEllipse(i->first - ellipse_size / 2, i->second - ellipse_size / 2, ellipse_size, ellipse_size); else path1.AddCircle(i->first, i->second, 1); dc.StrokePath(path1); if (double_cursor) { dc.SetPen(wxPen(*wxWHITE, 4, wxSOLID)); for (std::vector<std::pair<double, double> >::iterator i = p2circles.begin(); i != p2circles.end(); i++) if (draw_circle) path2.AddEllipse(i->first - ellipse_size / 2, i->second - ellipse_size / 2, ellipse_size, ellipse_size); else path2.AddCircle(i->first, i->second, 1); dc.StrokePath(path2); } }
void GrGpuGL::setupGeometry(const DrawInfo& info, int* startIndexOffset) { int newColorOffset; int newCoverageOffset; int newTexCoordOffsets[GrDrawState::kMaxTexCoords]; int newEdgeOffset; GrVertexLayout currLayout = this->getVertexLayout(); GrGLsizei newStride = GrDrawState::VertexSizeAndOffsetsByIdx(currLayout, newTexCoordOffsets, &newColorOffset, &newCoverageOffset, &newEdgeOffset); int oldColorOffset; int oldCoverageOffset; int oldTexCoordOffsets[GrDrawState::kMaxTexCoords]; int oldEdgeOffset; GrGLsizei oldStride = GrDrawState::VertexSizeAndOffsetsByIdx(fHWGeometryState.fVertexLayout, oldTexCoordOffsets, &oldColorOffset, &oldCoverageOffset, &oldEdgeOffset); int extraVertexOffset; this->setBuffers(info.isIndexed(), &extraVertexOffset, startIndexOffset); GrGLenum scalarType; bool texCoordNorm; if (currLayout & GrDrawState::kTextFormat_VertexLayoutBit) { scalarType = TEXT_COORDS_GL_TYPE; texCoordNorm = SkToBool(TEXT_COORDS_ARE_NORMALIZED); } else { scalarType = GR_GL_FLOAT; texCoordNorm = false; } size_t vertexOffset = (info.startVertex() + extraVertexOffset) * newStride; // all the Pointers must be set if any of these are true bool allOffsetsChange = fHWGeometryState.fArrayPtrsDirty || vertexOffset != fHWGeometryState.fVertexOffset || newStride != oldStride; // position and tex coord offsets change if above conditions are true // or the type/normalization changed based on text vs nontext type coords. bool posAndTexChange = allOffsetsChange || (((TEXT_COORDS_GL_TYPE != GR_GL_FLOAT) || TEXT_COORDS_ARE_NORMALIZED) && (GrDrawState::kTextFormat_VertexLayoutBit & (fHWGeometryState.fVertexLayout ^ currLayout))); if (posAndTexChange) { int idx = GrGLProgram::PositionAttributeIdx(); GL_CALL(VertexAttribPointer(idx, 2, scalarType, false, newStride, (GrGLvoid*)vertexOffset)); fHWGeometryState.fVertexOffset = vertexOffset; } for (int t = 0; t < GrDrawState::kMaxTexCoords; ++t) { if (newTexCoordOffsets[t] > 0) { GrGLvoid* texCoordOffset = (GrGLvoid*)(vertexOffset + newTexCoordOffsets[t]); int idx = GrGLProgram::TexCoordAttributeIdx(t); if (oldTexCoordOffsets[t] <= 0) { GL_CALL(EnableVertexAttribArray(idx)); GL_CALL(VertexAttribPointer(idx, 2, scalarType, texCoordNorm, newStride, texCoordOffset)); } else if (posAndTexChange || newTexCoordOffsets[t] != oldTexCoordOffsets[t]) { GL_CALL(VertexAttribPointer(idx, 2, scalarType, texCoordNorm, newStride, texCoordOffset)); } } else if (oldTexCoordOffsets[t] > 0) { GL_CALL(DisableVertexAttribArray(GrGLProgram::TexCoordAttributeIdx(t))); } } if (newColorOffset > 0) { GrGLvoid* colorOffset = (int8_t*)(vertexOffset + newColorOffset); int idx = GrGLProgram::ColorAttributeIdx(); if (oldColorOffset <= 0) { GL_CALL(EnableVertexAttribArray(idx)); GL_CALL(VertexAttribPointer(idx, 4, GR_GL_UNSIGNED_BYTE, true, newStride, colorOffset)); } else if (allOffsetsChange || newColorOffset != oldColorOffset) { GL_CALL(VertexAttribPointer(idx, 4, GR_GL_UNSIGNED_BYTE, true, newStride, colorOffset)); } } else if (oldColorOffset > 0) { GL_CALL(DisableVertexAttribArray(GrGLProgram::ColorAttributeIdx())); } if (newCoverageOffset > 0) { GrGLvoid* coverageOffset = (int8_t*)(vertexOffset + newCoverageOffset); int idx = GrGLProgram::CoverageAttributeIdx(); if (oldCoverageOffset <= 0) { GL_CALL(EnableVertexAttribArray(idx)); GL_CALL(VertexAttribPointer(idx, 4, GR_GL_UNSIGNED_BYTE, true, newStride, coverageOffset)); } else if (allOffsetsChange || newCoverageOffset != oldCoverageOffset) { GL_CALL(VertexAttribPointer(idx, 4, GR_GL_UNSIGNED_BYTE, true, newStride, coverageOffset)); } } else if (oldCoverageOffset > 0) { GL_CALL(DisableVertexAttribArray(GrGLProgram::CoverageAttributeIdx())); } if (newEdgeOffset > 0) { GrGLvoid* edgeOffset = (int8_t*)(vertexOffset + newEdgeOffset); int idx = GrGLProgram::EdgeAttributeIdx(); if (oldEdgeOffset <= 0) { GL_CALL(EnableVertexAttribArray(idx)); GL_CALL(VertexAttribPointer(idx, 4, scalarType, false, newStride, edgeOffset)); } else if (allOffsetsChange || newEdgeOffset != oldEdgeOffset) { GL_CALL(VertexAttribPointer(idx, 4, scalarType, false, newStride, edgeOffset)); } } else if (oldEdgeOffset > 0) { GL_CALL(DisableVertexAttribArray(GrGLProgram::EdgeAttributeIdx())); } fHWGeometryState.fVertexLayout = currLayout; fHWGeometryState.fArrayPtrsDirty = false; }
void GrInOrderDrawBuffer::onDraw(const DrawInfo& info) { GeometryPoolState& poolState = fGeoPoolStateStack.back(); const GrDrawState& drawState = this->getDrawState(); AutoClipReenable acr; if (drawState.isClipState() && NULL != info.getDevBounds() && this->quickInsideClip(*info.getDevBounds())) { acr.set(this->drawState()); } if (this->needsNewClip()) { this->recordClip(); } if (this->needsNewState()) { this->recordState(); } DrawRecord* draw; if (info.isInstanced()) { int instancesConcated = this->concatInstancedDraw(info); if (info.instanceCount() > instancesConcated) { draw = this->recordDraw(info); draw->adjustInstanceCount(-instancesConcated); } else { return; } } else { draw = this->recordDraw(info); } switch (this->getGeomSrc().fVertexSrc) { case kBuffer_GeometrySrcType: draw->fVertexBuffer = this->getGeomSrc().fVertexBuffer; break; case kReserved_GeometrySrcType: // fallthrough case kArray_GeometrySrcType: { size_t vertexBytes = (info.vertexCount() + info.startVertex()) * drawState.getVertexSize(); poolState.fUsedPoolVertexBytes = GrMax(poolState.fUsedPoolVertexBytes, vertexBytes); draw->fVertexBuffer = poolState.fPoolVertexBuffer; draw->adjustStartVertex(poolState.fPoolStartVertex); break; } default: GrCrash("unknown geom src type"); } draw->fVertexBuffer->ref(); if (info.isIndexed()) { switch (this->getGeomSrc().fIndexSrc) { case kBuffer_GeometrySrcType: draw->fIndexBuffer = this->getGeomSrc().fIndexBuffer; break; case kReserved_GeometrySrcType: // fallthrough case kArray_GeometrySrcType: { size_t indexBytes = (info.indexCount() + info.startIndex()) * sizeof(uint16_t); poolState.fUsedPoolIndexBytes = GrMax(poolState.fUsedPoolIndexBytes, indexBytes); draw->fIndexBuffer = poolState.fPoolIndexBuffer; draw->adjustStartIndex(poolState.fPoolStartIndex); break; } default: GrCrash("unknown geom src type"); } draw->fIndexBuffer->ref(); } else { draw->fIndexBuffer = NULL; } }