FinishedManager::~FinishedManager() { QueueManager::getInstance()->removeListener(this); UploadManager::getInstance()->removeListener(this); Lock l(cs); for_each(downloads.begin(), downloads.end(), DeleteFunction()); for_each(uploads.begin(), uploads.end(), DeleteFunction()); }
void CPhylogenView::OnLButtonDblClk(UINT nFlags, CPoint point) { CScrollView::OnLButtonDblClk(nFlags, point); // TODO: Add your message handler code here and/or call default CPhyloGenBase * pPGB; int Flag = 0; POSITION Pos; CGenedocDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); if ( pDoc->m_pPGBase != NULL ) { CPhyloNode *pPNDoc = pDoc->m_pPGBase; Pos = pPNDoc->m_PhyloList.GetHeadPosition(); while ( Pos != NULL ) { pPGB = (CPhyloGenBase *)pPNDoc->m_PhyloList.GetNext(Pos); if ( pPGB->m_FirstSelection == 1 ) { Flag++; } } if ( Flag == 1) { DeleteFunction(); } else if ( Flag == 2 ) { CreateFunction(); } else { OnUpdate( NULL, 0, NULL ); } } }
void CAGEmotionSetup::cleanup() { for_each(EmotionsList.begin(), EmotionsList.end(), DeleteFunction()); EmotionsList.clear(); m_images.Destroy(); m_CountSelEmotions = 0; m_FilterEmotiion.clear(); }
void FinishedManager::removeAll(bool upload /* = false */) { { Lock l(cs); FinishedItemList *listptr = upload ? &uploads : &downloads; for_each(listptr->begin(), listptr->end(), DeleteFunction()); listptr->clear(); } }
void FinishedManager::removeAll() { { Lock l(cs); FinishedItemList *listptr = &uploads; for_each(listptr->begin(), listptr->end(), DeleteFunction()); listptr->clear(); } }
bool operator()(const DirectoryListing::Directory::Ptr i) const { const bool r = i->getFileCount() + i->directories.size() == 0; if (r) { DeleteFunction()(i); } return r; }
void FinishedManager::removeAll(bool upload /* = false */) { //fire before the items are removed to make sure the gui can clear the list if (!upload) fire(FinishedManagerListener::RemovedAllDl()); else fire(FinishedManagerListener::RemovedAllUl()); { Lock l(cs); FinishedItem::List *listptr = upload ? &uploads : &downloads; for_each(listptr->begin(), listptr->end(), DeleteFunction()); listptr->clear(); } }
DirectoryListing::Directory::~Directory() { if (m_directory_list && m_virus_detect.is_virus_dir()) { CFlyVirusFileList l_file_list; l_file_list.m_virus_path = m_directory_list->getPath(this); l_file_list.m_hub_url = m_directory_list->getHintedUser().hint; l_file_list.m_nick = m_directory_list->getUser()->getLastNick(); l_file_list.m_ip = m_directory_list->getUser()->getIPAsString(); l_file_list.m_time = GET_TIME(); for (auto j = m_files.begin(); j != m_files.end(); ++j) { if (CFlyVirusDetector::is_virus_file((*j)->getName(), (*j)->getSize())) { CFlyTTHKey l_key((*j)->getTTH(), (*j)->getSize()); l_file_list.m_files[l_key].push_back((*j)->getName()); } } CFlyServerJSON::addAntivirusCounter(l_file_list); } for_each(directories.begin(), directories.end(), DeleteFunction()); for_each(m_files.begin(), m_files.end(), DeleteFunction()); }
bool operator()(const DirectoryListing::Directory::Ptr i) const { bool r = i->getFileCount() == 0 && i->directories.empty(); if (r) DeleteFunction()(i); return r; }
bool operator()(const DirectoryListing::File::Ptr i) const { return tl.count((i->getTTH())) && (DeleteFunction()(i), true); }
ToolbarManager::~ToolbarManager() throw() { SettingsManager::getInstance()->removeListener(this); for_each(toolbarEntries.begin(), toolbarEntries.end(), DeleteFunction()); }
void WebShortcuts::clear() { for_each(list.begin(), list.end(), DeleteFunction()); list.clear(); }
//----------------------------------------------------------- // Subroutine to translate BMP file into material point //----------------------------------------------------------- void MPMReadHandler::TranslateBMPFiles(void) { unsigned char **rows,**angleRows; BMPInfoHeader info,angleInfo; bool setAngles=FALSE; int numRotations=strlen(rotationAxes); // read image file char *bmpFullPath=archiver->ExpandOutputPath(bmpFileName); ReadBMPFile(bmpFullPath,info,&rows); delete [] bmpFullPath; // angle file name (overrides other angle settings) if(bmpAngleFileName[0]>0) { setAngles=TRUE; char *bmpFullAnglePath=archiver->ExpandOutputPath(bmpAngleFileName); ReadBMPFile(bmpFullAnglePath,angleInfo,&angleRows); if(info.height!=angleInfo.height || info.width!=angleInfo.width) throw SAXException(BMPError("The image file and angle file sizes do not match.",bmpFileName)); delete [] bmpFullAnglePath; } else if(numRotations>0) { int i; for(i=0;i<numRotations;i++) { char *expr=new char[strlen(angleExpr[i])+1]; strcpy(expr,angleExpr[i]); if(!CreateFunction(expr,i+1)) throw SAXException("Invalid angle expression was provided in <RotateX(YZ)> command."); delete [] expr; } } // bheight and bwidth provided in bmp file // <-1.e8 means not provided // negative means provided mm per pixel // positive is a specified size double xpw=-1.,ypw=-1.; if(bwidth<-1.e8 && bheight<-1.e8) { if(!info.knowsCellSize) throw SAXException(BMPError("<BMP> must specify width and/or height as size or pixels per mm.",bmpFileName)); bwidth = info.width*info.xcell; bheight = info.height*info.ycell; xpw = info.xcell; ypw = info.ycell; } else { // provided mm per pixel if(bheight<0. && bheight>-1.e8) { ypw = -bheight; bheight = ypw*(double)info.height; } if(bwidth<0. && bwidth>-1.e8) { xpw = -bwidth; bwidth = xpw*(double)info.width; } } // total dimensions (if only one is known, find the other, never have both unknown) if(bheight<0) bheight=bwidth*(double)info.height/(double)info.width; if(bwidth<0) bwidth=bheight*(double)info.width/(double)info.height; // final mm per pixel (if needed) if(xpw<0.) xpw=bwidth/(double)info.width; if(ypw<0.) ypw=bheight/(double)info.height; // variables for scanning BMP file int matID; MPMBase *newMpt; int ii,k; Vector mpos[MaxElParticles]; int ptFlag; BMPLevel *nextLevel; double deltax,deltay,deltaz,semiscale; double rmin,rmax,wtr1,wtr2,rweight; double cmin,cmax,wtc1,wtc2,weight; int r1,r2,c1,c2; BMPLevel *maxLevel; int row,col; ElementBase *elem; // Length/semiscale is half particle with // (semiscale=4 for 2D w 4 pts per element or 3D with 8 pts per element, // or 2 if 1 particle in the element) if(fmobj->IsThreeD()) semiscale=2.*pow((double)fmobj->ptsPerElement,1./3.); else semiscale=2.*sqrt((double)fmobj->ptsPerElement); /* Parallelizing the following loop will speed up check meshes on Mac 1. Will need copy of levels for each block (or pass copy of weight to BMPLevel methods) see BMPLevel methods: ClearWeight(),Material(double,double), MaximumWeight(double) 2. mpCtrl->AddMaterialPoint() will need critical block 3. FunctionValue() when setting angles uses globals they are problem for parallel */ // scan mesh and assign material points or angles try { for(ii=1;ii<=nelems;ii++) { // skip if image not in extent of element box elem=theElements[ii-1]; if(!elem->IntersectsBox(xorig,yorig,bwidth,bheight,zslice)) continue; // load point coordinates elem->MPMPoints(fmobj->ptsPerElement,mpos); // half the extent of the volume of a particle deltax=(elem->GetDeltaX())/semiscale; deltay=(elem->GetDeltaY())/semiscale; if(fmobj->IsThreeD()) deltaz=elem->GetDeltaZ()/semiscale; else deltaz=1.; if(deltaz<0.) deltaz=1.; for(k=0;k<fmobj->ptsPerElement;k++) { ptFlag=1<<k; // skip if already filled if(elem->filled&ptFlag) continue; // if point in the view area, then check it if((mpos[k].x>=xorig && mpos[k].x<xorig+bwidth) && (mpos[k].y>=yorig && mpos[k].y<yorig+bheight) && (mpos[k].z>=zslice-deltaz && mpos[k].z<zslice+deltaz)) { // find range of rows and cols for pixels over this material point if(yflipped) { rmin=(yorig+bheight-mpos[k].y-deltay)/ypw; rmax=(yorig+bheight-mpos[k].y-deltay)/ypw; } else { rmin=(mpos[k].y-deltay-yorig)/ypw; rmax=(mpos[k].y+deltay-yorig)/ypw; } r1=BMPIndex(rmin,info.height); r2=BMPIndex(rmax,info.height); if(r2==r1) { wtr1=wtr2=1.; } else { // fractional weight for first and last row in case not all within the extent wtr1=(double)(r1+1)-rmin; wtr2=rmax-(double)r2; } cmin=(mpos[k].x-deltax-xorig)/xpw; cmax=(mpos[k].x+deltax-xorig)/xpw; c1=BMPIndex(cmin,info.width); c2=BMPIndex(cmax,info.width); if(c2==c1) { wtc1=wtc2=1.; } else { // fractional weight for first and last col in case not all within the extent wtc1=(double)(c1+1)-cmin; wtc2=cmax-(double)c2; } // find material ID or none (a hole) // clear material weights nextLevel=firstLevel; while(nextLevel!=NULL) nextLevel=nextLevel->ClearWeight(); // add weights for(row=r1;row<=r2;row++) { if(row==r1) rweight=wtr1; else if(row==r2) rweight=wtr2; else rweight=1.; for(col=c1;col<=c2;col++) { if(col==c1) weight=rweight*wtc1; else if(col==c2) weight=rweight*wtc2; else weight=rweight; // find material at this level // (note: last level with matID=0 catches empty space) nextLevel=firstLevel; while(nextLevel!=NULL) { matID=nextLevel->Material(rows[row][col],weight); if(matID>=0) break; nextLevel=(BMPLevel *)nextLevel->GetNextObject(); } } } // find maximum weight (matID=0 means max is empty space) weight=0.; maxLevel=NULL; nextLevel=firstLevel; while(nextLevel!=NULL) nextLevel=nextLevel->MaximumWeight(weight,&maxLevel); if(maxLevel!=NULL) { matID=maxLevel->mat; nextLevel=maxLevel; } else matID=-1; // create a material point if one at this spot using matID and nextLevel // Note that empty spaced is not marked as filled which allows superposition of // images with different materials. If want to forcefully create a hole that // cannot be filled by subsequent image, will need to define a new material // type that can have matID for a hole. It will not create a point, but will mark // the location as filled if(matID>0) { if(fmobj->IsThreeD()) newMpt=new MatPoint3D(ii,matID,nextLevel->angle); else if(fmobj->IsAxisymmetric()) newMpt=new MatPointAS(ii,matID,nextLevel->angle,mpos[k].x); else newMpt=new MatPoint2D(ii,matID,nextLevel->angle,nextLevel->thickness); newMpt->SetPosition(&mpos[k]); newMpt->SetOrigin(&mpos[k]); newMpt->SetVelocity(&nextLevel->vel); mpCtrl->AddMaterialPoint(newMpt,nextLevel->concentration,nextLevel->temperature); // is there an angle image? if(setAngles) { // weight average of scanned pixels double totalWeight=0.; double totalIntensity=0.; for(row=r1;row<=r2;row++) { if(row==r1) rweight=wtr1; else if(row==r2) rweight=wtr2; else rweight=1.; for(col=c1;col<=c2;col++) { if(col==c1) weight=rweight*wtc1; else if(col==c2) weight=rweight*wtc2; else weight=rweight; totalIntensity+=weight*angleRows[row][col]; totalWeight+=weight; } } totalIntensity/=totalWeight; double matAngle=minAngle+(totalIntensity-minIntensity)*angleScale; newMpt->SetAnglez0InDegrees(matAngle); } else { // If had Rotate commands then use them SetMptAnglesFromFunctions(numRotations,&mpos[k],newMpt); } elem->filled|=ptFlag; } } } } } catch(const char *msg) { throw SAXException(msg); } // clean up for(row=0;row<info.height;row++) { delete [] rows[row]; if(setAngles) delete [] angleRows[row]; } delete [] rows; if(setAngles) delete [] angleRows; // angles if allocated for(ii=0;ii<numRotations;ii++) { delete [] angleExpr[ii]; } DeleteFunction(-1); }
void EmoticonsManager::Unload() { for_each(emoticons.begin(), emoticons.end(), DeleteFunction()); emoticons.clear(); }
void CPhylogenView::OnPhylodelete() { // TODO: Add your command handler code here DeleteFunction(); }
void CPhylogenView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) { // TODO: Add your message handler code here and/or call default CGenedocDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); POSITION Pos; CPhyloGenBase *pPGB; CClientDC dc(this); OnPrepareDC(&dc); int Selection; switch ( nChar ) { case VK_DOWN: if ( !ClearSelected(&Selection) ) Selection = m_LastKeySelect; Selection += 1; if ( Selection >= pDoc->m_pPGBase->m_PhyloList.GetCount() ) Selection = 0; SetSelected(Selection, 1); break; case VK_UP: if ( !ClearSelected(&Selection) ) Selection = m_LastKeySelect; Selection -= 1; if ( Selection < 0 ) Selection = pDoc->m_pPGBase->m_PhyloList.GetCount() - 1; SetSelected(Selection, 1); break; case VK_NEXT: if ( !ClearSelected(&Selection) ) Selection = m_LastKeySelect; Selection += 5; if ( Selection >= pDoc->m_pPGBase->m_PhyloList.GetCount() ) Selection = 0; SetSelected(Selection, 1); break; case VK_PRIOR: if ( !ClearSelected(&Selection) ) Selection = m_LastKeySelect; Selection -= 5; if ( Selection < 0 ) Selection = pDoc->m_pPGBase->m_PhyloList.GetCount() - 1; SetSelected(Selection, 1); break; case VK_HOME: if ( !ClearSelected(&Selection) ) Selection = m_LastKeySelect; Selection = 0; SetSelected(Selection, 1); break; case VK_END: if ( !ClearSelected(&Selection) ) Selection = m_LastKeySelect; Selection = pDoc->m_pPGBase->m_PhyloList.GetCount() - 1; SetSelected(Selection, 1); break; case VK_RETURN: Selection = 0; Pos = pDoc->m_pPGBase->m_PhyloList.GetHeadPosition(); while ( Pos != NULL ) { CPhyloGenBase * pPGB = (CPhyloGenBase *)pDoc->m_pPGBase->m_PhyloList.GetNext(Pos); if ( pPGB->m_Selected == 1 ) break; Selection++; } Pos = pDoc->m_pPGBase->m_PhyloList.GetHeadPosition(); while ( Pos != NULL ) { pPGB = (CPhyloGenBase *)pDoc->m_pPGBase->m_PhyloList.GetNext(Pos); if ( pPGB->m_Selected ) { pPGB->m_FirstSelection = 1; break; } } CreateFunction(); SetSelected(Selection, 0 ); break; case VK_SHIFT: case VK_SPACE: SelectFunction(); break; case VK_DELETE: Selection = 0; Pos = pDoc->m_pPGBase->m_PhyloList.GetHeadPosition(); while ( Pos != NULL ) { CPhyloGenBase * pPGB = (CPhyloGenBase *)pDoc->m_pPGBase->m_PhyloList.GetNext(Pos); if ( pPGB->m_Selected == 1 ) break; Selection++; } DeleteFunction(); SetSelected(Selection, 0 ); break; case VK_ESCAPE: Pos = pDoc->m_pPGBase->m_PhyloList.GetHeadPosition(); while ( Pos != NULL ) { pPGB = (CPhyloGenBase *)pDoc->m_pPGBase->m_PhyloList.GetNext(Pos); if ( pPGB->m_FirstSelection == 1 ) { pPGB->m_FirstSelection = 0; CRect tRect = pPGB->m_ClientRect; dc.LPtoDP( &tRect ); InvalidateRect( tRect ); } } break; } CScrollView::OnKeyDown(nChar, nRepCnt, nFlags); }
void Facility::AddFunction(int thread, Function* f) { DeleteFunction(thread); function.push_back(std::make_pair(thread, f)); }
// finish start of FEA results file void NairnFEA::MyStartResultsOutput(void) { char hline[200]; int i; //--------------------------------------------------- // Temperature PrintSection("THERMAL LOAD"); if(temperatureExpr!=NULL) { if(!CreateFunction(temperatureExpr)) throw CommonException("The temperature expression is not a valid function","NairnFEA::MyStartResultsOutput"); for(i=1;i<=nnodes;i++) { nd[i]->gTemperature = FunctionValue(1,nd[i]->x,nd[i]->y,0.,0.,0.,0.)-stressFreeTemperature; } DeleteFunction(); } else { // unknown, but may have been set in explicit node commands temperatureExpr=new char[2]; strcpy(temperatureExpr,"?"); } sprintf(hline,"T0: %.2lf C\nT: %s C",stressFreeTemperature,temperatureExpr); cout << hline << endl; if(stressFreeTemperature!=0) { sprintf(hline,"T-T0: %s - %.2lf C",temperatureExpr,stressFreeTemperature); cout << hline << endl; } cout << endl; //--------------------------------------------------- // Fixed Displacements if(firstDispBC!=NULL) { PrintSection("NODAL POINTS WITH FIXED DISPLACEMENTS"); cout << " Node DOF Displacement (mm) Axis Angle\n" << "----------------------------------------------------\n"; NodalDispBC *nextBC=firstDispBC; while(nextBC!=NULL) nextBC=nextBC->PrintBC(cout); cout << endl; } //--------------------------------------------------- // Loaded Nodes if(firstLoadBC!=NULL) { PrintSection("NODAL POINTS WITH APPLIED LOADS"); cout << " Node DOF Load (N)\n" << "------------------------------\n"; NodalLoad *nextLoad=firstLoadBC; while(nextLoad!=NULL) nextLoad=nextLoad->PrintLoad(); cout << endl; } //--------------------------------------------------- // Stress element faces if(firstEdgeBC!=NULL) { PrintSection("FACES WITH APPLIED STRESS (MPa)"); cout << " Elem Fc Type Nodal Stress Nodal Stress Nodal Stress\n" << "----------------------------------------------------------------------\n"; EdgeBC *nextEdge=firstEdgeBC; while(nextEdge!=NULL) nextEdge=nextEdge->PrintEdgeLoad(); cout << endl; } //--------------------------------------------------- // Periodic directions if(periodic.dof) { PrintSection("PERIODIC DIRECTIONS"); // x periodic, but y not (not allowed for axisymmetric) if(fmobj->periodic.dof==1) { sprintf(hline,"x direction from %g to %g mm",periodic.xmin,periodic.xmax); cout << hline << endl; if(periodic.fixDu) { sprintf(hline," Displacement jump fixed at %g mm for exx = %g",periodic.du,periodic.du/(periodic.xmax-periodic.xmin)); cout << hline << endl; } if(periodic.fixDudy) { sprintf(hline," Displacement jump slope fixed at %g",periodic.dudy); cout << hline << endl; } } // y periodic, but x not (only option for axisymmetrix - z periodic, but r not) else if(fmobj->periodic.dof==2) { char pax = fmobj->IsAxisymmetric() ? 'z' : 'y' ; sprintf(hline,"%c direction from %g to %g mm",pax,periodic.ymin,periodic.ymax); cout << hline << endl; if(periodic.fixDv) { sprintf(hline," Displacement jump fixed at %g mm for e%c%c = %g",periodic.dv,pax,pax,periodic.dv/(periodic.ymax-periodic.ymin)); cout << hline << endl; } if(periodic.fixDvdx) { sprintf(hline," Displacement jump slope fixed at %g",periodic.dvdx); cout << hline << endl; } } // x and y both periodic (not allowed for axisymmetric) else { sprintf(hline,"x direction from %g to %g mm",periodic.xmin,periodic.xmax); cout << hline << endl; if(periodic.fixDu) { sprintf(hline," Displacement jump fixed at %g mm for exx = %g",periodic.du,periodic.du/(periodic.xmax-periodic.xmin)); cout << hline << endl; } if(periodic.fixDvdx) { sprintf(hline," Displacement jump dv fixed at %g",periodic.dvdx); cout << hline << endl; } sprintf(hline,"y direction from %g to %g mm",periodic.ymin,periodic.ymax); cout << hline << endl; if(periodic.fixDv) { sprintf(hline," Displacement jump fixed at %g mm for eyy = %g",periodic.dv,periodic.dv/(periodic.ymax-periodic.ymin)); cout << hline << endl; } if(periodic.fixDudy) { sprintf(hline," Displacement jump du fixed at %g",periodic.dudy); cout << hline << endl; // if both Dudy and Dvdx then global shear is specified if(periodic.fixDvdx) { double b=periodic.dvdx/(periodic.xmax-periodic.xmin); double d=periodic.dudy/(periodic.ymax-periodic.ymin); sprintf(hline," for gxy = %g and rotation = %g",b+d,(d-b)/2); cout << hline << endl; } } } cout << endl; } }