void fillGraph_(Graph & graph, const Node & a, const Node & b, double slowness, SIndex leftID){ if (a.id() == b.id()) return; double dist = a.pos().distance(b.pos()); // ensure connection between 3d boundaries dist = max(1e-8, dist); double newTime = dist * slowness; double oldTime = graph[a.id()][b.id()].time(); // if (V_){ // __MS("a:" << a.id() << " b:" << b.id() << " L:" << leftID << " t:" << " " << newTime << " " << oldTime) // } if (oldTime > 0.0) { newTime = std::min(newTime, oldTime); // way pair already exist so set time to min and add leftID NodeDistMap::iterator ita(graph[a.id()].find(b.id())); ita->second.cellIDs().insert(leftID); ita->second.setTime(newTime); NodeDistMap::iterator itb(graph[b.id()].find(a.id())); itb->second.cellIDs().insert(leftID); itb->second.setTime(newTime); } else { // first time fill graph[a.id()][b.id()] = GraphDistInfo(newTime, dist, leftID); graph[b.id()][a.id()] = GraphDistInfo(newTime, dist, leftID); } }
PotentialValue operator-(const PotentialValue& a, const PotentialValue& b) { PotentialValue res ; for(PotentialValue::Iterator ita(a); ita; ita++) for(PotentialValue::Iterator itb(b); itb; itb++) res.insert(*ita - *itb ) ; return res ; }
// This is called from the AnalyserQueue thread bool AnalyserQueue::isLoadedTrackWaiting(TrackPointer analysingTrack) { const PlayerInfo& info = PlayerInfo::instance(); TrackPointer pTrack; bool trackWaiting = false; QList<TrackPointer> progress100List; QList<TrackPointer> progress0List; m_qm.lock(); QMutableListIterator<TrackPointer> it(m_tioq); while (it.hasNext()) { TrackPointer& pTrack = it.next(); if (!pTrack) { it.remove(); continue; } if (!trackWaiting) { trackWaiting = info.isTrackLoaded(pTrack); } // try to load waveforms for all new tracks first // and remove them from queue if already analysed // This avoids waiting for a running analysis for those tracks. int progress = pTrack->getAnalyserProgress(); if (progress < 0) { // Load stored analysis QListIterator<Analyser*> ita(m_aq); bool processTrack = false; while (ita.hasNext()) { if (!ita.next()->loadStored(pTrack)) { processTrack = true; } } if (!processTrack) { progress100List.append(pTrack); it.remove(); // since pTrack is a reference it is invalid now. } else { progress0List.append(pTrack); } } else if (progress == 1000) { it.remove(); } } m_qm.unlock(); // update progress after unlock to avoid a deadlock foreach (TrackPointer pTrack, progress100List) { emitUpdateProgress(pTrack, 1000); }
// This is called from the AnalyserQueue thread bool AnalyserQueue::isLoadedTrackWaiting(TrackPointer tio) { QMutexLocker queueLocker(&m_qm); const PlayerInfo& info = PlayerInfo::instance(); TrackPointer pTrack; bool trackWaiting = false; QMutableListIterator<TrackPointer> it(m_tioq); while (it.hasNext()) { TrackPointer& pTrack = it.next(); if (!pTrack) { it.remove(); continue; } if (!trackWaiting) { trackWaiting = info.isTrackLoaded(pTrack); } // try to load waveforms for all new tracks first // and remove them from queue if already analysed // This avoids waiting for a running analysis for those tracks. int progress = pTrack->getAnalyserProgress(); if (progress < 0) { // Load stored analysis QListIterator<Analyser*> ita(m_aq); bool processTrack = false; while (ita.hasNext()) { if (!ita.next()->loadStored(pTrack)) { processTrack = true; } } if (!processTrack) { emitUpdateProgress(pTrack, 1000); it.remove(); } else { emitUpdateProgress(pTrack, 0); } } else if (progress == 1000) { it.remove(); } } if (info.isTrackLoaded(tio)) { return false; } return trackWaiting; }
bool ClassData::reference(BrowserClass * target) const { if ((base_type.type == target) || (switch_type.type == target)) return TRUE; unsigned i; for (i = 0; i != nformals; i += 1) if ((formals[i].get_default_value().type == target) || (formals[i].get_extends().type == target)) return TRUE; QListIterator<ActualParamData> ita(actuals); for (; ita.current(); ++ita) if (ita.current()->get_value().type == target) return TRUE; return FALSE; }
void ClassData::save(QTextStream & st, QString & warning) const { nl_indent(st); if (is_abstract) st << "abstract "; if (is_active) st << "active "; st << "visibility " << stringify(uml_visibility) << ' '; if (!stereotype.isEmpty()) { st << "stereotype "; save_string(stereotype, st); if (stereotype == "typedef") base_type.save(st, warning, " base_type ", " explicit_base_type "); } nl_indent(st); if (nformals != 0) { st << "nformals " << nformals; for (int i = 0; i!= nformals; i += 1) formals[i].save(st, warning); nl_indent(st); } if (actuals.count() != 0) { st << "nactuals " << actuals.count(); QListIterator<ActualParamData> ita(actuals); for (; ita.current(); ++ita) ita.current()->save(st, warning); nl_indent(st); } if (!constraint.isEmpty()) { nl_indent(st); st << "constraint "; save_string(constraint, st); } if (cpp_external) st << "cpp_external "; if (cpp_visibility != UmlDefaultVisibility) st << "cpp_visibility " << stringify(cpp_visibility) << " "; st << "cpp_decl "; save_string(cpp_decl, st); nl_indent(st); if (java_external) st << "java_external "; if (java_final) st << "final "; st << "java_decl "; save_string(java_decl, st); if (! java_annotation.isEmpty()) { nl_indent(st); st << "java_annotation "; save_string(java_annotation, st); } nl_indent(st); if (php_external) st << "php_external "; if (php_final) st << "php_final "; st << "php_decl "; save_string(php_decl, st); nl_indent(st); if (python_external) st << "python_external "; if (python_2_2) st << "python_2_2 "; st << "python_decl "; save_string(python_decl, st); nl_indent(st); if (idl_external) st << "idl_external "; if (idl_local) st << "local "; if (idl_custom) st << "custom "; st << "idl_decl "; save_string(idl_decl, st); nl_indent(st); switch_type.save(st, warning, "switch_type ", "explicit_switch_type "); nl_indent(st); }
void UcUseCaseCanvas::send(ToolCom * com, Q3CanvasItemList & all) { Q3PtrList<UcUseCaseCanvas> lu; Q3PtrList<UcClassCanvas> la; Q3CanvasItemList::Iterator cit; for (cit = all.begin(); cit != all.end(); ++cit) { DiagramItem *di = QCanvasItemToDiagramItem(*cit); if ((di != 0) && (*cit)->visible()) { switch (di->type()) { case UmlUseCase: lu.append((UcUseCaseCanvas *) di); break; case UmlClass: la.append((UcClassCanvas *) di); break; default: break; } } } // send UC com->write_unsigned(lu.count()); Q3PtrListIterator<UcUseCaseCanvas> itu(lu); for (; itu.current(); ++itu) { com->write_unsigned((unsigned) itu.current()->get_ident()); itu.current()->get_bn()->write_id(com); com->write(itu.current()->rect()); } // send Actors com->write_unsigned(la.count()); Q3PtrListIterator<UcClassCanvas> ita(la); for (; ita.current(); ++ita) ita.current()->get_bn()->write_id(com); // send rels Q3PtrList<ArrowCanvas> lr; for (itu.toFirst(); itu.current(); ++itu) { Q3PtrListIterator<ArrowCanvas> itl(itu.current()->lines); for (; itl.current(); ++itl) { ArrowCanvas * r = itl.current(); DiagramItem * from = r->get_start(); DiagramItem * to = r->get_end(); if ((from->type() == UmlUseCase) ? (to->type() == UmlClass) : (from->type() == UmlClass)) lr.append(r); } } com->write_unsigned(lr.count()); Q3PtrListIterator<ArrowCanvas> itr(lr); for (; itr.current(); ++itr) itr.current()->write_uc_rel(com); }
static libmaus2::aio::SynchronousGenericInput<uint64_t>::unique_ptr_type openWordPairFile( std::istream & CIS, uint64_t const n, uint64_t const offset ) { libmaus2::suffixsort::GapArrayByteOverflowKeyAccessor acc(CIS); libmaus2::util::ConstIterator<libmaus2::suffixsort::GapArrayByteOverflowKeyAccessor,uint64_t> ita(&acc,0); libmaus2::util::ConstIterator<libmaus2::suffixsort::GapArrayByteOverflowKeyAccessor,uint64_t> ite(&acc,n); libmaus2::util::ConstIterator<libmaus2::suffixsort::GapArrayByteOverflowKeyAccessor,uint64_t> itc = std::lower_bound(ita,ite,offset); uint64_t const el = itc-ita; uint64_t const restel = n - el; CIS.clear(); CIS.seekg( el * 2 * sizeof(uint64_t), std::ios::beg ); libmaus2::aio::SynchronousGenericInput<uint64_t>::unique_ptr_type tSGI( new libmaus2::aio::SynchronousGenericInput<uint64_t>(CIS,1024,2*restel) ); return UNIQUE_PTR_MOVE(tSGI); }
/* region<int> getDiffer( trackDocument * doc, int areaIndex, int start, int end, int time ) { boundaryArea & area = doc->areas[areaIndex]; boundaryCurve & curve = area.divisions.first(); boundaryCurveIndex index; index.curve = 0; index.size = curve.points.size; index.start = start; index.end = end; static array2<bool> flag; flag.allocate( doc->width, doc->height ); region<int> result; if ( ! time ) return result; area.update( time - 1 ); area.update( time ); region<int> prevShape, nowShape; { list< point2<int> > segments; bool checkStart = true; for ( boundaryCurveIndex::iterator iti( index ); iti; ++iti ) { curve.segment( segments, iti(), time - 1 ); } memset( flag.data, 0, sizeof( bool ) * flag.size ); for ( list< point2<int> >::iterator itp( segments ); itp; ++itp ) { flag( clamp( 0, itp->x, doc->width - 1 ), clamp( 0, itp->y, doc->height - 1 ) ) = true; } prevShape.set( flag, 0, 0 ); } { list< point2<int> > segments; bool checkStart = true; for ( boundaryCurveIndex::iterator iti( index ); iti; ++iti ) { curve.segment( segments, iti(), time ); } memset( flag.data, 0, sizeof( bool ) * flag.size ); for ( list< point2<int> >::iterator itp( segments ); itp; ++itp ) { flag( clamp( 0, itp->x, doc->width - 1 ), clamp( 0, itp->y, doc->height - 1 ) ) = true; } nowShape.set( flag, 0, 0 ); } region<int> round; round = nowShape | prevShape; { region<int> line; point2<int> p1 = curve.points[start]( time - 1 ); point2<int> p2 = curve.points[start]( time ); line.line( p1.x, p1.y, p2.x, p2.y ); round |= line; } { region<int> line; point2<int> p1 = curve.points[end]( time - 1 ); point2<int> p2 = curve.points[end]( time ); line.line( p1.x, p1.y, p2.x, p2.y ); round |= line; } round.fill( result ); return result; } */ void stateDocument::paint() { trackDocument * doc = trackDocument::get(); trackView * view = trackView::get(); if ( ! doc ) return; if ( ! view ) return; static image viewImage;//画面表示用画像 viewImage.topdown = false; double maxValue = doc->maxValues[doc->currentViewImageIndex]; double windowLevel = windowLevelBar->get(); double windowSize = windowSizeBar->get(); decimal rate = 255.0 / windowSize; decimal offset = windowLevel - windowSize / 2; imageInterface< pixelLuminance<int16> > * img = & doc->originalImages[doc->currentViewImageIndex]; switch ( view->mode & trackView::baseImageMask ) { case trackView::original: break; case trackView::vertEdge: img = & doc->verticalEdgeImages[doc->currentViewImageIndex]; break; case trackView::horzEdge: img = & doc->horizontalEdgeImages[doc->currentViewImageIndex]; break; default: offset = 0; rate = 0; break; } viewImage.create( img->width, img->height ); pixel p( 0, 0, 0, 255 ); if ( rate ) { for ( int y = 0; y < img->height; ++y ) { for ( int x = 0; x < img->width; ++x ) { p.r = p.g = p.b = static_cast<int8>( clamp<decimal>( 0, ( img->getInternal( x, y ).y - offset ) * rate, 255.0 ) ); viewImage.setInternal( x, y, p ); } } } else { for ( int y = 0; y < img->height; ++y ) { for ( int x = 0; x < img->width; ++x ) { viewImage.setInternal( x, y, p ); } } } //波の表示用の色 pixel colorV( 0, 0, 255, 255 ); pixel colorH( 0, 255, 0, 255 ); pixel colorA( 255, 255, 0, 255 ); pixel colorD( 255, 0, 255, 255 ); //論文投稿用の表示 if ( false && ( ( view->mode & trackView::baseImageMask ) == trackView::none ) ) { p.r = p.g = p.b = 0; for ( int y = 0; y < img->height; ++y ) { for ( int x = 0; x < img->width; ++x ) { viewImage.setInternal( x, y, p ); } } for ( int t = 0; t < doc->sizeTime(); ++t ) { pixel c; if ( view->mode & trackView::vertical ) { for ( array< list<link> >::iterator ita( doc->verticalLinks ); ita; ++ita ) { for ( list<link>::iterator it( ita() ); it; ++it ) { c.r = c.g = c.b = clamp<int>( 0, it->reliability * 255, 255 ); int x = it->cx * doc->wave[t] + it->bx; int y = it->cy * doc->wave[t] + it->by; viewImage.set( x, y, blendMax( viewImage.get( x, y ), c ) ); } } } if ( view->mode & trackView::horizontal ) { for ( array< list<link> >::iterator ita( doc->horizontalLinks ); ita; ++ita ) { for ( list<link>::iterator it( ita() ); it; ++it ) { c.r = c.g = c.b = clamp<int>( 0, it->reliability * 255, 255 ); int x = it->cx * doc->wave[t] + it->bx; int y = it->cy * doc->wave[t] + it->by; viewImage.set( x, y, blendMax( viewImage.get( x, y ), c ) ); } } } if ( view->mode & trackView::ascent ) { for ( array< list<link> >::iterator ita( doc->ascentLinks ); ita; ++ita ) { for ( list<link>::iterator it( ita() ); it; ++it ) { c.r = c.g = c.b = clamp<int>( 0, it->reliability * 255, 255 ); int x = it->cx * doc->wave[t] + it->bx; int y = it->cy * doc->wave[t] + it->by; viewImage.set( x, y, blendMax( viewImage.get( x, y ), c ) ); } } } if ( view->mode & trackView::descent ) { for ( array< list<link> >::iterator ita( doc->descentLinks ); ita; ++ita ) { for ( list<link>::iterator it( ita() ); it; ++it ) { c.r = c.g = c.b = clamp<int>( 0, it->reliability * 255, 255 ); int x = it->cx * doc->wave[t] + it->bx; int y = it->cy * doc->wave[t] + it->by; viewImage.set( x, y, blendMax( viewImage.get( x, y ), c ) ); } } } } } else if ( view->mode != trackView::original ) { /* if ( view->mode & trackView::vertical ) { checkMaximum<double> mx; for ( array< list<link> >::iterator ita( doc->verticalLinks ); ita; ++ita ) { for ( list<link>::iterator it( ita() ); it; ++it ) { mx( it->intensity ); } } for ( array< list<link> >::iterator ita( doc->verticalLinks ); ita; ++ita ) { for ( list<link>::iterator it( ita() ); it; ++it ) { pixel c = colorV; c.a = clamp<int>( 0, c.a * it->intensity / mx(), 255 ); int x = it->cx * doc->wave[doc->currentViewImageIndex] + it->bx; int y = it->cy * doc->wave[doc->currentViewImageIndex] + it->by; viewImage.set( x, y, blend( viewImage.get( x, y ), c ) ); } } } if ( view->mode & trackView::horizontal ) { checkMaximum<double> mx; for ( array< list<link> >::iterator ita( doc->horizontalLinks ); ita; ++ita ) { for ( list<link>::iterator it( ita() ); it; ++it ) { mx( it->intensity ); } } for ( array< list<link> >::iterator ita( doc->horizontalLinks ); ita; ++ita ) { for ( list<link>::iterator it( ita() ); it; ++it ) { pixel c = colorH; c.a = clamp<int>( 0, c.a * it->intensity / mx(), 255 ); int x = it->cx * doc->wave[doc->currentViewImageIndex] + it->bx; int y = it->cy * doc->wave[doc->currentViewImageIndex] + it->by; viewImage.set( x, y, blend( viewImage.get( x, y ), c ) ); } } } if ( view->mode & trackView::ascent ) { checkMaximum<double> mx; for ( array< list<link> >::iterator ita( doc->ascentLinks ); ita; ++ita ) { for ( list<link>::iterator it( ita() ); it; ++it ) { mx( it->intensity ); } } for ( array< list<link> >::iterator ita( doc->ascentLinks ); ita; ++ita ) { for ( list<link>::iterator it( ita() ); it; ++it ) { pixel c = colorA; c.a = clamp<int>( 0, c.a * it->intensity / mx(), 255 ); int x = it->cx * doc->wave[doc->currentViewImageIndex] + it->bx; int y = it->cy * doc->wave[doc->currentViewImageIndex] + it->by; viewImage.set( x, y, blend( viewImage.get( x, y ), c ) ); } } } if ( view->mode & trackView::descent ) { checkMaximum<double> mx; for ( array< list<link> >::iterator ita( doc->descentLinks ); ita; ++ita ) { for ( list<link>::iterator it( ita() ); it; ++it ) { mx( it->intensity ); } } for ( array< list<link> >::iterator ita( doc->descentLinks ); ita; ++ita ) { for ( list<link>::iterator it( ita() ); it; ++it ) { pixel c = colorD; c.a = clamp<int>( 0, c.a * it->intensity / mx(), 255 ); int x = it->cx * doc->wave[doc->currentViewImageIndex] + it->bx; int y = it->cy * doc->wave[doc->currentViewImageIndex] + it->by; viewImage.set( x, y, blend( viewImage.get( x, y ), c ) ); } } } */ if ( view->mode & trackView::vertical ) { for ( array< list<link> >::iterator ita( doc->verticalLinks ); ita; ++ita ) { for ( list<link>::iterator it( ita() ); it; ++it ) { pixel c = colorV; c.a = clamp<int>( 0, c.a * it->reliability, 255 ); int x = it->cx * doc->wave[doc->currentViewImageIndex] + it->bx; int y = it->cy * doc->wave[doc->currentViewImageIndex] + it->by; viewImage.set( x, y, blend( viewImage.get( x, y ), c ) ); } } } if ( view->mode & trackView::horizontal ) { for ( array< list<link> >::iterator ita( doc->horizontalLinks ); ita; ++ita ) { for ( list<link>::iterator it( ita() ); it; ++it ) { pixel c = colorH; c.a = clamp<int>( 0, c.a * it->reliability, 255 ); int x = it->cx * doc->wave[doc->currentViewImageIndex] + it->bx; int y = it->cy * doc->wave[doc->currentViewImageIndex] + it->by; viewImage.set( x, y, blend( viewImage.get( x, y ), c ) ); } } } if ( view->mode & trackView::ascent ) { for ( array< list<link> >::iterator ita( doc->ascentLinks ); ita; ++ita ) { for ( list<link>::iterator it( ita() ); it; ++it ) { pixel c = colorA; c.a = clamp<int>( 0, c.a * it->reliability, 255 ); int x = it->cx * doc->wave[doc->currentViewImageIndex] + it->bx; int y = it->cy * doc->wave[doc->currentViewImageIndex] + it->by; viewImage.set( x, y, blend( viewImage.get( x, y ), c ) ); } } } if ( view->mode & trackView::descent ) { for ( array< list<link> >::iterator ita( doc->descentLinks ); ita; ++ita ) { for ( list<link>::iterator it( ita() ); it; ++it ) { pixel c = colorD; c.a = clamp<int>( 0, c.a * it->reliability, 255 ); int x = it->cx * doc->wave[doc->currentViewImageIndex] + it->bx; int y = it->cy * doc->wave[doc->currentViewImageIndex] + it->by; viewImage.set( x, y, blend( viewImage.get( x, y ), c ) ); } } } } /* for ( int i = 0; i < 4; ++i ) { for ( array2<flicker>::iterator it( doc->flickers[i] ); it; ++it ) { if ( it->value < 0.25 ) continue; pixel c( 0, 255, 0, 255 ); c.a = clamp<int>( 0, c.a * it->value, 128 ); const point2<int> & pos = it->lnk.position( doc->currentViewImageIndex, doc->wave ); int x = pos.x, y = pos.y; viewImage.set( x, y, blend( viewImage.get( x, y ), c ) ); } } */ for ( list< boundaryArea >::iterator it( doc->areas ); it; ++it ) { it->update( doc->currentViewImageIndex ); } list< point2<int> > points; pixel linecolor( 255, 255, 0, 128 ); pixel pointcolor( 0, 255, 0, 255 ); pixel itnitialpointcolor( 0, 0, 255, 255 ); pixel editedpointcolor( 255, 0, 0, 255 ); /* for ( list< boundaryArea >::iterator it( doc->areas ); it; ++it ) { boundaryArea & area = it(); if ( ! area.enable ) continue; pixel areacolor( 0, 0, 0, 64 ); for ( list< boundaryPart >::iterator ita( area.parts ); ita; ++ita ) { areacolor.r = rand() % 256; areacolor.g = rand() % 256; areacolor.b = rand() % 256; areacolor.a = 128; boundaryPart & part = ita(); for ( region<int>::iterator itp( part.shapes[doc->currentViewImageIndex] ); itp; ++itp ) { int x = itp->x; int y = itp->y; viewImage.set( x, y, blend( viewImage.get( x, y ), areacolor ) ); } } } */ for ( list< boundaryArea >::iterator it( doc->areas ); it; ++it ) { //曲線の表示 if ( doc->show_curve ) { for ( list< point2<int> >::iterator itp( it->boundaryCurves[doc->currentViewImageIndex] ); itp; ++itp ) { const point2<int> & p = itp(); int x = p.x; int y = p.y; viewImage.set( x, y, blend( viewImage.get( x, y ), linecolor ) ); } } //制御点の表示 for ( list<boundaryPoint*>::iterator itc( it->controlPoints ); itc; ++itc ) { boundaryPoint & bp = *itc(); const point2<int> & p = bp( doc->currentViewImageIndex ); pixel c; switch ( bp.type( doc->currentViewImageIndex ) ) { case boundaryPointFrame::typeInitial: c = itnitialpointcolor; break; case boundaryPointFrame::typeEdited: c = editedpointcolor; break; case boundaryPointFrame::typeInterpolated: c = pointcolor; break; default: c = pointcolor; break; } for ( int y = p.y - 1; y <= p.y + 1; ++y ) { for ( int x = p.x - 1; x <= p.x + 1; ++x ) { viewImage.set( x, y, blend( viewImage.get( x, y ), c ) ); } } } } paint( viewImage ); }
PotentialValue& PotentialValue::operator=(const PotentialValue& a) { clear() ; for (PotentialValue::Iterator ita(a); ita; ita++) insert(*ita) ; return *this ; }