Changeset 229 in PSPA
- Timestamp:
- Jan 3, 2013, 9:50:36 AM (12 years ago)
- Location:
- Interface_Web/trunk/pspaWT
- Files:
-
- 23 edited
Legend:
- Unmodified
- Added
- Removed
-
Interface_Web/trunk/pspaWT/include/GWt_abstractElement.h
r226 r229 22 22 WPushButton* dropped_; 23 23 WContainerWidget* wc_; 24 24 WText* wc_item_; 25 25 WLineEdit* labelEdit_; 26 26 … … 36 36 37 37 void clicked(); 38 void setLabelWidget(); 38 39 void updateLabelWidget(); 39 40 WPushButton* getButton(); -
Interface_Web/trunk/pspaWT/include/GWt_soleno.h
r226 r229 1 1 #ifndef GWTSOLENO_SEEN 2 2 #define GWTSOLENO_SEEN 3 4 #include <Wt/WCheckBox> 3 5 4 6 //#include "GWt_pspaApplication.h" … … 18 20 WLineEdit* apertureEdit_; 19 21 WLineEdit* B0Edit_; 22 WCheckBox* varyB0Edit_; 20 23 21 24 GWt_soleno() {;} -
Interface_Web/trunk/pspaWT/include/abstractElement.h
r225 r229 15 15 16 16 bool parmelaOk_; 17 bool parmelaIgnored_; 17 18 bool transportOk_; 18 19 int nbParam_; … … 54 55 double getLenghtOfElement() const; 55 56 int getNbParams() const; 57 bool is_parmela_ignored() const; 56 58 bool is_parmela_element() const; 57 59 bool is_transport_element() const; -
Interface_Web/trunk/pspaWT/include/elementSoleno.h
r84 r229 16 16 double B0Def_; // en kilogauss 17 17 18 bool varyB0_; 19 bool varyB0Def_; 18 20 19 21 -
Interface_Web/trunk/pspaWT/include/particleBeam.h
r227 r229 51 51 52 52 53 void readTransportMoments(ifstream& inp); 53 // void readTransportMoments(ifstream& inp); 54 void readTransportMoments(stringstream& inp); 54 55 55 56 void impressionDesMoments() const; -
Interface_Web/trunk/pspaWT/include/transportMoments.h
r180 r229 32 32 void raz(); 33 33 34 void readFromTransportOutput(ifstream& inp); 34 // void readFromTransportOutput(ifstream& inp); 35 void readFromTransportOutput(stringstream& inp); 35 36 string writeToTransportInput(double P0) const; 36 37 -
Interface_Web/trunk/pspaWT/src/GWt_LigneFaisceau.cc
r226 r229 69 69 } 70 70 71 gw-> updateLabelWidget();71 gw->setLabelWidget(); 72 72 nObjets_[ptr->getNomdElement().getElementType()].incr(); 73 73 GWt_dropZoneLigneFaiseau* dropZone = new GWt_dropZoneLigneFaiseau(pspa_); -
Interface_Web/trunk/pspaWT/src/GWt_abstractElement.cc
r226 r229 69 69 { 70 70 string str = element_->getLabel(); 71 WText *item = new WText(str); 72 item->setObjectName("aText"); 73 wc_->addWidget(item); 71 wc_item_->setText(str); 72 } 73 74 void GWt_abstractElement::setLabelWidget() 75 { 76 string str = element_->getLabel(); 77 wc_item_ = new WText(str); 78 wc_item_->setObjectName("aText"); 79 wc_->addWidget(wc_item_); 74 80 } 75 81 -
Interface_Web/trunk/pspaWT/src/GWt_beam.cc
r226 r229 65 65 } 66 66 element_->setParametersString(envoi); 67 updateLabelWidget(); 67 68 delete [] envoi; 68 69 } -
Interface_Web/trunk/pspaWT/src/GWt_bend.cc
r226 r229 66 66 } 67 67 element_->setParametersString(envoi); 68 updateLabelWidget(); 68 69 delete [] envoi; 69 70 } -
Interface_Web/trunk/pspaWT/src/GWt_cell.cc
r226 r229 91 91 } 92 92 element_->setParametersString(envoi); 93 updateLabelWidget(); 93 94 delete [] envoi; 94 95 } -
Interface_Web/trunk/pspaWT/src/GWt_drift.cc
r226 r229 39 39 } 40 40 element_->setParametersString(envoi); 41 updateLabelWidget(); 41 42 delete [] envoi; 42 43 } -
Interface_Web/trunk/pspaWT/src/GWt_dropZoneLigneFaiseau.cc
r226 r229 153 153 154 154 if(insertedAbstractElement == NULL) return; 155 insertedAbstractElement-> updateLabelWidget();155 insertedAbstractElement->setLabelWidget(); 156 156 157 157 // ////////////////////////////////////////////////////////////////// … … 396 396 str= elem.getElementLabel()+"0"+number; 397 397 } else { 398 str= elem.getElementLabel()+ " "+number;398 str= elem.getElementLabel()+number; 399 399 } 400 400 } -
Interface_Web/trunk/pspaWT/src/GWt_fit.cc
r226 r229 42 42 new WText(" tolerance : ",dialog_->contents()); 43 43 tolerEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); 44 new WBreak(dialog_->contents()); 44 45 WPushButton *submit = new WPushButton("OK",dialog_->contents()); 45 46 submit->clicked().connect(dialog_, &Wt::WDialog::accept); … … 66 67 } 67 68 element_->setParametersString(envoi); 69 updateLabelWidget(); 68 70 delete [] envoi; 69 71 } -
Interface_Web/trunk/pspaWT/src/GWt_pspaApplication.cc
r227 r229 687 687 void PspaApplication::faireDessinEnveloppe(WContainerWidget* toto, string type) 688 688 { 689 new WText(nameOfCase_ + " : enveloppe", toto); 690 unsigned nbel = dtmanage_->beamLineSize(); 689 690 GWt_dialog* envDialog = new GWt_dialog("enveloppe",toto_,false); 691 envDialog->setMinimumSize(400,400); 692 envDialog->setClosable(true); 693 envDialog->show(); 694 695 696 697 // new WText(nameOfCase_ + " : enveloppe", toto); 698 unsigned nbel = dtmanage_->beamLineSize(); 691 699 692 700 … … 697 705 dtmanage_->donneesRmsEnveloppe(type,1, nbel, xcor,ycor); 698 706 699 scatterPlot1D(toto,xcor,ycor);707 scatterPlot1D(envDialog->contents(),xcor,ycor); 700 708 701 709 } … … 703 711 void PspaApplication::faireDessinParmela(WContainerWidget* toto, particleBeam* beam) 704 712 { 713 714 GWt_dialog* pointsDialog = new GWt_dialog("space phase",toto,false); 715 pointsDialog->setMinimumSize(400,400); 716 pointsDialog->setClosable(true); 717 // pointsDialog->show(); 718 719 720 705 721 vector<bareParticle>& partic = beam->getParticleVector(); 706 new WText(nameOfCase_ + " : espace de phase x,x' "+ " nb partic. "+ mixedTools::intToString(partic.size()), toto);707 WStandardItemModel *model = new WStandardItemModel(partic.size(), 3, toto);722 new WText(nameOfCase_ + " : espace de phase x,x' "+ " nb partic. "+ mixedTools::intToString(partic.size()), pointsDialog->contents()); 723 WStandardItemModel *model = new WStandardItemModel(partic.size(), 3, pointsDialog->contents()); 708 724 // model->setHeaderData(0, WString("X")); 709 725 // model->setHeaderData(1, WString("Y = sin(X)")); … … 720 736 } 721 737 722 WCartesianChart *chart = new WCartesianChart( toto);738 WCartesianChart *chart = new WCartesianChart(pointsDialog->contents()); 723 739 chart->setModel(model); // set the model 724 740 chart->setXSeriesColumn(0); // set the column that holds the X data … … 757 773 #endif 758 774 775 pointsDialog->show(); 776 759 777 // chart->setMargin(10, Top | Bottom); // add margin vertically 760 778 // chart->setMargin(WLength::Auto, Left | Right); // center horizontally … … 773 791 774 792 // new WText(nameOfCase_ + " : espace de phase x,x' "+ " nb partic. "+ mixedTools::intToString(partic.size()), toto); 793 794 GWt_dialog* ellipseDialog = new GWt_dialog("ellipse",toto,false); 795 ellipseDialog->setMinimumSize(400,400); 796 ellipseDialog->setClosable(true); 797 ellipseDialog->show(); 775 798 776 799 … … 787 810 // dtmanage_->getCurrentBeam()->donneesDessinEllipseXxp(xcor,ycor); 788 811 beam->donneesDessinEllipseXxp(xcor,ycor); 789 scatterPlot1D(toto,xcor,ycor); 790 791 } 812 scatterPlot1D(ellipseDialog->contents(),xcor,ycor); 813 814 } 815 816 // void PspaApplication::scatterPlot1D(WContainerWidget* toto, vector<double>& xcor, vector<double>& ycor) 817 // { 818 // int nbpts = xcor.size(); 819 // cout << " PspaApplication::scatterPlot1D nbpts = " << nbpts << endl; 820 // WStandardItemModel *model = new WStandardItemModel(nbpts, 2, toto); 821 // for (int i = 0; i < nbpts; ++i) { 822 // model->setData(i, 0, xcor.at(i)); 823 // model->setData(i, 1, ycor.at(i)); 824 // // cout << " PspaApplication::scatterPlot1D el= " << i+1 << " x= " << xcor.at(i) << " y= " << ycor.at(i) << endl; 825 // } 826 827 // WCartesianChart *chart = new WCartesianChart(toto); 828 829 // chart->initLayout(); 830 831 // chart->setModel(model); // set the model 832 // chart->setXSeriesColumn(0); // set the column that holds the X data 833 // chart->setLegendEnabled(true); // enable the legend 834 835 // chart->setType(ScatterPlot); // set type to ScatterPlot 836 837 // // Typically, for mathematical functions, you want the axes to cross 838 // // at the 0 mark: 839 // chart->axis(XAxis).setLocation(ZeroValue); 840 // chart->axis(YAxis).setLocation(ZeroValue); 841 842 // // Provide space for the X and Y axis and title. 843 // // chart->setPlotAreaPadding(80, Left); 844 // // chart->setPlotAreaPadding(40, Top | Bottom); 845 // // Add the curves 846 // WDataSeries s(1, CurveSeries, Y1Axis); 847 // chart->addSeries(s); 848 849 // // chart->setBackground (WBrush(WColor("blue"))); 850 // chart->resize(300, 300); // WPaintedWidget must be given explicit size 851 852 // #ifdef HAS_IMAGEMAGIC 853 // Wt::WRasterImage pngImage("png", 600, 600); 854 // Wt::WPainter p(&pngImage); 855 856 // chart->paint(p); 857 // std::string name; 858 // name = workingDir_ + "/chart-"+sessionId ()+".png"; 859 // std::ofstream f(name.c_str(), std::ios::out |std::ios::trunc | std::ios::binary); 860 // pngImage.write(f); 861 862 // new WText("<a href='workingArea/chart-"+sessionId ()+".png' target='_blank'>Afficher l'image</a>",toto); 863 864 // /* 865 // Wt::WPdfImage pdfImage("30cm", "30cm"); 866 // Wt::WPainter p1(&pdfImage); 867 // chart->paint(p1); 868 // std::ofstream f1("chart.pdf", std::ios::out | std::ios::binary); 869 // pdfImage.write(f1); 870 // */ 871 // #endif 872 // } 873 792 874 793 875 void PspaApplication::scatterPlot1D(WContainerWidget* toto, vector<double>& xcor, vector<double>& ycor) … … 802 884 } 803 885 804 WCartesianChart *chart = new WCartesianChart(toto); 805 806 chart->initLayout(); 886 WCartesianChart *chart = new WCartesianChart(toto); 887 chart->setTitle("Enveloppe"); 888 889 // chart->initLayout(); 807 890 808 891 chart->setModel(model); // set the model … … 825 908 826 909 // chart->setBackground (WBrush(WColor("blue"))); 827 chart->resize( 300, 300); // WPaintedWidget must be given explicit size910 chart->resize(800, 400); // WPaintedWidget must be given explicit size 828 911 829 912 #ifdef HAS_IMAGEMAGIC -
Interface_Web/trunk/pspaWT/src/GWt_rfgun.cc
r226 r229 61 61 } 62 62 element_->setParametersString(envoi); 63 updateLabelWidget(); 63 64 delete [] envoi; 64 65 } -
Interface_Web/trunk/pspaWT/src/GWt_soleno.cc
r226 r229 18 18 apertureEdit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); 19 19 new WBreak(dialog_->contents()); 20 new WText("fiel g(kG) : ",dialog_->contents());20 new WText("field (kG) : ",dialog_->contents()); 21 21 B0Edit_ = new WLineEdit( (++param)->c_str(), dialog_->contents()); 22 varyB0Edit_ = new WCheckBox(" : may vary ? ", dialog_->contents()); 23 varyB0Edit_->setChecked(atoi( (++param)->c_str() ) ); 22 24 new WBreak(dialog_->contents()); 23 24 25 // Submit 25 26 WPushButton *submit = new WPushButton("OK",dialog_->contents()); … … 38 39 envoi[++compteur] = apertureEdit_->text().toUTF8(); 39 40 envoi[++compteur] = B0Edit_->text().toUTF8(); 41 int varie; 42 if ( varyB0Edit_->checkState() == Checked ) varie = 1; 43 else varie = 0; 44 envoi[++compteur] = mixedTools::intToString(varie); 40 45 if ( compteur != (int)nbParam ) { 41 46 cerr << " GWt_bend::dialogDone() pb nb de parametres, compteur = " << compteur << " nbParam= " << nbParam << endl; … … 43 48 } 44 49 element_->setParametersString(envoi); 50 updateLabelWidget(); 45 51 delete [] envoi; 46 52 } -
Interface_Web/trunk/pspaWT/src/abstractElement.cc
r225 r229 38 38 aperture_ = defaultAperture_; 39 39 parmelaOk_ = false; 40 parmelaIgnored_ = false; 40 41 transportOk_ = false; 41 42 } … … 105 106 } 106 107 108 bool abstractElement::is_parmela_ignored() const { 109 return parmelaIgnored_; 110 } 111 107 112 bool abstractElement::is_transport_element() const { 108 113 return transportOk_; -
Interface_Web/trunk/pspaWT/src/elementSoleno.cc
r225 r229 21 21 { 22 22 B0Def_ = 0.0; 23 varyB0Def_ = false; 23 24 } 24 25 … … 26 27 { 27 28 B0_ = B0Def_; 29 varyB0_ = varyB0Def_; 28 30 } 29 31 … … 39 41 parametersString_[++compteur] = mixedTools::doubleToString(aperture_); 40 42 parametersString_[++compteur] = mixedTools::doubleToString(B0_); 43 parametersString_[++compteur] = mixedTools::intToString(varyB0_); 41 44 if ( compteur != nbParam_ ) { 42 45 cerr << " elementSoleno::getParametersString() : ERROR nr pf parameters dosnt match " << endl; … … 65 68 aperture_ = atof(param[++compteur].c_str()); 66 69 B0_ = atof(param[++compteur].c_str()); 70 varyB0_ = atoi(param[++compteur].c_str()); 67 71 } 68 72 … … 79 83 ostringstream sortie; 80 84 // on passe la longueur en metres 81 sortie << label_ << ":" << " SOLENOID, L=" << 0.01*lenghtElem_ << ", B=" << B0_ << ";"; 85 sortie << label_ << ":" << " SOLENOID, L=" << 0.01*lenghtElem_ << ", B=" << B0_ << ";" << endl; 86 if ( varyB0_ ) { 87 sortie << " VARY, " << label_+"[B]" << ";"; 88 } 82 89 return sortie.str(); 83 90 } … … 89 96 sortie << elementName_.getElementLabel() << endl; 90 97 sortie << label_ << endl; 91 sortie << lenghtElem_ << " " << aperture_<< " " << B0_ << endl;98 sortie << lenghtElem_ << " " << aperture_<< " " << B0_ << " " << varyB0_ << endl; 92 99 return sortie.str(); 93 100 } … … 96 103 { 97 104 ifs >> label_; 98 ifs >> lenghtElem_ >> aperture_ >> B0_ ;105 ifs >> lenghtElem_ >> aperture_ >> B0_ >> varyB0_ ; 99 106 } -
Interface_Web/trunk/pspaWT/src/nomdElements.cc
r226 r229 80 80 case cell : return 10; 81 81 case bend : return 7; 82 case soleno : return 4;82 case soleno : return 5; 83 83 case fit : return 4; 84 84 default : return 0; -
Interface_Web/trunk/pspaWT/src/particleBeam.cc
r227 r229 5 5 #include <stdio.h> 6 6 #include <algorithm> 7 7 #include <sstream> 8 8 //#include "environmentVariables.h" 9 9 #include <Wt/WApplication> 10 10 11 11 using namespace std; 12 12 13 13 particleBeam::particleBeam() { … … 95 95 96 96 97 // bool particleBeam::setFromTransport(string workingDir, string elLab, const nomdElements elem) 98 // { 99 // string elementLabel = elLab; 100 // // transformer le label en majuscules ; je ne suis pas sur que ca 101 // // marchera a tous les coups (glm) 102 // std::transform(elementLabel.begin(), elementLabel.end(), elementLabel.begin(), (int (*)(int))std::toupper); 103 104 // cout << " particleBeam::setFromTransport on cherche element " << elementLabel << endl; 105 // string buf; 106 // ifstream infile; 107 // // string nameIn = WORKINGAREA + "transport.output"; 108 // string nameIn = workingDir + "transport.output"; 109 // infile.open(nameIn.c_str(), ios::in); 110 // if (!infile) { 111 // cerr << " particleBeam::setFromTransport : error re-opening transport output stream " << nameIn << endl; 112 // return false; 113 // } 114 // // else cout << " particleBeam::setFromTransport() : ouverture du fichier " << nameIn << endl; 115 116 // string::size_type nn = string::npos; 117 // while ( getline(infile, buf) ) { 118 // // cout << " buf= " << buf << endl; 119 // nn = buf.find(elementLabel); 120 // // cout << " string::npos= " << string::npos << " nn= " << nn << endl; 121 // if ( nn != string::npos ) { 122 // // cout << " particleBeam::setFromTransport : element " << elementLabel << " trouve " << endl; 123 // break; 124 // } 125 // } 126 127 // if ( nn == string::npos ) { 128 // cerr << " particleBeam::setFromTransport : element " << elementLabel << " non trouve dans le fichier " << nameIn << endl; 129 // return false; 130 // } 131 // if (elem.getElementType() == bend ) { 132 // getline(infile, buf); 133 // getline(infile, buf); 134 // } 135 // readTransportMoments(infile); 136 // impressionDesMoments(); 137 // infile.close(); 138 // momentRepresentationOk_ = true; 139 // return true; 140 // } 141 97 142 bool particleBeam::setFromTransport(string workingDir, string elLab, const nomdElements elem) 98 143 { … … 103 148 104 149 cout << " particleBeam::setFromTransport on cherche element " << elementLabel << endl; 105 string buf;106 150 ifstream infile; 107 151 // string nameIn = WORKINGAREA + "transport.output"; … … 115 159 116 160 string::size_type nn = string::npos; 161 string fichier; 162 string buf; 163 unsigned compteur = 0; 117 164 while ( getline(infile, buf) ) { 118 // cout << " buf= " << buf << endl;165 fichier += buf+"\n"; 119 166 nn = buf.find(elementLabel); 120 // cout << " string::npos= " << string::npos << " nn= " << nn << endl;121 167 if ( nn != string::npos ) { 122 // cout << " particleBeam::setFromTransport : element " << elementLabel << " trouve " << endl; 123 break; 124 } 125 } 126 127 if ( nn == string::npos ) { 168 compteur++; 169 // break; 170 } 171 } 172 infile.close(); 173 cout << " compteur= " << compteur << endl; 174 if ( compteur == 0 ) { 128 175 cerr << " particleBeam::setFromTransport : element " << elementLabel << " non trouve dans le fichier " << nameIn << endl; 129 176 return false; 130 177 } 131 if (elem.getElementType() == bend ) { 132 getline(infile, buf); 133 getline(infile, buf); 134 } 135 readTransportMoments(infile); 178 179 180 stringstream fichierStream(fichier); 181 buf.clear(); 182 unsigned relu = 0; 183 while ( std::getline(fichierStream, buf) ) { 184 // cout << " relecture buffer : " << buf << endl; 185 nn = buf.find(elementLabel); 186 if ( nn != string::npos ) { 187 relu++; 188 if ( relu == compteur ) { 189 cout << " TROUVE !" << endl; 190 break; 191 } 192 } 193 } 194 195 readTransportMoments(fichierStream); 136 196 // impressionDesMoments(); 137 infile.close();138 197 momentRepresentationOk_ = true; 139 198 return true; … … 430 489 431 490 432 void particleBeam::readTransportMoments(ifstream& inp) { 491 // void particleBeam::readTransportMoments(ifstream& inp) { 492 // rij_.readFromTransportOutput(inp); 493 // } 494 495 void particleBeam::readTransportMoments(stringstream& inp) { 433 496 rij_.readFromTransportOutput(inp); 434 497 } -
Interface_Web/trunk/pspaWT/src/transportMoments.cc
r226 r229 76 76 77 77 78 // // suppose qu'on est bien positionné dans le stream (a revoir) 79 // void transportMoments::readFromTransportOutput(ifstream& inp) { 80 // string bidString; 81 // double bidon; 82 83 // // initialisation des moments 84 // raz(); 85 86 // inp >> bidon >> bidString >> bidon >> ( rij_transportMoments_.at(0) ).at(0) >> bidString; 87 // inp >> bidon >> ( rij_transportMoments_.at(1) ).at(1) >> bidString >> ( rij_transportMoments_.at(1) ).at(0); 88 // inp >> bidon >> ( rij_transportMoments_.at(2) ).at(2) >> bidString >> ( rij_transportMoments_.at(2) ).at(0) >> ( rij_transportMoments_.at(2) ).at(1); 89 // inp >> bidon >> ( rij_transportMoments_.at(3) ).at(3) >> bidString >> ( rij_transportMoments_.at(3) ).at(0) >> ( rij_transportMoments_.at(3) ).at(1) >> ( rij_transportMoments_.at(3) ).at(2); 90 91 // inp >> bidon >> ( rij_transportMoments_.at(4) ).at(4) >> bidString >> ( rij_transportMoments_.at(4) ).at(0) >> ( rij_transportMoments_.at(4) ).at(1) >> ( rij_transportMoments_.at(4) ).at(2) >> ( rij_transportMoments_.at(4) ).at(3); 92 93 // inp >> bidon >> ( rij_transportMoments_.at(5) ).at(5) >> bidString >> ( rij_transportMoments_.at(5) ).at(0) >> ( rij_transportMoments_.at(5) ).at(1) >> ( rij_transportMoments_.at(5) ).at(2) >> ( rij_transportMoments_.at(5) ).at(3) >> ( rij_transportMoments_.at(5) ).at(4); 94 95 // } 96 78 97 // suppose qu'on est bien positionné dans le stream (a revoir) 79 void transportMoments::readFromTransportOutput( ifstream& inp) {98 void transportMoments::readFromTransportOutput(stringstream& inp) { 80 99 string bidString; 81 100 double bidon; … … 94 113 95 114 } 115 96 116 97 117 string transportMoments::writeToTransportInput(double P0) const { -
Interface_Web/trunk/pspaWT/workingArea/pspa.save
r202 r229 19 19 solnd 20 20 solnd01 21 7.88 1e+61 1.02885 21 7.88 1e+61 1.02885 0 22 22 drift 23 23 drift02
Note: See TracChangeset
for help on using the changeset viewer.