/////////////// // SetPrompt // /////////////// void PlayerPrompt::SetPrompt( uint playerNum, std::string prompt, SelectionList selections, HotKeyList hotKeys ) { GameUtilities::IGraphicsProvider::TextInfo textInfo; textInfo.contents = "Player " + NumToStr( playerNum ) + ": " + prompt; textInfo.fontSize = 1; textInfo.position.x = 100; textInfo.position.y = 720; textInfo.argb[0] = 255; textInfo.argb[1] = 155; textInfo.argb[2] = 155; textInfo.argb[3] = 155; ServProvider()->GetGraphicsProvider()->SetText( m_promptID, "prompt", textInfo ); std::string selectionStr; uint hotKeyCounter = 0; for( SelectionList::iterator selectionItemItr = selections.begin(); selectionItemItr != selections.end(); ++selectionItemItr ) { std::stringstream s; s << hotKeys[hotKeyCounter++]; selectionStr += s.str() + " - " + *selectionItemItr + " "; } textInfo.contents = selectionStr; textInfo.position.y = 760; textInfo.argb[1] = 255; textInfo.argb[2] = 255; textInfo.argb[3] = 255; ServProvider()->GetGraphicsProvider()->SetText( m_promptID, "selections", textInfo ); }
void AnimationFrame::OnCmd_FollowMarcher(wxCommandEvent& event) { wxTextEntryDialog dialog(this, wxT("Please enter a marcher to follow (or -1 to stop following)\n"), wxT("Follow Marcher"), wxT(""), wxOK | wxCANCEL); if (dialog.ShowModal() == wxID_OK) { wxString value = dialog.GetValue(); auto& labels = mAnimationView->GetShow()->GetPointLabels(); auto which = std::find(labels.begin(), labels.end(), value); if (which == labels.end()) { wxString upper_value = value.Upper(); which = std::find(labels.begin(), labels.end(), upper_value); } if (which == labels.end()) { wxMessageDialog dialog(this, wxT("Could not find marcher"), wxT("Could not find marcher ") + value, wxOK); dialog.ShowModal(); return; } if (mOmniViewCanvas) { mOmniViewCanvas->OnCmd_FollowMarcher(std::distance(labels.begin(), which)); } SelectionList sl; sl.insert(std::distance(labels.begin(), which)); mAnimationView->SetSelection(sl); } Refresh(); }
void ListElementWidget::onMouseClick(void) { SelectionList *list = dynamic_cast<SelectionList*>(parent); if(list) { list->childWasClicked(this); } }
void WorkspacePanel::OnSelectionChanged(wxTreeEvent& event) { SelectionList list; wxTreeItemId id = event.GetItem(); if(isProject(id)) list.push_back(getProject(id)); else if(isMaterial(id)) list.push_back(getMaterial(id)); else if(isTechnique(id)) list.push_back(getTechnique(id)); else if(isPass(id)) list.push_back(getPass(id)); // else its the workspace so just leave the list empty as if nothing were selected SelectionService::getSingletonPtr()->setSelection(list); }
void DrawSheetPoints(wxDC& dc, const CalChartConfiguration& config, CC_coord origin, const SelectionList& selection_list, unsigned short numberPoints, const std::vector<std::string>& labels, const CC_sheet& sheet, unsigned ref, CalChartColors unselectedColor, CalChartColors selectedColor, CalChartColors unselectedTextColor, CalChartColors selectedTextColor) { SaveAndRestore_Font orig_font(dc); wxFont *pointLabelFont = wxTheFontList->FindOrCreateFont((int)Float2Coord(config.Get_DotRatio() * config.Get_NumRatio()), wxSWISS, wxNORMAL, wxNORMAL); dc.SetFont(*pointLabelFont); dc.SetTextForeground(config.Get_CalChartBrushAndPen(COLOR_POINT_TEXT).first.GetColour()); for (size_t i = 0; i < numberPoints; i++) { wxBrush fillBrush; if (selection_list.count(i)) { auto brushAndPen = config.Get_CalChartBrushAndPen(selectedColor); fillBrush = brushAndPen.first; dc.SetBrush(brushAndPen.first); dc.SetPen(brushAndPen.second); dc.SetTextForeground(config.Get_CalChartBrushAndPen(selectedTextColor).second.GetColour()); } else { auto brushAndPen = config.Get_CalChartBrushAndPen(unselectedColor); fillBrush = brushAndPen.first; dc.SetBrush(brushAndPen.first); dc.SetPen(brushAndPen.second); dc.SetTextForeground(config.Get_CalChartBrushAndPen(unselectedTextColor).second.GetColour()); } DrawPoint(dc, config, sheet.GetPoint(i), ref, origin, labels.at(i)); } }
void TimeTaggerDialog::unTag_action() { if (this==NULL) return; SelectionList listForRemoval; int i=findSelection(0,SELECTION_OUTSIDE); if (i>=0) { while (i>=0) { listForRemoval.append(Selection(tags[i].first,tags[i].second)); tags.removeAt(i); i--; i=findSelection(i+1,SELECTION_OUTSIDE); } } else { QTextCursor c=text->textCursor(); int start=c.selectionStart(); int end=c.selectionEnd(); int i=findSelection(0,SELECTION_OUTSIDEOVERLAP); if (i>=0) { listForRemoval.append(Selection(start,end-1)); } while (i>=0) { if (tags[i].first>=start) { tags[i].first=end; } else { tags[i].second=start-1; } if (tags[i].first==tags[i].second) { tags.removeAt(i); i--; } i=findSelection(i+1,SELECTION_OUTSIDEOVERLAP); } } QTextCursor c=text->textCursor(); for (int i=0;i<listForRemoval.size();i++) { c.setPosition(listForRemoval[i].first,QTextCursor::MoveAnchor); c.setPosition(listForRemoval[i].second+1,QTextCursor::KeepAnchor); text->setTextCursor(c); text->setTextBackgroundColor(Qt::white); text->setTextColor(Qt::black); text->setTextCursor(c); } c.clearSelection(); text->setTextCursor(c); }
void AnalysisTemplate::writeOutput() { // We print out the average of the mean distances for each group. for (size_t g = 0; g < sel_.size(); ++g) { fprintf(stderr, "Average mean distance for '%s': %.3f nm\n", sel_[g].name(), avem_->average(0, g)); } }
void SelectionTester::printSelections() { fprintf(stderr, "\nSelections:\n"); for (size_t g = 0; g < selections_.size(); ++g) { selections_[g].printDebugInfo(stderr, nmaxind_); } fprintf(stderr, "\n"); }
void AbstractTwoLevelAgreement::overLapNamesFinished(const SelectionList & tagWords, const SelectionList & outputWords,int &numWords) { if (tagWords.size()==0 && outputWords.size()==0 ) return; bool underComputation=(&numWords==&underNumWords); int countCommon=commonWords(text,tagWords,outputWords); //not working correctly on maximal boundaries int countCorrect=countWords(text,tagWords); int countDetected=countWords(text,outputWords); assert (countCorrect!=0); assert (countDetected!=0); numWords+=countCorrect; double recall=(double)countCommon/countCorrect * countCorrect, precision=(double)countCommon/countDetected *countCorrect; if (countDetected==0) precision=0; if (underComputation) { underBoundaryRecallList.append(recall); underBoundaryPrecisionList.append(precision); } else { boundaryRecallList.append(recall); boundaryPrecisionList.append(precision); } }
void Angle::checkSelections(const SelectionList &sel1, const SelectionList &sel2) const { if (natoms2_ > 0 && sel1.size() != sel2.size()) { GMX_THROW(InconsistentInputError( "-group1 and -group2 should specify the same number of selections")); } for (size_t g = 0; g < sel1.size(); ++g) { int na1 = sel1[g].posCount(); int na2 = (natoms2_ > 0) ? sel2[g].posCount() : 0; if (natoms1_ > 1 && na1 % natoms1_ != 0) { GMX_THROW(InconsistentInputError(formatString( "Number of positions in selection %d in the first group not divisible by %d", static_cast<int>(g + 1), natoms1_))); } if (natoms2_ > 1 && na2 % natoms2_ != 0) { GMX_THROW(InconsistentInputError(formatString( "Number of positions in selection %d in the second group not divisible by %d", static_cast<int>(g + 1), natoms2_))); } if (natoms1_ > 0 && natoms2_ > 1 && na1 / natoms1_ != na2 / natoms2_) { GMX_THROW(InconsistentInputError( "Number of vectors defined by the two groups are not the same")); } if (g2type_[0] == 's' && sel2[g].posCount() != 1) { GMX_THROW(InconsistentInputError( "The second group should contain a single position with -g2 sphnorm")); } } }
void SelectionTester::analyzeFrame(int /*frnr*/, const t_trxframe & /*fr*/, t_pbc * /*pbc*/, TrajectoryAnalysisModuleData * /*pdata*/) { fprintf(stderr, "\n"); for (size_t g = 0; g < selections_.size(); ++g) { const Selection &sel = selections_[g]; int n; fprintf(stderr, " Atoms (%d pcs):", sel.atomCount()); n = sel.atomCount(); if (nmaxind_ >= 0 && n > nmaxind_) { n = nmaxind_; } ConstArrayRef<int> atoms = sel.atomIndices(); for (int i = 0; i < n; ++i) { fprintf(stderr, " %d", atoms[i]+1); } if (n < sel.atomCount()) { fprintf(stderr, " ..."); } fprintf(stderr, "\n"); fprintf(stderr, " Positions (%d pcs):\n", sel.posCount()); n = sel.posCount(); if (nmaxind_ >= 0 && n > nmaxind_) { n = nmaxind_; } for (int i = 0; i < n; ++i) { const SelectionPosition &p = sel.position(i); fprintf(stderr, " (%.2f,%.2f,%.2f) r=%d, m=%d, n=%d\n", p.x()[XX], p.x()[YY], p.x()[ZZ], p.refId(), p.mappedId(), p.atomCount()); } if (n < sel.posCount()) { fprintf(stderr, " ...\n"); } } fprintf(stderr, "\n"); }
SelectionList TrajectoryAnalysisModuleData::parallelSelections(const SelectionList &selections) { // TODO: Consider an implementation that does not allocate memory every time. SelectionList newSelections; newSelections.reserve(selections.size()); SelectionList::const_iterator i = selections.begin(); for (; i != selections.end(); ++i) { newSelections.push_back(parallelSelection(*i)); } return newSelections; }
void AnalysisTemplate::initAnalysis(const TrajectoryAnalysisSettings &settings, const TopologyInformation & /*top*/) { nb_.setCutoff(cutoff_); data_.setColumnCount(0, sel_.size()); avem_.reset(new AnalysisDataAverageModule()); data_.addModule(avem_); if (!fnDist_.empty()) { AnalysisDataPlotModulePointer plotm( new AnalysisDataPlotModule(settings.plotSettings())); plotm->setFileName(fnDist_); plotm->setTitle("Average distance"); plotm->setXAxisIsTime(); plotm->setYLabel("Distance (nm)"); data_.addModule(plotm); } }
void AnalysisTemplate::analyzeFrame(int frnr, const t_trxframe &fr, t_pbc *pbc, TrajectoryAnalysisModuleData *pdata) { AnalysisDataHandle dh = pdata->dataHandle(data_); const Selection &refsel = pdata->parallelSelection(refsel_); AnalysisNeighborhoodSearch nbsearch = nb_.initSearch(pbc, refsel); dh.startFrame(frnr, fr.time); for (size_t g = 0; g < sel_.size(); ++g) { const Selection &sel = pdata->parallelSelection(sel_[g]); int nr = sel.posCount(); real frave = 0.0; for (int i = 0; i < nr; ++i) { SelectionPosition p = sel.position(i); frave += nbsearch.minimumDistance(p.x()); } frave /= nr; dh.setPoint(g, frave); } dh.finishFrame(); }
void PropertiesPanel::selectionChanged(EventArgs& args) { SelectionEventArgs sea = dynamic_cast<SelectionEventArgs&>(args); SelectionList selection = sea.getSelection(); if(!selection.empty()) { boost::any sel = selection.front(); if(sel.type() == typeid(Project)) { } else if(sel.type() == typeid(MaterialController*)) { MaterialController* mc = any_cast<MaterialController*>(sel); MaterialPageIndexMap::iterator it = mMaterialPageIndexMap.find(mc); if(it != mMaterialPageIndexMap.end()) { int index = mMaterialPageIndexMap[mc]; mPropertyGrid->SelectPage(index); } else { MaterialPropertyGridPage* page = new MaterialPropertyGridPage(mc); int index = mPropertyGrid->AddPage(wxEmptyString, wxPG_NULL_BITMAP, page); page->populate(); mMaterialPageIndexMap[mc] = index; mPropertyGrid->SelectPage(index); } } else if(sel.type() == typeid(TechniqueController*)) { TechniqueController* tc = any_cast<TechniqueController*>(sel); TechniquePageIndexMap::iterator it = mTechniquePageIndexMap.find(tc); if(it != mTechniquePageIndexMap.end()) { int index = mTechniquePageIndexMap[tc]; mPropertyGrid->SelectPage(index); } else { TechniquePropertyGridPage* page = new TechniquePropertyGridPage(tc); int index = mPropertyGrid->AddPage(wxEmptyString, wxPG_NULL_BITMAP, page); page->populate(); mTechniquePageIndexMap[tc] = index; mPropertyGrid->SelectPage(index); } } else if(sel.type() == typeid(PassController*)) { PassController* pc = any_cast<PassController*>(sel); PassPageIndexMap::iterator it = mPassPageIndexMap.find(pc); if(it != mPassPageIndexMap.end()) { int index = mPassPageIndexMap[pc]; mPropertyGrid->SelectPage(index); } else { PassPropertyGridPage* page = new PassPropertyGridPage(pc); int index = mPropertyGrid->AddPage(wxEmptyString, wxPG_NULL_BITMAP, page); page->populate(); mPassPageIndexMap[pc] = index; mPropertyGrid->SelectPage(index); } } mPropertyGrid->Refresh(); } }
void AbstractTwoLevelAgreement::overLapMainFinished(int i,int j,const SelectionList & tagNames, const SelectionList & outputNames,int &numNames) { bool underComputation=(&numNames==&underNumNames); assert(underComputation || (i<0 && j<0 )); //if in max-boundary, i and j have no significance QSet<int> visitedTags; int allCommonCount; int countCommon=commonNames(tagNames,outputNames,visitedTags,allCommonCount); int countCorrect=tagNames.size(); int countDetected=outputNames.size(); assert (countCommon<=countDetected); if (countCorrect>0) { numNames+=countCorrect; double recall=(double)countCommon/countCorrect * countCorrect, precision=(double)countCommon/countDetected *countCorrect; if (countDetected==0) precision=0; if (underComputation) { underNameRecallList.append(recall); underNamePrecisionList.append(precision); } else { nameRecallList.append(recall); namePrecisionList.append(precision); } int k=0,h=0; QList<int> common_k,common_h; SelectionList tagWords, outputWords; while (k<tagNames.size() && h<outputNames.size()) { int start1=tagNames[k].first,end1=tagNames[k].second, start2=outputNames[h].first,end2=outputNames[h].second; if (overLaps(start1,end1,start2,end2) && start1!=end2) { bool foundK=common_k.contains(k), foundH=common_h.contains(h); if (underComputation) startNamesOverLap(i,j,k,h,countCommon); if (!foundK /*&& !foundJ*/) {//so that merged parts will not be double counted common_k.append(k); tagWords.append(tagNames[k]); if (foundH) { //new correctnode that matches detected if (underComputation) anotherTagOverLapPreviousOutputName(i,j,k,h); } } if (!foundH) {//common_i and common_j now are not same size, bc recall and precision need different treatment for overlap common_h.append(h); outputWords.append(outputNames[h]); if (foundK) { //new detectednode that matches correct if (underComputation) anotherOutputOverLapPreviousTagName(i,j,k,h); } } if (!foundK && !foundH) { if (underComputation) firstNameOverLap(i,j,k,h); } //[underboundary computations SelectionList singleTagWords, singleOutputWords; singleTagWords.append(tagNames[k]); singleOutputWords.append(outputNames[h]); overLapNamesFinished(singleTagWords,singleOutputWords,underNumWords); //] int process=0; if (end1<=end2 ) { k++; process++; } if (end2<=end1) { h++; process++; } if (process==2) { //[max-boundary computations overLapNamesFinished(tagWords,outputWords,numWords); //] tagWords.clear(); outputWords.clear(); } } else if (before(start1,end1,start2,end2)) { if (underComputation) beforeMovingToNextTagName(i,j,k,h); //[max-boundary computations overLapNamesFinished(tagWords,outputWords,numWords); //] tagWords.clear(); outputWords.clear(); k++; } else if (after(start1,end1,start2,end2) ) { if (underComputation) beforeMovingToNextOutputName(i,j,k,h); //[max-boundary computations overLapNamesFinished(tagWords,outputWords,numWords); //] tagWords.clear(); outputWords.clear(); h++; } } if (tagWords.size()>0 || outputWords.size()>0) { //[max-boundary computations overLapNamesFinished(tagWords,outputWords,numWords); //] tagWords.clear(); outputWords.clear(); } } else { nameRecallList.append(0); namePrecisionList.append(0); } if (underComputation) { //under computation only if (hadithParameters.detailed_statistics) { theSarf->displayed_error <</*text->mid(start1,end1-start1+1)*/i<<"\t" <</*text->mid(start2,end2-start2+1)*/j<<"\t" <<countCommon<<"/"<<countCorrect<<"\t"<<allCommonCount<<"/"<<countDetected<<"\n"; } } }
int main(int argc,char** argv) { osgViewer::Viewer viewer; osg::Camera* camera = createMasterCamera( 50, 50, 640, 480 ); viewer.setCamera(camera); viewer.addEventHandler(new PickNode); osg::ref_ptr<osg::Group> root = new osg::Group; viewer.setSceneData(root.get()); osgDragger::ShowBound::Instence()->setNodeMask(~0x1); root->addChild(osgDragger::ShowBound::Instence()->getRoot()); osg::ref_ptr<osg::MatrixTransform> scene = new osg::MatrixTransform; root->addChild(scene.get()); scene->setNodeMask(0x1); osg::ref_ptr<osg::Camera> hudCamera = 0; osg::ref_ptr<osgDragger::HudCamera> _hudCamera; osgViewer::Viewer::Windows windows; viewer.getWindows(windows); if (windows.size() != 0) { hudCamera = createHUD(windows[0]); hudCamera->addChild(CustomDraggerManager::Instence()->getRoot()); viewer.addSlave(hudCamera.get(), false); _hudCamera = new osgDragger::HudCamera(hudCamera.get(), 60, 60);//左下角坐标系 } else { CustomDraggerManager::Instence()->getRoot()->getOrCreateStateSet()->setAttributeAndModes(new osgDragger::ClearDepth); CustomDraggerManager::Instence()->getRoot()->getOrCreateStateSet()->setRenderingHint(osg::StateSet::TRANSPARENT_BIN); CustomDraggerManager::Instence()->getRoot()->getOrCreateStateSet()->setMode(GL_NORMALIZE, osg::StateAttribute::ON); root->addChild(CustomDraggerManager::Instence()->getRoot()); _hudCamera = new osgDragger::HudCamera(camera, 60, 60);//左下角坐标系 } osgDragger::MoveDragger* move = new osgDragger::MoveDragger; move->setName("move"); move->setIntersectionMask(0x2); move->setIntersectionCamera(hudCamera.get()); move->setupDefaultGeometry(); move->setHandleEvents(true); CustomDraggerManager::Instence()->addDragger(move, true); CustomDraggerManager::Instence()->setIntersectionMask(0x2); osgDragger::RotateDragger* rotate = new osgDragger::RotateDragger; rotate->setName("rotate"); rotate->setIntersectionMask(0x2); rotate->setIntersectionCamera(hudCamera.get()); rotate->setupDefaultGeometry(); rotate->setHandleEvents(true); CustomDraggerManager::Instence()->addDragger(rotate, false); CustomDraggerManager::Instence()->setIntersectionMask(0x2); osg::ref_ptr<osg::Geode> geode = new osg::Geode; geode->addDrawable(new osg::ShapeDrawable(new osg::Box(osg::Vec3(), 5.0f))); SelectionList sl; { osg::ref_ptr<osg::MatrixTransform> mt = new osg::MatrixTransform; mt->setName("mt"); mt->addChild(geode.get()); sl.push_back(mt.get()); scene->addChild(mt.get()); } { osg::ref_ptr<osg::MatrixTransform> mt = new osg::MatrixTransform; mt->setName("mt"); mt->setMatrix(osg::Matrix::translate(osg::Vec3(20,0,0))); mt->addChild(geode.get()); scene->addChild(mt.get()); } CustomDraggerManager::Instence()->setSelections(sl); viewer.setCameraManipulator(new osgGA::TrackballManipulator); while (!viewer.done()) { viewer.frame(); } return 0; }