📄 tdataviewx.c
字号:
#endif _pstorage.Clear(); _queryProc->BatchQuery(_map, _queryFilter, this, 0, _timestamp); } else {#ifdef DEBUG printf("View has no mappings; reporting query as done\n");#endif ReportQueryDone(0); DoneMappingIterator(_index); _map = 0; _index = -1; }}void TDataViewX::DerivedAbortQuery(){#ifdef DEBUG printf("TDataViewX::Abort query, index = %d\n", _index);#endif if (_map) { _queryProc->AbortQuery(_map, this); DOASSERT(_index >= 0, "Invalid iterator index"); DoneMappingIterator(_index); _map = 0; _index = -1; } // Abort record links whose master this view is int index = _masterLink.InitIterator(); while(_masterLink.More(index)) { RecordLink *link = _masterLink.Next(index); link->Abort(); } _masterLink.DoneIterator(index); _dataBin->Final();}Boolean TDataViewX::DisplaySymbols(Boolean state){ #if defined(DEBUG) printf("TDataViewX::DisplaySymbols(%d)\n", state);#endif if (state == _dispSymbols) return state; Boolean oldState = _dispSymbols; _dispSymbols = state;#ifdef DEBUG printf("DisplaySymbols now %s\n", (_dispSymbols ? "on" : "off"));#endif InvalidatePixmaps(); Refresh(); return oldState;}Boolean TDataViewX::DisplayConnectors(Boolean state){ #if defined(DEBUG) printf("TDataViewX::DisplayConnectors(%d)\n", state);#endif#if !USE_CONNECTORS return false;#endif if (state == _dispConnectors) return state; if (!state) { DOASSERT(_cMap, "No connector mapping"); delete _cMap; _cMap = NULL; } else { DOASSERT(!_cMap, "Unexpected connector mapping"); _cMap = new TDataCMap; DOASSERT(_cMap, "Could not create connector mapping"); _cMap->SetDefaultColor(GetFgColor()); } Boolean oldState = _dispConnectors; _dispConnectors = state;#ifdef DEBUG printf("DisplayConnectors now %s\n", (_dispConnectors ? "on" : "off"));#endif InvalidatePixmaps(); Refresh(); return oldState;}/* Query data ready to be returned. Do initialization here. */void TDataViewX::QueryInit(void *userData){ _dataBin->Init(_map, &_queryFilter, GetWindowRep()->TopTransform(), _dispSymbols, _dispConnectors, _cMap, this);}void TDataViewX::ReturnGData(TDataMap *mapping, RecId recId, void *gdata, int numGData){#if defined(DEBUG) printf("TDataViewX::ReturnGData()\n");#endif DOASSERT(_index >= 0, "Invalid iterator index"); mapping->UpdateMaxSymSize(gdata, numGData); int gRecSize = mapping->GDataRecordSize(); _totalGData += numGData; _numBatches++; char *tp = (char *)gdata; GDataAttrOffset *offset = mapping->GetGDataOffset(); // Can do record elimination only for constant bar shape Boolean canElimRecords = false; if (offset->shapeOffset < 0 && mapping->GetDefaultShape() == 2) canElimRecords = true; // Collect statistics and update record links only for last mapping if (!MoreMapping(_index)) { int firstRec = 0; for(int i = 0; i < numGData; i++) { // Extract X, Y, shape, and color information from gdata record Coord x = GetX(tp, mapping, offset); Coord y = GetY(tp, mapping, offset); ShapeID shape = GetShape(tp, mapping, offset); GlobalColor color = mapping->GetDefaultColor(); if (offset->colorOffset >= 0) color = *(GlobalColor *)(tp + offset->colorOffset); Boolean complexShape = mapping->IsComplexShape(shape); complexShape |= (GetNumDimensions() == 3); // Compute statistics only for records that match the filter''s // X range, regardless of the Y boundary if (x >= _queryFilter.xLow && x <= _queryFilter.xHigh) { if (color < MAXCOLOR) _stats[color].Sample(x, y); _allStats.Sample(x, y); _allStats.Histogram(y); if(_glist.Size() <= MAX_GSTAT) { int X = (int) x; BasicStats *bs; if(_gstat.Lookup(X, bs)) { bs->Sample(x,y); } else { bs = new BasicStats(); DOASSERT(bs, "Out of memory"); bs->Init(0); _glist.InsertOrderly(X, 1); bs->Sample(x, y); _gstat.Insert(X, bs); _blist.Insert(bs); } } } // Contiguous ranges which match the filter''s X *and* Y range // are stored in the record link if (!complexShape && (x < _queryFilter.xLow || x > _queryFilter.xHigh || y < _queryFilter.yLow || y > _queryFilter.yHigh)) { if (i > firstRec) WriteMasterLink(recId + firstRec, i - firstRec); // Next contiguous batch of record id''s starts at i+1 firstRec = i + 1; } tp += gRecSize; } if (numGData > firstRec) WriteMasterLink(recId + firstRec, numGData - firstRec); } // Draw data only if window is not iconified if (!Iconified()) { if (_batchRecs) { _dataBin->InsertSymbol(recId, gdata, numGData, 0, 1, canElimRecords);#ifdef DEBUG _dataBin->PrintStat();#endif } else { char *ptr = (char *)gdata; for(int i = 0; i < numGData; i++) { _dataBin->InsertSymbol(recId, ptr, 1, 0, 1, canElimRecords); recId++; ptr += gRecSize; } } }}/* Done with query */void TDataViewX::QueryDone(int bytes, void *userData){#ifdef DEBUG printf("TDataViewX::Query done, index = %d, bytes = %d\n", _index, bytes);#endif _pstorage.Clear(); DOASSERT(_index >= 0, "Invalid iterator index"); if (MoreMapping(_index)) { _map = NextMapping(_index)->map;#ifdef DEBUG printf("Submitting next query 0x%p\n", _map);#endif _queryProc->BatchQuery(_map, _queryFilter, this, 0, _timestamp); return; } DoneMappingIterator(_index); _map = 0; _index = -1; _allStats.Done(); _allStats.Report(); for(int i = 0; i < MAXCOLOR; i++) _stats[i].Done(); PrepareStatsBuffer(); _dataBin->Final(); DrawLegend(); // Finish record links whose master this view is int index = _masterLink.InitIterator(); while(_masterLink.More(index)) { RecordLink *link = _masterLink.Next(index); link->Done(); } _masterLink.DoneIterator(index); ReportQueryDone(bytes);}void TDataViewX::ReturnGDataBinRecs(TDataMap *map, void **recs, int numRecs){#ifdef DEBUG printf("TDataViewX %d recs buf start 0x%p\n", numRecs, recs);#endif WindowRep *win = GetWindowRep(); if (IsInPileMode()) { ViewWin *parent = GetParent(); DOASSERT(parent, "View has no parent"); int index = parent->InitIterator(); DOASSERT(parent->More(index), "Parent view has no children"); ViewWin *vw = parent->Next(index); win = vw->GetWindowRep(); parent->DoneIterator(index);#ifdef DEBUG printf("Drawing view %s in view %s, window 0x%p\n", GetName(), vw->GetName(), win);#endif } map->DrawGDataArray(this, win, recs, numRecs);}void TDataViewX::ReturnGDataBinConnectors(TDataCMap *cmap, Connector **connectors, int num){#ifdef DEBUG printf("TDataViewX drawing %d connectors\n", num);#endif for(int i = 0; i < num; i++) ConnectorShapeRegistrar::DrawConnection(GetWindowRep(), connectors[i]);}void TDataViewX::PrintStat(){ if (Init::PrintViewStat()) { View::PrintStat(); printf("%d GData records, %d batches, %.2f per batch\n", _totalGData, _numBatches, 1.0 * _totalGData / _numBatches); _dataBin->PrintStat(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -