void CLjz153View::OnPic2() { // TODO: Add your command handler code here CFileDialog pic2( TRUE, _T( ".bmp" ), _T( "test.bmp" ), OFN_FILEMUSTEXIST | OFN_HIDEREADONLY, _T( "图片(bmp)|*.bmp|所有文件|*||" ) ); if ( pic2.DoModal() == IDOK ) { CString path = pic2.GetPathName(); //获取路径 //AfxMessageBox(path); char* name = path.GetBuffer(path.GetLength()); path.ReleaseBuffer(); lpBitsInfo1 = LoadBmpFile(name); Invalidate(); picNum++; } }
int main(int argn, char* args[]) { static char *desc[] = { "This script will read the xtc trajectory from an MD simulation", "performed by GROMACS and output all data related to the analysis", "of preferential interactions.", "[PAR]", "Generated: Thu Aug 20 16:49:21 EDT 2015.[BR]", "Last updated: Thu Aug 27 17:26:01 EDT 2015.", "[PAR]", "Future Developments:[BR]", "[BB]1.[bb] Partition calculation into groups (constituent amino acids).[BR]", "[BB]2.[bb] Calculate residence times.[BR]", "[BB]3.[bb] Include a measure for geometric orientation.[BR]", "[BB]4.[bb] Calculate molecular distributions.[BR]", "[BB]5.[bb] Parallelize it.", "[PAR]", "Remember to check the dependencie of the results on the number of block", " used by using [TT]-block[tt].", "Also, check that your simulation has been properly equilibrated by using [TT]-f0[tt].", "In terms of reducing the computational cost of the analysis, use the option", "[TT]-skip[tt] to only use every nr[TT]-th[tt] frame from the trajectory." }; unsigned int protein_sequence=20; /* parse tpr.itp for info */ unsigned int N_co=4; /* look at topology for number of co-solvents */ unsigned int num_sol=7906; /* look at topology as well */ unsigned int skip_nr=1; unsigned int granularity=2*100; unsigned int f0=0; bool bIndex=false; t_pargs pa[] = { {"-start", FALSE, etINT, {&f0}, "Start after n-th frame."}, {"-skip", FALSE, etINT, {&skip_nr}, "Only write every nr-th frame."}, {"-grid", FALSE, etINT, {&granularity}, "Number points to calculate."}, {"-seq", FALSE, etINT,{&protein_sequence}, "Number of amino acids in protein sequence."}, {"-Nco", FALSE, etINT,{&N_co}, "Number of cosolvent molecules."}, {"-Sol", FALSE, etINT,{&num_sol}, "Number of water molecules."} }; char title[STRLEN]; t_topology top; int ePBC; rvec *xtop; matrix box; t_filenm fnm[] = { /* See filenm.h */ { efTOP, NULL, NULL, ffREAD }, { efTPS, NULL, NULL, ffREAD }, /* topology */ { efTRX, "-f", NULL, ffREAD }, /* trajcetory */ { efNDX, "-n", NULL, ffOPTRD } /* index file */ }; #define NFILE asize(fnm) /* Interface. Adds default options. */ CopyRight(stderr,args[0]); parse_common_args(&argn,args,PCA_CAN_TIME | PCA_CAN_VIEW, NFILE,fnm,asize(pa),pa,asize(desc),desc,0,NULL); read_tps_conf( ftp2fn(efTPS, NFILE, fnm), title, &top, &ePBC, &xtop, NULL, box, TRUE); sfree(xtop); /*******************************************************************************************************************/ /* int iter; for (iter=0;iter<top.atoms.nr/100;++iter) { printf("Atom name: %s\tAtom charge: %f\n", *(top.atoms.atomname[iter]), top.atoms.atom[iter].q ); printf("Atom type: %d\tAtomic Residue NUmber: %d\n", top.atoms.atom[iter].type, top.atoms.atom[iter].resnr ); printf("Chain Identifier: %u\tNr of residues names: %d\n", top.atoms.atom[iter].ptype, top.atoms.nres ); printf("Residue name: %s\n\n", *(top.atoms.resname[iter]) ); } */ /*******************************************************************************************************************/ int status; t_trxframe fr; int flags = TRX_READ_X; /* Count Number of Frames */ unsigned int bframes=0, frames=0; int bwrite; read_first_frame(&status, ftp2fn(efTRX,NFILE,fnm), &fr, flags); do { bwrite = bframes % skip_nr; ++bframes; if ((bframes>f0) && (bwrite==0)){ ++frames; } } while ( read_next_frame(status,&fr) ); /* Preparing Block Analysis */ bIndex = ftp2bSet(efNDX,NFILE,fnm); std::vector<int> blocks_list; if (bIndex) { FILE *fp = ffopen(opt2fn("-n",NFILE,fnm),"r"); int numblock; while(fscanf(fp,"%d",&numblock)!=EOF) { blocks_list.push_back(numblock); } fclose(fp); } else { blocks_list.push_back(1); } /* Actual Calculation */ std::vector<Info> protein; std::vector<Info> cosolvent; std::vector<Info> solvent; std::vector<double> cutoff, coefficients; double molals=0, molars=0; /* BLOCK AVERAGE */ typedef std::vector<double> Row; typedef std::vector<Row> Matrix; unsigned int num_blocks; ///////////// //////////// std::ofstream test_partition("partition.txt"); for (unsigned int iter=0; iter<blocks_list.size(); ++iter) { num_blocks = blocks_list[iter]; unsigned int partition = (frames)/num_blocks; unsigned int frame_counter=0; std::vector<double> positions(granularity), averages(granularity), averages_sqr(granularity), sigma(granularity); Matrix values(num_blocks,Row(granularity)), values_sqr(num_blocks,Row(granularity)); unsigned int frame=0, twrite=0; read_first_frame(&status, ftp2fn(efTRX,NFILE,fnm), &fr, flags); do { twrite = frame % skip_nr; /* if twrite==0 then read frame. */ ++frame; if ((frame > f0) && (twrite==0)) { /* READING */ unsigned int protein_co=protein_sequence+N_co; unsigned int solvated=protein_co+num_sol; for (unsigned int n=0; n<top.atoms.nr; ++n) { /* Parsing */ Info atomo; atomo.setAtom( (std::string) *(top.atoms.atomname[n]) ); atomo.setResnum( (unsigned int) top.atoms.atom[n].resnr ); atomo.setResname( (std::string) *(top.atoms.resname[atomo.getResnum()]) ); atomo.setCoords( (double) fr.x[n][XX], (double) fr.x[n][YY], (double) fr.x[n][ZZ] ); /* Testing for partition of groups */ /////// atomo.print(test_partition); /* Appending */ // if if ( atomo.getAtom()[0]!='H') // atomo.atom[0]!='H') { if ( atomo.getResnum() < protein_sequence ){ protein.push_back(atomo); } else if ( (atomo.getResnum() >= protein_sequence) && (atomo.getResnum() < protein_co) ){ cosolvent.push_back(atomo); } else if ( (atomo.getResnum() >= protein_co) && (atomo.getResnum() < solvated) ){ // if (atomo.getResname().compare("SOL")!=0) // we want to avoid inputing number of waters for analysis solvent.push_back(atomo); } } } /* MAIN */ double box_size = fr.box[0][0]; /* Local calculation for cosolvents */ std::vector<double> close_co; /* Stores Distances of closest */ for (unsigned int i=0; i<N_co; ++i) { std::vector<double> local_co; double minimum_calculated = box_size*box_size; unsigned int Nco_size=cosolvent.size()/N_co; for (unsigned int n=(i*Nco_size); n<((i+1)*Nco_size); ++n) { for (unsigned int j=0; j<protein.size(); ++j) { double dist = cosolvent[n].distance(protein[j],box_size); if (dist < minimum_calculated ){ minimum_calculated = dist; } } local_co.push_back(minimum_calculated); } close_co.push_back( *min_element(local_co.begin(), local_co.end()) ); } /* Local calculation for water */ std::vector<double> local_wat; for (unsigned int i=0; i<solvent.size(); ++i) { double minimum_calculated = box_size*box_size; for (unsigned int j=0; j<protein.size(); ++j) { double dist = solvent[i].distance(protein[j],box_size); if (dist < minimum_calculated){ minimum_calculated = dist; } } local_wat.push_back(minimum_calculated); } /* Preferential Interaction Coefficient */ double N_wat = solvent.size(); linspace(0,box_size,granularity,cutoff); for (unsigned int x=0; x<granularity; ++x) { unsigned int n3=0, n1=0; for (unsigned int i=0; i<close_co.size(); ++i){ if (close_co[i] < (cutoff[x]*cutoff[x])) ++n3; } for (unsigned int i=0; i<local_wat.size(); ++i){ if (local_wat[i] < (cutoff[x]*cutoff[x])) ++n1; } coefficients.push_back(pref_coef(N_co, N_wat, n3, n1)); } molals+= molality(N_co, (int) N_wat); molars+= molarity(N_co, box_size); /* Storage */ for (unsigned int i=0; i<granularity; ++i){ positions[i] += cutoff[i]; } for (unsigned int j=0; j<granularity; ++j) { values[(int) (frame_counter/(partition+1))][j] += coefficients[j]; values_sqr[(int) (frame_counter/(partition+1))][j] += coefficients[j]*coefficients[j]; } cutoff.clear(); coefficients.clear(); protein.clear(); cosolvent.clear(); solvent.clear(); ++frame_counter; } } while ( read_next_frame(status,&fr) ); //thanx(stderr); /* FINAL REUSLTS */ double normalization = partition; molals /= (num_blocks*normalization); molars /= (num_blocks*normalization); for (unsigned int i=0; i<granularity; ++i){ positions[i] /= (num_blocks*normalization); } for (unsigned int i=0; i<num_blocks; ++i) { for (unsigned int j=0; j<granularity; ++j) { values[i][j] /= normalization; values_sqr[i][j] /= normalization; } } /* AVERAGES */ for (unsigned int i=0; i<granularity; ++i) { for (unsigned int j=0; j<num_blocks; ++j) { averages[i] += values[j][i]; averages_sqr[i] += values_sqr[j][i]; } averages[i] /= (double) num_blocks; averages_sqr[i] /= (double) num_blocks; } /* STANDARD DEVIATIONS */ for (unsigned int i=0; i<granularity; ++i) { sigma[i] += sqrt( averages_sqr[i] - averages[i]*averages[i] ); } /* OUTPUT */ std::ofstream distances("dimensions.dat"); for (unsigned int i=0; i<granularity/2; ++i){ distances << std::setw(1) << positions[i] <<'\n'; } distances.close(); std::string output1="preferential_val.dat"; std::string output2="preferential_sig.dat"; std::string result; std::ostringstream convert; convert << num_blocks; //skip; result = convert.str(); output1.insert(16,result); output2.insert(16,result); std::ofstream pic1(output1.c_str()); std::ofstream pic2(output2.c_str()); for (unsigned int i=0; i<granularity/2; ++i) { pic1 << std::setw(10)<< averages[i] <<'\n'; pic2 << std::setw(10)<< sigma[i] <<'\n'; } pic1.close(); pic2.close(); std::ofstream concentrations("concentrations.dat"); concentrations<< std::setw(10) << "Molality" <<'\t'<< std::setw(10) << "Molarity" <<'\n'; concentrations<< std::setw(10) << molals <<'\t'<< std::setw(10) << molars << '\n'; concentrations.close(); std::cout << "ANALYSIS COMPLETED!" <<'\n'; std::cout<<"Total number of frames: "<<frame_counter<<'\n'; } //////////////// test_partition.close(); thanx(stderr); return 0; }
int compare( const void *arg1, const void *arg2 ) { try { const I_MapItem *i1 = *reinterpret_cast<I_MapItem**>(const_cast<void*>(arg1)); const I_MapItem *i2 = *reinterpret_cast<I_MapItem**>(const_cast<void*>(arg2)); C_TextPtr text1(const_cast<I_MapItem*>(i1)); C_TextPtr text2(const_cast<I_MapItem*>(i2)); if (text1 && !text2) { return 1; } else if (text2 && !text1) { return -1; } C_PicturePtr pic1(const_cast<I_MapItem*>(i1)); C_PicturePtr pic2(const_cast<I_MapItem*>(i2)); if (pic1 && !pic2) { return 1; } else if (pic2 && !pic1) { return -1; } C_PositionPtr p1(const_cast<I_MapItem*>(i1)); C_PositionPtr p2(const_cast<I_MapItem*>(i2)); if (p1 && p2) { C_Area area1(p1.GetPoints()); C_Area area2(p2.GetPoints()); int n = 0; int cnt1 = area1.GetLength(); int cnt2 = area2.GetLength(); if (0 == cnt1) { return -1; } if (0 == cnt2) { return 1; } POINT3D *ptr1 = area1[cnt1 - 1]; POINT3D *ptr2 = area2[cnt2 - 1]; if (ptr1->x < 0 && ptr2->x > 0) { n = -1; } else if (ptr1->x > 0 && ptr2->x < 0) { n = 1; } else if (ptr1->y < ptr2->y) { n = -1; } else if (ptr1->y > ptr2->y) { n = 1; } if (0 == n) { if (cnt1 < cnt2) { n = -1; } else if (cnt1 > cnt2) { n = 1; } } if (0 != n) { return n; } } C_UniquePtr u1(const_cast<I_MapItem*>(i1)); C_UniquePtr u2(const_cast<I_MapItem*>(i2)); if (!u1 && !u2) { return 0; } else if (!u1) { return -1; } else if (!u2) { return 1; } else { BSTR bs1 = NULL; BSTR bs2 = NULL; u1->get_UID(&bs1); u2->get_UID(&bs2); int n = ::wcscmp(bs1, bs2); String::FreeBSTR(&bs1); String::FreeBSTR(&bs2); return n; } } catch (C_STLNonStackException const &exception) { exception.Log(_T("Exception in Items.cpp (compare)")); } return 0; }
void mainwindow::setacscene() { QRectF acbounds(0,0,2480,1754); scene2=new QGraphicsScene(acbounds,this); QPixmap pic2("./pic/bpic.png"); pix2 = new QGraphicsPixmapItem(pic2); scene2->addItem(pix2); s_no2 = new QGraphicsTextItem(""); s_no2->setZValue(pix2->zValue()+1); //s_no2->setPos(QPointF(908,784)); sname2 = new QGraphicsTextItem(""); sname2->setZValue(pix2->zValue()+1); sname2->setPos(QPointF(908,784)); fname2 = new QGraphicsTextItem(""); fname2->setZValue(pix2->zValue()+1); fname2->setPos(QPointF(440,896)); sdetail2 = new QGraphicsTextItem(""); sdetail2->setZValue(pix2->zValue()+1); sdetail2->setPos(QPointF(1128,1108)); periodfrom2 = new QGraphicsTextItem(""); periodfrom2->setZValue(pix2->zValue()+1); periodfrom2->setPos(QPointF(784,1228)); periodto2 = new QGraphicsTextItem(""); periodto2->setZValue(pix2->zValue()+1); periodto2->setPos(QPointF(1176,1228)); date2 = new QGraphicsTextItem(dt); date2->setZValue(pix2->zValue()+1); date2->setPos(QPoint(2112,540)); roll2 = new QGraphicsTextItem(""); roll2->setZValue(pix2->zValue()+1); roll2->setPos(QPointF(808,1000)); gen2 = new QGraphicsTextItem(""); gen2->setZValue(pix2->zValue()+1); gen2->setPos(QPointF(140,904)); purpose2 = new QGraphicsTextItem(""); purpose2->setZValue(pix2->zValue()+1); purpose2->setPos(QPointF(1024,1372)); purposetext2 = new QGraphicsTextItem(""); purposetext2->setZValue(pix2->zValue()+1); purposetext2->setPos(QPointF(128,1372)); scene2->addItem(fname2); scene2->addItem(sname2); scene2->addItem(sdetail2); scene2->addItem(periodfrom2); scene2->addItem(periodto2); scene2->addItem(roll2); scene2->addItem(date2); scene2->addItem(gen2); scene2->addItem(purpose2); scene2->addItem(purposetext2); }
void LinkStatusWidget::paintEvent(QPaintEvent *event){ initLines(); QPainter painter(this); QPixmap pic(QString::fromUtf8(":/computer_white.png")); QRectF dest(0,0,pic.width(),pic.height()); QPixmap pic2(QString::fromUtf8(":/honeywell.png")); QRectF dest2(0,0,pic2.width(),pic2.height()); //220*180 QRectF target_0(this->left_left,this->left_top,this->left_width,this->left_height); QRectF target_1(this->width()-this->right_right-this->right_width,this->right_top,this->right_width,this->right_height); QRectF target_2(this->width()-this->right_right-this->right_width,this->right_top+this->right_height+this->right_space,this->right_width,this->right_height); painter.setPen(Qt::white); painter.drawPixmap(target_0,pic2,dest2); painter.drawText(this->left_left+this->left_width+this->left_space,this->left_top+painter.fontMetrics().height(),Config::LINKSTATUS_LABEL.split("#").at(2)); painter.drawPixmap(target_1,pic,dest); QString text=Config::LINKSTATUS_LABEL.split("#").at(0); int f_w=painter.fontMetrics().width(text); painter.drawText(this->width()-this->right_right-this->right_width-this->right_space*2-f_w,this->right_top+painter.fontMetrics().height()+this->right_space,text); painter.drawPixmap(target_2,pic,dest); text=Config::LINKSTATUS_LABEL.split("#").at(1); f_w=painter.fontMetrics().width(text); painter.drawText(this->width()-this->right_right-this->right_width-this->right_space*2-f_w,this->right_top+this->right_height+this->right_space*2+painter.fontMetrics().height(),text); //draw base line painter.save(); //#353942 QPen pen1(Qt::white,8,Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin); pen1.setColor(QColor(53, 57, 66)); painter.setPen(pen1); painter.drawLines(lines); painter.restore(); if(!this->isConn){ return; } int centerHeight=this->right_top+this->right_height+this->right_space/2; QColor co1 =QColor(146, 196, 15) ; QColor co2 =QColor(0, 255, 0, 0); QColor co3 =QColor( 255,0, 0,200); QColor co4 =QColor( 255,0,0, 0); int mleft=this->width()-this->right_right-this->right_width-this->right_space-this->countMain; int mright=mleft+this->line_width_main; if(this->isBroken_1){ QLinearGradient linearGradient = QLinearGradient(mleft,centerHeight,mright,centerHeight); linearGradient.setColorAt(0,co3); linearGradient.setColorAt(1,co4); QPen pen2(linearGradient,5); pen2.setCapStyle(Qt::RoundCap); painter.setPen(pen2); }else{ QLinearGradient linearGradient = QLinearGradient(mleft,centerHeight,mright,centerHeight); linearGradient.setColorAt(0,co1); linearGradient.setColorAt(1,co2); QPen pen2(linearGradient,5); pen2.setCapStyle(Qt::RoundCap); painter.setPen(pen2); } painter.drawLine(mleft,centerHeight,mright,centerHeight); int sbottom= this->right_top+this->right_height/2+this->countSub; int stop= sbottom-this->line_width_sub; int sright=this->width()-this->right_right+this->right_space; //message 2 if(this->isBroken_2){ QLinearGradient linearGradient2 = QLinearGradient(sright,stop,sright,sbottom); linearGradient2.setColorAt(0,co4); linearGradient2.setColorAt(1,co3); QPen pen3(linearGradient2,4); pen3.setCapStyle(Qt::RoundCap); painter.setPen(pen3); }else{ QLinearGradient linearGradient2 = QLinearGradient(sright,stop,sright,sbottom); linearGradient2.setColorAt(0,co2); linearGradient2.setColorAt(1,co1); QPen pen3(linearGradient2,4); pen3.setCapStyle(Qt::RoundCap); painter.setPen(pen3); } painter.drawLine(sright,stop,sright,sbottom); }