void test_func(void) { //Person *p = new Person(); Person per; per.printInfo(); }
void StudentGrade::display() { thisStudent.display(); cout << " Grade: " << letter_grade << " (" << test_score << "/" << test_points << ")" << endl; }
/********************************************************************** * Add text here to describe what the function "main" does. Also don't forget * to fill this out with meaningful text or YOU WILL LOSE POINTS. ***********************************************************************/ int main(int argc, const char* argv[]) { //change this back to 2 to be universal if (argc < 1) { cout << "Usage: a.out fileName\n"; } else { List<Person> people; ifstream fin; //string fileName = argv[1]; string fileName = "cameron.ged"; string tmp; //Read in file do { fin.clear(); fin.open(fileName.c_str()); } while(fin.fail()); Person person; //parse file into list while(getline(fin, tmp)) { if(tmp.substr(0,4) == "0 @I") { person.idNumber = tmp.substr(4,4); fin.ignore(); } if(tmp.substr(0,6) == "2 GIVN") { person.fname = tmp.substr(6); } if(tmp.substr(0,6) == "2 SURN") { person.lname = tmp.substr(6); } if(tmp.substr(0,6) == "1 BIRT") { getline(fin, tmp); if(tmp.substr(0,6) == "2 DATE") { person.bday = tmp.substr(6); } } if(tmp.substr(0,6) == "3 TIME") { people.push_back(person); person.clear(); } } sortMerge(people); for(ListIterator<Person> it = people.begin(); it != people.end(); it++) { (*it).display(); } //cout << tmp << endl; //organize by name //Put into tree //output } return 0; }
void QBorderMainWindow::performFaceVerification(int isSketch) { //verify each input face with the wantedPersons. commonTool.log("Performing face verification"); // commonTool.log("222222333"+QString::number(wantedPersonsSynthesized.size())); matchedIndex = -1; partialMatchedIndex = -1; if (!inputPerson.empty()) { faceVerificationResult.clear(); partialFaceVerificationResult.clear(); sortedPartialFaceVerificationResult.clear(); sortedFaceVerificationResult.clear(); faceVerificationResultRaw.clear(); persons.clear(); for (int i=0;i<(int)wantedPersons.size();i++) { std::vector<double> similarities; // commonTool.log("222222333"+QString::number(wantedPersonsSynthesized.size())); /* if (!wantedPersonsSynthesized.at(i).empty()) { similarities = faceMatchingManager.getNormalizedSimilarity(wantedPersonsSynthesized.at(i), inputPerson); commonTool.log(QString("%1 -> %2*").arg(i).arg(similarities.at(0))); } else { similarities = faceMatchingManager.getNormalizedSimilarity(wantedPersons.at(i), inputPerson); commonTool.log(QString("%1 -> %2").arg(i).arg(similarities.at(0))); } */ //Audrey //commonTool.log("QBorderMainWindow::faceInputSynthesizeCompleted()"); //synthesize the input face now if (isSketch == 1 && inputPersonSynthesizedReady) { if (!wantedPersonsSynthesized.at(i).empty()) { // commonTool.log("1111111"); similarities = faceMatchingManager.getNormalizedSimilarity(wantedPersonsSynthesized.at(i), inputPersonSynthesized); // commonTool.log(QString("%1 -> %2*").arg(i).arg(similarities.at(0))); } else { // commonTool.log("2222222"+QString::number(wantedPersonsSynthesized.size()) + "EE" + QString::number(i)); similarities = faceMatchingManager.getNormalizedSimilarity(wantedPersons.at(i), inputPersonSynthesized); // commonTool.log(QString("%1 -> %2").arg(i).arg(similarities.at(0))); } } else if (!wantedPersonsSynthesized.at(i).empty()) { commonTool.log("3333333"); similarities = faceMatchingManager.getNormalizedSimilarity(wantedPersonsSynthesized.at(i), inputPerson); commonTool.log(QString("%1 -> %2").arg(i).arg(similarities.at(0))); } else { commonTool.log("4444444"); similarities = faceMatchingManager.getNormalizedSimilarity(wantedPersons.at(i), inputPerson); commonTool.log(QString("%1 -> %2").arg(i).arg(similarities.at(0))); } commonTool.log(QString("numberOfSimilarityScores = %1").arg(similarities.size())); Person person; IntDouble full; full.i = i; full.confidence = 100.0; full.d = similarities.at(0); faceVerificationResult.push_back(full); faceVerificationResultRaw.push_back(similarities); person.setFull(full); //partial score ... // commonTool.log("clac partial score."); IntDouble partial; partial.i = i; partial.confidence = 0.0; partial.d = 0.0; int c=0; if (similarities.at(0) > faceMatchingManager.alarmThreshold) { c++; partial.confidence += 100.0; partial.d += similarities.at(0); } if (c==0) { if (similarities.at(1) > faceMatchingManager.alarmThreshold) { c++; partial.confidence += 50.0; partial.d += similarities.at(1); } if (similarities.at(2) > faceMatchingManager.alarmThreshold) { c++; partial.confidence += 50.0; partial.d += similarities.at(2); } if (c==0) { if (similarities.at(3) > faceMatchingManager.alarmThreshold) { c++; partial.confidence += 25.0; partial.d += similarities.at(3); } if (similarities.at(4) > faceMatchingManager.alarmThreshold) { c++; partial.confidence += 25.0; partial.d += similarities.at(4); } if (similarities.at(5) > faceMatchingManager.alarmThreshold) { c++; partial.confidence += 25.0; partial.d += similarities.at(5); } if (similarities.at(6) > faceMatchingManager.alarmThreshold) { c++; partial.confidence += 25.0; partial.d += similarities.at(6); } if (c==0) { if (similarities.at(7) > faceMatchingManager.alarmThreshold) { c++; partial.confidence += 100.0/8.0; partial.d += similarities.at(7); } if (similarities.at(8) > faceMatchingManager.alarmThreshold) { c++; partial.confidence += 100.0/8.0; partial.d += similarities.at(8); } if (similarities.at(9) > faceMatchingManager.alarmThreshold) { c++; partial.confidence += 100.0/8.0; partial.d += similarities.at(9); } if (similarities.at(10) > faceMatchingManager.alarmThreshold) { c++; partial.confidence += 100.0/8.0; partial.d += similarities.at(10); } if (similarities.at(11) > faceMatchingManager.alarmThreshold) { c++; partial.confidence += 100.0/8.0; partial.d += similarities.at(11); } if (similarities.at(12) > faceMatchingManager.alarmThreshold) { c++; partial.confidence += 100.0/8.0; partial.d += similarities.at(12); } if (similarities.at(13) > faceMatchingManager.alarmThreshold) { c++; partial.confidence += 100.0/8.0; partial.d += similarities.at(13); } if (similarities.at(14) > faceMatchingManager.alarmThreshold) { c++; partial.confidence += 100.0/8.0; partial.d += similarities.at(14); } if (c==0) { //no more levels } else { partial.d /= c; } } else { partial.d /= c; } } else { partial.d /= c; } } commonTool.log(QString("partial %1.").arg(partial.d)); partialFaceVerificationResult.push_back(partial); person.setPartial(partial); person.setSimilarities(similarities); persons.push_back(person); // } //sort commonTool.log("sort 1"); sortedFaceVerificationResult = faceVerificationResult; for(int i = 0; i < sortedFaceVerificationResult.size();i++){ sortedFaceVerificationResult[i].print(); } std::sort(sortedFaceVerificationResult.begin(), sortedFaceVerificationResult.end(), intDouble_less); for(int i = 0; i < sortedFaceVerificationResult.size();i++){ sortedFaceVerificationResult[i].print(); } commonTool.log(QString("sort 2: partialFaceVerificationResult.size(): %1").arg(partialFaceVerificationResult.size())); for(size_t i = 0; i < partialFaceVerificationResult.size();i++){ partialFaceVerificationResult.at(i).print(); } sortedPartialFaceVerificationResult = partialFaceVerificationResult; std::sort(sortedPartialFaceVerificationResult.begin(), sortedPartialFaceVerificationResult.end(), intDouble_less); commonTool.log(QString("sort 2 over: partialFaceVerificationResult.size(): %1").arg(partialFaceVerificationResult.size())); for(std::vector<IntDouble>::iterator it = sortedPartialFaceVerificationResult.begin(); it != sortedPartialFaceVerificationResult.end(); ++it){ it->print(); } commonTool.log("sort end"); //get the highest Score! (necessary?) matchedIndex = sortedFaceVerificationResult.front().i; if (faceVerificationResult.at(matchedIndex).d < faceMatchingManager.alarmThreshold) matchedIndex = -1; partialMatchedIndex = sortedPartialFaceVerificationResult.front().i; if (partialFaceVerificationResult.at(partialMatchedIndex).d < faceMatchingManager.alarmThreshold) partialMatchedIndex = -1; commonTool.log(QString("matchedIndex --> %1").arg(matchedIndex)); commonTool.log(QString("partialMatchedIndex --> %1").arg(partialMatchedIndex)); if(matchedIndex != -1){ result.foundMethod = 1; char numstr[21]; // enough to hold all numbers up to 64-bits for (int i = 0; i < numOfPerson; i++) { sprintf(numstr, "%d", i); string name = "../data/person"; name = name + numstr + ".jpg"; int index = sortedFaceVerificationResult.at(i).i; cv::imwrite(name, wantedPersons.at(index)); persons.at(index).setLandmarks(wantedPersonsLandmarkPointsList.at(index)); persons.at(index).setPhotoPath(name); result.persons.push_back(persons.at(index)); } } else if(partialMatchedIndex != -1) { result.foundMethod = 2; char numstr[21]; // enough to hold all numbers up to 64-bits for (int i = 0; i < numOfPerson; i++) { sprintf(numstr, "%d", i); string name = "../data/person"; name = name + numstr + ".jpg"; int index = sortedPartialFaceVerificationResult.at(i).i; cv::imwrite(name, wantedPersons.at(index)); persons.at(index).setPhotoPath(name); persons.at(index).setLandmarks(wantedPersonsLandmarkPointsList.at(index)); result.persons.push_back(persons.at(index)); } } } }
int deref_ok() { Person p; return p.access_age(); }
Person modify( vector<Person>& people ) { // User menu that changes a persons template for the modify person operation QTextStream in(stdin); Person temp; string gender; QString birth, death, name, numId; char modify; int id = 0; cout << "Select a person to modify(input the number displayed before the name): "; while( !(id > 0 && id <= int( people.size() ) )) { numId = in.readLine(); id = numId.toInt(); } temp = people[id-1]; cout << " 1. Name\n" << " 2. Gender\n" << " 3. Birth date\n" << " 4. Death date\n" << " 5. All" << endl; cout << "What would you like to modify: "; cin >> modify; switch( modify ) { case '1': //To modify name only cout << "Name: "; cin.ignore(); name = ""; while( name == "" ) name = in.readLine(); temp.setName( name ); break; case '2': //To modify gender only cout << "Gender(male/female): "; do{ cin >> gender; cin.ignore(); if(gender == "male" || gender == "Male") temp.setGender( 1 ); else if(gender == "female" || gender == "Female") temp.setGender( 2 ); else cout << "Not a valid entry!"; } while( !(temp.getGender( ) == 1 || temp.getGender( ) == 2) ); break; case '3': //To modify birth year only do{ cout << "Birth year(dd.mm.yyyy): "; birth = in.readLine(); temp.setBirth( QDate::fromString( birth, "dd.MM.yyyy" ) ); if( !(temp.getBirth().isValid()) ) cout <<"Not a valid date!"<< endl; }while( !(temp.getBirth().isValid()) ); break; case '4': //To modify death year only do{ cout << "Death year(dd.mm.yyyy, enter 0 if person is still alive): "; death = in.readLine(); temp.setDeath( QDate::fromString( death, "dd.MM.yyyy" ) ); if( death == "0" ) break; if( !(temp.getDeath().isValid()) ) cout <<"Not a valid date!" << endl; }while( !(temp.getDeath().isValid()) ); break; case '5': //To modify all temp = addPerson(); break; default: cout << "Not a valid option" << endl; break; } temp.setId( people[id-1].getId() ); cout << endl; return temp; }
void ReturnToNormalPopulationEvent::execute() { Person* person = (Person*) dispatcher(); person->return_to_normal_population(); }
void CMyTable::Draw(CDC* pDC, MyCollection* coll) { //pDC->MoveTo(X, Y); int startX = X, startY = Y + cellHeight, finishX, finishY; CRect rect; CPen aPen; aPen.CreatePen(PS_SOLID, 1, RGB(150, 150, 150)); CPen* oldPen; oldPen = pDC->SelectObject(&aPen); coll->startPos = true; sumCell = 0; for(int i = 0; i < coll->GetLength(); i++) { Person* p = coll->getPerson(); if(p == NULL)break; sumCell++; finishY = startY + cellHeight; for(int j = 0; j < 5; j++) { if(j == 0) { finishX = startX + 340; rect.SetRect(startX, startY, finishX + 1, finishY + 1); pDC->Rectangle(&rect); rect.SetRect(startX + 20, startY, finishX + 20 + 1, finishY + 1); pDC->SetTextColor(RGB(20, 20, 20)); pDC->DrawTextW(p->getInitial(), &rect, DT_LEFT | DT_VCENTER | DT_SINGLELINE | DT_NOCLIP); //pDC->SelectObject(oldPen); } if(j == 1) { startX = finishX; finishX = startX + 145; rect.SetRect(startX, startY, finishX + 1, finishY + 1); pDC->Rectangle(&rect); CString str = p->ToCString(p->getSumHours()); pDC->DrawTextW(str, &rect, DT_CENTER | DT_VCENTER | DT_SINGLELINE | DT_NOCLIP); } if(j == 2) { startX = finishX; finishX = startX + 145; rect.SetRect(startX, startY, finishX + 1, finishY + 1); pDC->Rectangle(&rect); CString str = p->ToCString(p->getTarif()); str = str + ' ' + 'p'; pDC->DrawTextW(str, &rect, DT_CENTER | DT_VCENTER | DT_SINGLELINE | DT_NOCLIP); } if(j == 3) { startX = finishX; finishX = startX + 340; rect.SetRect(startX, startY, finishX + 1, finishY + 1); pDC->Rectangle(&rect); CString str = p->ToCString(p->getSalary()); str = str + ' ' + 'p'; pDC->DrawTextW(str, &rect, DT_CENTER | DT_VCENTER | DT_SINGLELINE | DT_NOCLIP); } if(j == 4) { startX = finishX; finishX = startX + 340; rect.SetRect(startX, startY, finishX + 1, finishY + 1); pDC->Rectangle(&rect); CString str = p->ToCString(p->getId()); pDC->DrawTextW(str, &rect, DT_CENTER | DT_VCENTER | DT_SINGLELINE | DT_NOCLIP); } } startX = X; startY += cellHeight; } pDC->SelectObject(oldPen); }
void sortName(Person& a, Person& b) { if(a.getName() < b.getName()) switching(a, b); }
int main ( int argc, char *argv[] ) { cv::VideoCapture cap; std::string auth_key; std::string file_name; std::string input; std::string data_dir = "../data/"; std::string resources_dir = "../resources/"; bool is_webcam_input = false; vector<Mat> normLeftEyeRegion,normRightEyeRegion,normNoseRegion,normLowResFaceRegion; vector<Mat> vHogLres,vHogReye,vHogLeye,vHogNose,vLbpLres,vLbpReye,vLbpLeye,vLbpNose,vHogFace,vEqualizedNorm,vGabor,vFss; vector<float> headPose,headYaw; vector <int> labels; // Create crowdsight instance CrowdSight crowdsight( data_dir ); // Authenticate crowdsight instance if ( !crowdsight.authenticate( auth_key ) ) { std::cerr << crowdsight.getErrorDescription() << std::endl; std::cout << "hello" << std::endl; return -1; } static CvScalar colors[] = { {{0, 0, 255}}, {{0, 128, 255}}, {{0, 255, 255}}, {{0, 255, 0 }}, {{255, 128, 0 }}, {{255, 255, 0 }}, {{255, 0, 0 }}, {{255, 0, 255}} }; // Get the path to your CSV. //string fn_csv = "C:/Users/Liveris/Documents/MasterThesis/FaceDatasets/orl_faces/data_faces.csv"; //string fn_csv = "C:/Users/Liveris/Documents/MasterThesis/FaceDatasets/colorferet/dvd1/data/images/faces_colorferet_train_all_withoutprofile_withouthalf_withoutrerd.txt"; //string fn_csv = "C:/Users/Liveris/Documents/MasterThesis/FaceDatasets/faces/faces_0_30.txt"; string fn_csv = "C:/Users/Liveris/Documents/MasterThesis/FaceDatasets/pubfig83lfw_raw_in_dirs/pubfig83lfw_raw_in_dirs/train/faces_publig83lfw_distract.txt"; //string fn_csv = "C:/Users/Liveris/Documents/MasterThesis/FaceDatasets/faces_yaleB.txt"; //string fn_csv = "C:/Users/Liveris/Documents/MasterThesis/FaceDatasets/lfw/faces_lfw_5.txt"; // These vectors hold the images and corresponding labels. // Read in the data. This can fail if no valid // input filename is given. std::ifstream file(fn_csv.c_str(), ifstream::in); if (!file) { string error_message = "No valid input file was given, please check the given filename."; CV_Error(CV_StsBadArg, error_message); } int counter=0,icounter=0; char separator = ';'; string line, path, classlabel;std::string filename; int i=1; while (getline(file, line)) { stringstream liness(line); getline(liness, path, separator); getline(liness, classlabel); //path="C:/Users/Liveris/Documents/MasterThesis/FaceDatasets/pubfig83lfw_raw_in_dirs/pubfig83lfw_raw_in_dirs/test/Harrison Ford/test__000034-000011.jpg"; //iterate through all images //for ( unsigned int i = 0; i < images.size();++i ) //{ cv::Mat frame; int label; i++ ; // Grab one frame if(!path.empty() && !classlabel.empty()) { frame = ((imread(path))); label=(atoi(classlabel.c_str())); filename= path; } //frame =images[i]; //imread("C:/Users/Liveris/Downloads/lena.jpg");//images[i]; // //Give the full path to the image file# namedWindow( "Display window 1", CV_WINDOW_KEEPRATIO );// Create a window for display. // Define region of interest here if required int marginTop = 0; int marginBottom = 0; int marginLeft = 0; int marginRight = 0; cv::Rect roi; int maxNumPeople = 10; //Start main processing loop crowdsight.setMaxNumPeople( maxNumPeople ); // If frame is empty break if ( frame.empty() ) { break; } //cv::pyrDown(frame,frame); // Specify the roi that will be extracted from the frame roi.x = marginLeft; // pixels to skip from the left roi.y = marginTop; // pixels to skip from the top roi.width = frame.cols-roi.x-marginRight; // width of roi roi.height = frame.rows-roi.y-marginBottom; // height of roi // Change settings if required // Proces current image. // Process function evaluates the frames contents and // must be called before getCurrentPeople(); //show the current face image //cv::imshow("frame",frame); //namedWindow( "frame", CV_WINDOW_KEEPRATIO ); if ( !crowdsight.process(frame,roi) ) { std::cout << crowdsight.getErrorDescription() << std::endl; } // Get the list of people in the last processed frame std::vector<Person> people; if ( !crowdsight.getCurrentPeople(people) ) { std::cerr << crowdsight.getErrorDescription() << std::endl; } cout<<"outer counter "<<counter++<<endl; // For the one person in the frame, do: if (people.size()>0 ) { cout<<"inner counter "<<icounter++<<endl;// Get person Person person = people.at(0); /*********************************** RETRIEVE PERSN INFO ***********************************/ cv::Rect face = person.getFaceRect(); // Retrieve the person's face cv::Point right_eye = person.getRightEye(); // Retrieve left and right eye locations of the person. Eye location is relative to the face rectangle. cv::Point left_eye = person.getLeftEye(); /************************************* DRAW PERSON INFO *************************************/ // Offset eye position with face position, to get frame coordinates. right_eye.x += face.x; right_eye.y += face.y; left_eye.x += face.x; left_eye.y += face.y; // Draw circles in the center of left and right eyes //cv::circle( frame, right_eye, 3, cv::Scalar(0,255,0) ); //cv::circle( frame, left_eye, 3, cv::Scalar(0,255,0) ); Mat faceRect=frame(face); // Draw a rectangle around person's face on the current frame //cv::rectangle(frame, face, cv::Scalar(255,255,255), 1); //Show image imshow("frame",frame); namedWindow( "frame", CV_WINDOW_KEEPRATIO ); //Framo preprocessor Mat greyFrame=convert2gray(frame); //initialize constructor with original eye points FacePreprocessor fprocessor(right_eye,left_eye,72,80); //register image Mat warped=fprocessor.registerImage(greyFrame); //imshow("warped",warped); Mat tanTriggs= fprocessor.tan_triggs_preprocessing(warped); imshow("Tan Triggs",(tanTriggs)); //mean normalize image //Mat norm=fprocessor.meanNormalizeImage(warped); //Mat equalizedNorm; //equalizeHist( norm, equalizedNorm );//Equalize the face image //imshow("norm",norm); //cout<<getImgType(normEllipse.type())<<endl; //imshow("Equalized norm",equalizedNorm); //namedWindow( "Equalized norm", CV_WINDOW_KEEPRATIO ); //waitKey(1); //Extract facial regions from face bool viz=false; FacialRegionExtractor fextractor(fprocessor.getRegisteredRightEye(fprocessor.getTransformMatrix()),fprocessor.getRegisteredLeftEye(fprocessor.getTransformMatrix()),tanTriggs,viz); Mat faceImage=fextractor.getFace(); Mat gaborCropped= resizeImage(faceImage,30,30); imshow("gabor cropped",gaborCropped); namedWindow( "gabor cropped", CV_WINDOW_KEEPRATIO ); waitKey(1); // add the labels labels.push_back(label); //puth them to vectors for opencv lbp uniform vEqualizedNorm.push_back(faceImage); //Extract hog features from resized facial regions HogFeatureExtractor descFace(faceImage,16,16,8,8,8,8); vector<float> HogFace=descFace.extractFeatures(); Mat visHogFace=descFace.convertDescriptor2Mat(HogFace); vHogFace.push_back(visHogFace); imshow("visHog",descFace.getHogVis(visHogFace)); waitKey(3); cout<<visHogFace.rows<<endl; //Extract Gabor Features GaborFeatureExtractor gFace(gaborCropped,4); Mat gMat= gFace.extractFeatures(); vGabor.push_back(gMat); //Extract fss features LSS lss(faceImage); Mat descriptor = lss(); //lss.visualize(); vFss.push_back(descriptor); } } //Create lbp uniform decriptor LBPH lbph(2,8,9,10,DBL_MAX,true); lbph.train(vEqualizedNorm, labels); //FileStorage fs1("lbpUniformFaceTanTrain.yml", FileStorage::WRITE); lbph.save("lbpUniformFaceTanDistract.yml"); //fs1.release(); //Save the hog face FileStorage fs2("hogFaceTanDistract.yml", FileStorage::WRITE); fs2 << "TestImages" << vHogFace; fs2 << "LabelImages"<< labels; fs2.release(); //Save the gabor face FileStorage fs3("gaborFaceTanDistract.yml", FileStorage::WRITE); fs3 << "TestImages" << vGabor; fs3 << "LabelImages"<< labels; fs3.release(); //Save the fss face FileStorage fs4("fssFaceTanDistract.yml", FileStorage::WRITE); fs4 << "TestImages" << vFss; fs4 << "LabelImages"<< labels; fs4.release(); return 0; }
int main() { int nperson, nquery; scanf("%d %d", &nperson, &nquery); vector<vector<Person>> table(201); vector<int> index(201, 0); for(int i=0; i<nperson; i++) { Person p; scanf("%s %d %d", p.name, &p.age, &p.worth); table[p.age].push_back(p); } for( int i=0,size=table.size(); i<size; i++) { sort(table[i].begin(), table[i].end()); } for(int i=1; i<=nquery; i++) { int agemin, agemax, k; scanf("%d %d %d", &k, &agemin, &agemax); printf("Case #%d:\n", i); int K = 0; for(int j=agemin; j<=agemax; j++) { index[j] = 0; } Person minp; int minindex; while(true) { bool reachend = true; minp.worth = -1000001; for( int j=agemin; j<=agemax; j++) { if( index[j] >= table[j].size()) { } else { reachend = false; if( table[j][index[j]] < minp) { minindex = j; minp = table[j][index[j]]; } } } if( reachend) { if( !K) { printf("None\n"); } break; } else { minp.print(); index[minindex]++; if( ++K == k) { break; } } } } return 0; }
void drawScene() { glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glEnable(GL_LIGHT1); glEnable(GL_NORMALIZE); /* GLuint texture = LoadGLTexture("water.bmp", 396, 734); glEnable(GL_TEXTURE_2D); glBindTexture( GL_TEXTURE_2D, texture );*/ //Add ambient light /* GLfloat ambientColor[] = {0.2f, 0.2f, 0.2f, 1.0f}; //Color(0.2, 0.2, 0.2) glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambientColor); //Add positioned light GLfloat lightColor0[] = {0.5f, 0.5f, 0.5f, 1.0f}; //Color (0.5, 0.5, 0.5) GLfloat lightPos0[] = {4.0f, 0.0f, 8.0f, 1.0f}; //Positioned at (4, 0, 8) glLightfv(GL_LIGHT0, GL_DIFFUSE, lightColor0); glLightfv(GL_LIGHT0, GL_POSITION, lightPos0); //Add directed light GLfloat lightColor1[] = {0.5f, 0.2f, 0.2f, 1.0f}; //Color (0.5, 0.2, 0.2) //Coming from the direction (-1, 0.5, 0.5) GLfloat lightPos1[] = {-1.0f, 0.5f, 0.5f, 0.0f}; glLightfv(GL_LIGHT1, GL_DIFFUSE, lightColor1); glLightfv(GL_LIGHT1, GL_POSITION, lightPos1);*/ glRotatef(-0.0, 0.0f, 1.0f, 0.0f); glTranslatef(-4*1.5, 0.0, 4*1.5); //int gifts_x1 = -1, gifts_x2 = -1, gifts_z1 = -1, gifts_z2 = -1; int g=0,h=0,gg=-1,hh=-2,fl1=0,fl2=0,kk=0; int tile_x1=-1,tile_z1=-1; int tile_x2=-1,tile_z2=-1,c*k = 0; int obs_x1=-1,obs_z1=-1,obs_x2=-1,obs_z2=-1; //int gifts_x1=-1,gifts_z1=-1,gifts_x2=-1,gifts_z2=-1; p1.drawtree(-40.0,0.0,-40.0); p1.drawtree(-30.0,0.0,-40.0); p1.drawtree(-20.0,0.0,-40.0); p1.drawtree(-10.0,0.0,-40.0); p1.drawtree(0.0,0.0,-40.0); p1.drawtree(10.0,0.0,-40.0); p1.drawtree(20.0,0.0,-40.0); p1.drawtree(30.0,0.0,-40.0); p1.drawtree(40.0,0.0,-40.0); p1.drawtree(0.0,0.0,0.0); p1.drawtree(12.0,0.0,0.0); glPushMatrix(); glTranslatef(-50*1.5, 0.0, 50*1.5); //change = 10.0f; for(float j=0.0;j>(-100*1.5);j-=1.5) { k++; for(i=0.0;i<(50*3.0);i+=3.0) { glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, x); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,GL_NEAREST); if(k%2==0) { glPushMatrix(); glTranslatef(i,-1.0,j); p1.draw_BlackArea(); //Add commands for drawing a black area to the display list // glCallList(_displayListId_blackArea); glPopMatrix(); } else { glPushMatrix(); glTranslatef(i+1.5,-1.0,j); p1.draw_BlackArea(); //Add commands for drawing a black area to the display list // glCallList(_displayListId_blackArea); glPopMatrix(); } glDisable(GL_TEXTURE_2D); } } for(float j=0.0;j>(-100*1.5);j-=1.5) { k++; for(i=0.0;i<(50*3.0);i+=3.0) { glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, x); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,GL_NEAREST); if(k%2!=0) { glPushMatrix(); glTranslatef(i,-1.0,j); p1.draw_whiteArea(); //Add commands for drawing a black to the display list // glCallList(_displayListId_whiteArea); glPopMatrix(); } else { glPushMatrix(); glTranslatef(i+1.5,-1.0,j); p1.draw_whiteArea(); //Add commands for drawing a black to the display list // glCallList(_displayListId_whiteArea); glPopMatrix(); } glDisable(GL_TEXTURE_2D); } } glPopMatrix(); k=0; change = 1.0; if(mode == 2) { for(float j=0.0;j>(-8*1.5);j-=1.5) { k++;kk++; if(kk%2==0) { fl1 = 1; } if(kk%2==1 && kk>1) c*k =1; for(i=0.0;i<(4*3.0);i+=3.0) { g++; if(fl1 == 1) { fl1=0; gg = gg + 1; } else if(c*k == 1) { c*k = 0; gg = gg +3; } else gg = gg + 2; //if(call_randb == g) //{ tile_x1 = gg%8; tile_z1 = gg/8; //} //else{ if((tile_x1 == sx && tile_z1 == sz && gir == 1) || (sx < 0) || (sx > 7) || (sz < 0) || (sz > 7)) { flag_exit = 1; } else{ glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, grassTextureId); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); if(k%2==0) { if(obs_b == g) { obs_x1=gg%8; obs_z1=gg/8; p1.obstacle(i,j); } glPushMatrix(); glTranslatef(i,0.0,j); glCallList(_displayListId_blackArea); glPopMatrix(); } else { if(obs_b == g) { obs_x1=gg%8; obs_z1=gg/8; p1.obstacle(i+1.5,j); } glPushMatrix(); glTranslatef(i+1.5,0.0,j); glCallList(_displayListId_blackArea); glPopMatrix(); } } //} } } kk=0;int dnt = 0; for(float j=0.0;j>(-8*1.5);j-=1.5) { k++;kk++; if(kk%2==1 && kk>1) { fl2 = 1; } if(kk%2==0) dnt =1; for(i=0.0;i<(4*3.0);i+=3.0) { h++; if(fl2 == 1) { fl2=0; hh = hh + 1; } else if(dnt ==1) { dnt =0; hh = hh +3; } else hh = hh +2; //if(call_randw == h) //{ tile_x2 = hh%8; tile_z2 = hh/8; //} //else{ if( (tile_x2 == sx && tile_z2 == sz && gir == 1) || (sx < 0) || (sx > 7) || (sz < 0) || (sz > 7)) { flag_exit = 1; } else{ glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, grassTextureId); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); if(k%2!=0) { if(obs_w == h) { obs_x2=hh%8; obs_z2=hh/8; p1.obstacle(i,j); } glPushMatrix(); glTranslatef(i,0.0,j); glCallList(_displayListId_whiteArea); glPopMatrix(); } else { if(obs_w == h) { obs_x2=hh%8; obs_z2=hh/8; p1.obstacle(i+1.5,j); } glPushMatrix(); glTranslatef(i+1.5,0.0,j); glCallList(_displayListId_whiteArea); glPopMatrix(); } } //} } } } if(mode == 1) { for(float j=0.0;j>(-8*1.5);j-=1.5) { k++;kk++; if(kk%2==0) { fl1 = 1; // printf("-------------in----------\n"); } if(kk%2==1 && kk>1) c*k =1; for(i=0.0;i<(4*3.0);i+=3.0) { g++; if(fl1 == 1) { fl1=0; gg = gg + 1; } else if(c*k == 1) { c*k = 0; gg = gg +3; } else gg = gg + 2; // printf("gg: %d\n", gg); if(call_randb == g) { // printf("------------------GG is %d\n",gg); tile_x1 = gg%8; tile_z1 = gg/8; } else{ glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, grassTextureId); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); // tile_x1 = gg%8; // tile_z1 = gg/8; if(k%2==0) { if(obs_b == g) { obs_x1=gg%8; obs_z1=gg/8; p1.obstacle(i,j); } /* if(gift_b == g) { gifts_x1=gg%8; gifts_z1=gg/8; p1.gifts(i,j); }*/ glPushMatrix(); glTranslatef(i,0.0,j); glCallList(_displayListId_blackArea); glPopMatrix(); } else { if(obs_b == g) { obs_x1=gg%8; obs_z1=gg/8; p1.obstacle(i+1.5,j); } /*if(gift_b == g) { gifts_x1=gg%8; gifts_z1=gg/8; p1.gifts(i+1.5,j); }*/ glPushMatrix(); glTranslatef(i+1.5,0.0,j); glCallList(_displayListId_blackArea); glPopMatrix(); } } } } kk=0;int dnt = 0; for(float j=0.0;j>(-8*1.5);j-=1.5) { k++;kk++; if(kk%2==1 && kk>1) { fl2 = 1; // printf("---------------in----------------\n"); } if(kk%2==0) dnt =1; for(i=0.0;i<(4*3.0);i+=3.0) { h++; if(fl2 == 1) { fl2=0; hh = hh + 1; } else if(dnt ==1) { dnt =0; hh = hh +3; } else hh = hh +2; // printf("hh:%d\n",hh); if(call_randw == h) { // printf("------------------HH is %d\n",hh); tile_x2 = hh%8; tile_z2 = hh/8; } else{ glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, grassTextureId); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); // tile_x2 = hh%8; // tile_z2 = hh/8; if(k%2!=0) { if(obs_w == h) { obs_x2=hh%8; obs_z2=hh/8; p1.obstacle(i,j); } /*if(gift_w == h) { gifts_x2=hh%8; gifts_z2=hh/8; p1.gifts(i,j); }*/ glPushMatrix(); glTranslatef(i,0.0,j); glCallList(_displayListId_whiteArea); glPopMatrix(); } else { if(obs_w == h) { obs_x2=hh%8; obs_z2=hh/8; p1.obstacle(i+1.5,j); } /*if(gift_w == h) { gifts_x2=hh%8; gifts_z2=hh/8; p1.gifts(i+1.5,j); }*/ glPushMatrix(); glTranslatef(i+1.5,0.0,j); glCallList(_displayListId_whiteArea); glPopMatrix(); } } } } } else if(mode == 0) { for(float j=0.0;j>(-8*1.5);j-=1.5) { k++; for(i=0.0;i<(4*3.0);i+=3.0) { glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, grassTextureId); //Bottom glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); if(k%2==0) { glPushMatrix(); glTranslatef(i,0.0,j); glCallList(_displayListId_blackArea); glPopMatrix(); } else { glPushMatrix(); glTranslatef(i+1.5,0.0,j); glCallList(_displayListId_blackArea); glPopMatrix(); } } } for(float j=0.0;j>(-8*1.5);j-=1.5) { k++; for(i=0.0;i<(4*3.0);i+=3.0) { glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, grassTextureId); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); if(k%2!=0) { glPushMatrix(); glTranslatef(i,0.0,j); glCallList(_displayListId_whiteArea); glPopMatrix(); } else { glPushMatrix(); glTranslatef(i+1.5,0.0,j); glCallList(_displayListId_whiteArea); glPopMatrix(); } } } } if(mode == 0 || mode ==1) { if((tile_x1 == sx && tile_z1 == sz) ||( tile_x2 == sx && tile_z2 == sz) || (sx < 0) || (sx > 7) || (sz < 0) || (sz > 7)) { flag_exit = 1; } if((sx == obs_x1 && sz == obs_z1) || (sx == obs_x2 && sz == obs_z2)) { printf("You are DEAD !!!\nLOL!!!!!\n"); exit(0); } } glPushMatrix(); glTranslatef(0.0f, 0.0f, -5.0f); // Push eveything 5 units back into the scene, otherwise we won't see the primitive gluLookAt (0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0); p1.drawPerson(); //p1.obstacle(); //p1.gifts(1,1); glPopMatrix(); glutSwapBuffers(); angle++; }
void initRendering() { /* glDisable(GL_LIGHTING); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, x); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glDisable(GL_NORMALIZE); glEnable(GL_BLEND); glColor4f(1, 1, 1, WATER_ALPHA); glNormal3f(0, 1, 0); glBegin(GL_QUADS); glTexCoord2f(200 / WATER_TEXTURE_SIZE, -waterTextureOffset / WATER_TEXTURE_SIZE); glVertex3f(-100, 0, -100); glTexCoord2f(200 / WATER_TEXTURE_SIZE, (200 - waterTextureOffset) / WATER_TEXTURE_SIZE); glVertex3f(-100, 0, 100); glTexCoord2f(0, (200 - waterTextureOffset) / WATER_TEXTURE_SIZE); glVertex3f(100, 0, 100); glTexCoord2f(0, -waterTextureOffset / WATER_TEXTURE_SIZE); glVertex3f(100, 0, -100); glEnd(); glDisable(GL_BLEND); glEnable(GL_LIGHTING); */ glEnable(GL_DEPTH_TEST); glEnable(GL_COLOR_MATERIAL); glClearColor(0.0f,0.0f,0.2f,1.0f); Image* image = loadBMP("images.bmp"); grassTextureId = loadTexture(image); Image* image1 = loadBMP("fire2.bmp"); x = loadTexture(image1); //Set up a display list for drawing a cube _displayListId_blackArea = glGenLists(1); // Make room for the display list glNewList(_displayListId_blackArea, GL_COMPILE); // Begin the display list change = 1.0f; p1.draw_BlackArea(); //Add commands for drawing a black area to the display list glEndList(); //End the display list //Set up a display list for drawing a cube _displayListId_whiteArea = glGenLists(2); //Make room for the display list glNewList(_displayListId_whiteArea, GL_COMPILE); //Begin the display list p1.draw_whiteArea(); //Add commands for drawing a black to the display list glEndList(); //End the display list // To uncomment later GLfloat sun_direction[] = { 0.0, 2.0, -1.0, 1.0 }; GLfloat sun_intensity[] = { 0.7, 0.7, 0.7, 1.0 }; GLfloat ambient_intensity[] = { 0.3, 0.3, 0.3, 1.0 }; glEnable(GL_DEPTH_TEST); // Enable objects to be drawn ahead/behind one another glEnable(GL_COLOR_MATERIAL); // Enable coloring glClearColor(0.0f, 0.0f, 1.0f, 1.0f); // Setting a background color glEnable(GL_LIGHTING); // Set up ambient light. glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambient_intensity); glEnable(GL_LIGHT0); // Set up sunlight. glLightfv(GL_LIGHT0, GL_POSITION, sun_direction); glLightfv(GL_LIGHT0, GL_DIFFUSE, sun_intensity); glEnable(GL_COLOR_MATERIAL); // Configure glColor(). glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE); delete image; delete image1; }
Person Person::Parser::parseXml(QXmlStreamReader &xml) { Person person; bool hasAvatarPic = false; while (!xml.atEnd()) { xml.readNext(); if (xml.isStartElement()) { if (xml.name() == QLatin1String("personid")) { person.setId(xml.readElementText()); } else if (xml.name() == QLatin1String("firstname")) { person.setFirstName(xml.readElementText()); } else if (xml.name() == QLatin1String("lastname")) { person.setLastName(xml.readElementText()); } else if (xml.name() == QLatin1String("homepage")) { person.setHomepage(xml.readElementText()); } else if (xml.name() == QLatin1String("avatarpic")) { person.setAvatarUrl(QUrl(xml.readElementText())); } else if (xml.name() == QLatin1String("avatarpicfound")) { QString value = xml.readElementText(); if (value.toInt()) { hasAvatarPic = true; } } else if (xml.name() == QLatin1String("birthday")) { person.setBirthday(QDate::fromString(xml.readElementText(), Qt::ISODate)); } else if (xml.name() == QLatin1String("city")) { person.setCity(xml.readElementText()); } else if (xml.name() == QLatin1String("country")) { person.setCountry(xml.readElementText()); } else if (xml.name() == QLatin1String("latitude")) { person.setLatitude(xml.readElementText().toFloat()); } else if (xml.name() == QLatin1String("longitude")) { person.setLongitude(xml.readElementText().toFloat()); } else { person.addExtendedAttribute(xml.name().toString(), xml.readElementText()); } } else if (xml.isEndElement() && (xml.name() == QLatin1String("person") || xml.name() == QLatin1String("user"))) { break; } } if (!hasAvatarPic) { person.setAvatarUrl(QUrl()); } return person; }
void Person::meet(Person other) { cout << "Hi " << other.name << ", my name is " << this->name <<endl; other.giggleNervously(); other.seize(); }
void sortGender(Person& a, Person& b) { if(a.getGender() < b.getGender()) switching(a, b); }
Person SearchPersonMenu() { // Get search paramters from user Person temp; char key = 0; QTextStream in(stdin); temp.setName(""); temp.setGender(0); while( key != '5' ) { // while looping while inserting search parameters cout << "Please specify search parameters" << endl; cout << "\t1. Search by name("; if( temp.getName() == "" ) // If wildcard cout << "any)" << endl; else // if user specified cout << temp.getName().toUtf8().constData() << ")" << endl; // Write current name parameters cout << "\t2. Search by gender("; if( temp.getGender() == 0 ) // If wildcard cout << "any)" << endl; else if( temp.getGender() == 1 ) // if user specified cout << "male)" << endl; else if( temp.getGender() == 2 ) // if user specified cout << "female)" << endl; cout << "\t3. Search by birth("; if( !temp.getBirth().isValid() ) // If wildcard cout << "any)" << endl; else // if user specified cout << temp.getBirth().toString("d.M.yyyy").toUtf8().constData() << ")" << endl; // Write current birth parameters cout << "\t4. Search by death("; if( !temp.getDeath().isValid() ) // If wildcard cout << "any)" << endl; else // if user specified cout << temp.getDeath().toString("d.M.yyyy").toUtf8().constData() << ")" << endl; // Write current death parameters cout << "\t5. Search" << endl; cout << "Your choice: "; cin >> key; // Get user input for next action, 1: name parameter, 2: gender parameter, 3: birth parameter, 4: death parameter and 5: Search cin.ignore(); if( key == '1' ) { // Set user name search parameter cout << "Insert name to search for: "; temp.setName( in.readLine() ); } else if( key == '2' ) { // Set user gender search parameter temp.setGender( -1 ); while( (temp.getGender() < 0) || (temp.getGender() > 2) ) { QString gender; cout << "Insert gender to search for(any/male/female): "; gender = in.readLine(); if( gender == "any" || gender == "Any" ) temp.setGender( 0 ); else if( gender == "male" || gender == "Male" ) temp.setGender( 1 ); else if( gender == "female" || gender == "Female" ) temp.setGender( 2 ); else cout << "Please enter a valid gender" << endl; } } else if( key == '3' ) { // Set user birth search parameter QString birthstring = ""; temp.setBirth( QDate() ); // Set empty date (Also used as wildcard) while( birthstring != "0" && !temp.getBirth().isValid() ) { cout << "Insert birth date(dd.mm.yyyy, 0 for any): "; birthstring = in.readLine(); if( birthstring != "0" ) temp.setBirth( QDate::fromString( birthstring, "dd.MM.yyyy" ) ); } } else if( key == '4' ) { // Set user death search parameter QString deathstring = ""; temp.setDeath( QDate() ); // Set empty date (Also used as wildcard) while( deathstring != "0" && !temp.getDeath().isValid() ) { cout << "Insert death date(dd.mm.yyyy, 0 for any): "; deathstring = in.readLine(); if( deathstring != "0" ) temp.setDeath( QDate::fromString( deathstring, "dd.MM.yyyy" ) ); } } } cout << endl; return temp; // Returns template for person to search for }
void sortBirthyear(Person& a, Person& b) { if(a.getyearOfBirth() < b.getyearOfBirth()) switching(a, b); }
virtual void Show() { m_component->Show(); }
void sortDeathyear(Person& a, Person& b) { if(a.getyearOfDeath() < b.getyearOfDeath()) { switching(a, b); } }
void Pedigree::WriteRecodedPerson( FILE * output, int person, MarkerInfo ** markerInfo, const char * famid, const char * pid, const char * fatid, const char * motid) { Person * p = persons[person]; if (famid == NULL) famid = p->famid; if (pid == NULL) pid = p->pid; if (fatid == NULL) fatid = p->fatid; if (motid == NULL) motid = p->motid; // write in the following order: // markers, traits, affections, covariates fprintf(output, "%s\t%s\t%s\t%s\t%d\t", famid, pid, fatid, motid, p->sex); const char * twinCodes[] = {"0", "MZ", "DZ"}; if (haveTwins) { if (p->zygosity <= 2) fprintf(output, "%s\t", twinCodes[p->zygosity]); else fprintf(output, "%d\t", p->zygosity); } for (int m = 0; m < markerCount; m++) if (markerInfo == NULL) fprintf(output, markerCount < 20 ? "%3d/%3d\t" : "%d/%d\t", p->markers[m][0], p->markers[m][1]); else fprintf(output, markerCount < 20 ? "%3s/%3s\t" : "%s/%s\t", (const char *) markerInfo[m]->GetAlleleLabel(p->markers[m][0]), (const char *) markerInfo[m]->GetAlleleLabel(p->markers[m][1])); for (int t = 0; t < traitCount; t++) if (p->isPhenotyped(t)) fprintf(output, "%.3f\t", p->traits[t]); else fprintf(output, "x\t"); for (int a = 0; a < affectionCount; a++) if (p->isDiagnosed(a)) fprintf(output, "%d\t", p->affections[a]); else fprintf(output, "x\t"); for (int c = 0; c < covariateCount; c++) if (p->isControlled(c)) fprintf(output, "%.3f\t", p->covariates[c]); else fprintf(output, "x\t"); for (int s = 0; s < stringCount; s++) if (!p->strings[s].IsEmpty()) fprintf(output, "%s\t", (const char *) p->strings[s]); else fprintf(output, ".\t"); fprintf(output, "\n"); }
void addPeople() { Person newGuy; newGuy.makePerson(); printToFile(newGuy); }
int deref_after_move_crash() { Person p; auto x = p.move_age(); *x; return p.access_age(); }
void FileReader::parseFile(QString &filename, FileRecord &record) { QFileInfo f(filename); QFile file(filename); QByteArray data; QXmlStreamReader reader; if (f.suffix() == "fb2") { if (!file.open(QFile::ReadOnly | QFile::Text)) { return; } reader.setDevice(&file); } else if (f.suffix() == "zip") { int res = unzipFile(filename, data); if (0 != res) { return; } reader.addData(data); } reader.readNext(); if (reader.isStartDocument()) { record.setEncoding(reader.documentEncoding().toString()); } if (reader.readNextStartElement()) { if (reader.name() == "FictionBook") { if (reader.readNextStartElement()) { if (reader.name() == "description") { if (reader.readNextStartElement()) { if (reader.name() == "title-info") { while (reader.readNextStartElement()) { if (reader.name() == "genre") { QString genre = reader.readElementText(); if (reader.attributes().hasAttribute("match")) { int match = reader.attributes().value("match").toInt(); record.addGenre(genre, match); } else record.addGenre(genre); } else if (reader.name() == "author") { Person *tmpAuthor = new Person(); while (reader.readNextStartElement()) { if (reader.name() == "first-name") { tmpAuthor->setFirstName(reader.readElementText()); } if (reader.name() == "middle-name") { tmpAuthor->setMiddleName(reader.readElementText()); } if (reader.name() == "last-name") { tmpAuthor->setLastName(reader.readElementText()); } if (reader.name() == "nickname") { tmpAuthor->setNickname(reader.readElementText()); } if (reader.name() == "home-page") { tmpAuthor->addHomePage(reader.readElementText()); } if (reader.name() == "email") { tmpAuthor->addEmail(reader.readElementText()); } if (reader.name() == "id") { tmpAuthor->setId(reader.readElementText()); } } record.addAuthor(*tmpAuthor); delete tmpAuthor; } else if (reader.name() == "book-title") { record.setBookTitle(reader.readElementText()); } else if (reader.name() == "sequence") { if (reader.attributes().hasAttribute("name")) { QString sequence = reader.attributes().value("name").toString(); if (reader.attributes().hasAttribute("number")) { int number = reader.attributes().value("number").toInt(); record.addSequence(sequence, number); } else record.addSequence(sequence); } } else reader.skipCurrentElement(); } } } } } } } file.close(); }
int deref_after_move_ok() { Person p; auto x = p.move_age(); return *x; }
void FahrtagWindow::itemChanged(QListWidgetItem *item , AActivity::Category kat, bool isExtern) { /* item: Das Item das Verändert wurde */ /* kat: Die Kategorie, auf die gebucht wird */ /* is Extern: Gibt an ob die Person extern ist */ // Laden der Informationen zur geänderten Person QString text = item->text(); QStringList liste = text.split(QRegExp("\\s*;\\s*")); QString name = liste.at(0); QString bem = ""; QTime start = QTime(0,0); QTime ende = QTime(0,0); QString aufgabe = AActivity::getStringFromCategory(kat); if (liste.length() > 1) { bem = liste.at(1); } if (bem.toUpper().contains("EXTERN")) isExtern = true; Person *person; if (isExtern) { person = new Person(name); person->setAusbildungTf(true); person->setAusbildungZf(true); person->setAusbildungRangierer(true); person->addActivity(fahrtag, kat); fahrtag->addPerson(person, bem, start, ende, aufgabe); if (listeMitNamen->contains(item)) { fahrtag->removePerson(listeMitNamen->value(item)); listeMitNamen->remove(item); ui->tablePersonen->removeRow(ui->tablePersonen->row(listToTable->value(item))); namen->remove(name); } return; } else if (!fahrtag->getPersonal()->personExists(name)) { QMessageBox::information(this, "Person nicht gefunden", "Die eingegebene Person konnte nicht gefunden werden!"); return; } person = fahrtag->getPersonal()->getPerson(name); // Die Person ist in Ordnung und kann jetzt übernommen werden name = person->getName(); if (listeMitNamen->contains(item)) { if (listeMitNamen->value(item) == name) { // Der Name hat sich nicht verändert, lediglich die Bemerkungen updaten fahrtag->updatePersonBemerkung(person, bem); return; } else { // Der Name wurde verändert -> alte Person löschen und dann verfahren, als ob person nicht vorhanden wäre QString nameAlt = listeMitNamen->value(item); AActivity::Infos *info = fahrtag->getIndividual(person); start = info->beginn; ende = info->ende; aufgabe = info->aufgabe; fahrtag->removePerson(nameAlt); // Alte Person von Fahrtag lösen listeMitNamen->remove(item); ui->tablePersonen->removeRow(ui->tablePersonen->row(listToTable->value(item))); listToTable->remove(item); } } if (fahrtag->addPerson(person, bem, start, ende, aufgabe) == ManagerPersonal::FalscheQualifikation) { QMessageBox::warning(this, "Fehlene Qualifikation", "Die Aufgabe kann/darf nicht von der angegebenen Person übernommen werden, da dies eine Aufgabe ist, welche eine Ausbildung voraussetzt."); return; } person->addActivity(fahrtag, kat); listeMitNamen->insert(item, name); // Zeile für die Person in die Tabelle einfügen ui->tablePersonen->insertRow(0); QTableWidgetItem *zelleName = new QTableWidgetItem(name); zelleName->setFlags(Qt::NoItemFlags); ui->tablePersonen->setItem(0,0,zelleName); if (start != QTime(0, 0)) { ui->tablePersonen->setItem(0, 1, new QTableWidgetItem(start.toString("hh:mm"))); } if (ende != QTime(0,0)) { ui->tablePersonen->setItem(0, 2, new QTableWidgetItem(ende.toString("hh:mm"))); } QTableWidgetItem *zelleAufgabe = new QTableWidgetItem(AActivity::getStringFromCategory(kat)); zelleAufgabe->setFlags(Qt::NoItemFlags); ui->tablePersonen->setItem(0,3,zelleAufgabe); listToTable->insert(item, zelleName); namen->insert(name); }
int main(int argc, char const *argv[]){ List friendList; int width, height; initscr(); start_color(); scrollok(curscr,TRUE); init_pair(1, COLOR_RED, COLOR_BLACK); init_pair(2, COLOR_GREEN, COLOR_BLACK); init_pair(3, COLOR_CYAN, COLOR_BLACK); init_pair(4, COLOR_MAGENTA, COLOR_BLACK); init_pair(5, COLOR_WHITE, COLOR_BLACK); getmaxyx(curscr,height,width); int move_this_y_1 = (height/2)-1; int move_this_y_2 = (height/2)+1; mvprintw(move_this_y_1,(width-strlen("Bienvenido a tu agenda de amigos."))/2,"Bienvenido a tu agenda de amigos."); mvprintw(move_this_y_2,(width-strlen("Laboratorio 5 de programación 3."))/2,"Laboratorio 5 de programación 3."); getch(); clear(); refresh(); attron(A_BOLD); attron(COLOR_PAIR(4)); mvprintw(0,0,"%i",friendList.size()); mvprintw(move_this_y_1-2,(width-strlen(".-*-.-*-.-*MENU.-*-.-*-.-*"))/2,".-*-.-*-.-*MENU.-*-.-*-.-*"); attroff(COLOR_PAIR(4)); attron(COLOR_PAIR(3)); mvprintw(move_this_y_1-1,(width-strlen("1.-) Agregar contacto."))/2,"1.-) Agregar contacto."); attroff(COLOR_PAIR(3)); attron(COLOR_PAIR(2)); mvprintw(move_this_y_1,(width-strlen("2.-) Listar contactos."))/2,"2.-) Listar contactos."); attroff(COLOR_PAIR(2)); attron(COLOR_PAIR(3)); mvprintw(height/2,(width-strlen("3.-) Eliminar contacto."))/2,"3.-) Eliminar contacto."); attroff(COLOR_PAIR(3)); attron(COLOR_PAIR(1)); mvprintw(move_this_y_2,(width-strlen("4.-) Salir."))/2,"4.-) Salir."); attroff(COLOR_PAIR(1)); attroff(A_BOLD); char ans = getch(); while(ans == '1' || ans == '2' || ans == '3'){ clear(); refresh(); if(ans == '1'){ int nameCounter = 0; char nombre[26]; bool nameEnd = false; attron(COLOR_PAIR(3)); mvprintw(move_this_y_1,(width-strlen("Ingrese nombre: "))/2,"Ingrese nombre: "); attroff(COLOR_PAIR(3)); while(nameCounter < 26 && !nameEnd){ noecho(); char temp; temp = getch(); if((temp >= 65 && temp <= 90) || (temp >= 97 && temp <= 122)){ echo(); addch(temp); nombre[nameCounter] = temp; nameCounter++; } else if(temp == 10 && nameCounter != 0){ nameEnd = true; nombre[nameCounter] = '\0'; } } attron(COLOR_PAIR(2)); mvprintw(move_this_y_1+1,(width-strlen("Ingrese numero: "))/2,"Ingrese numero: "); attroff(COLOR_PAIR(2)); int numberCounter = 0; char number[10]; while(numberCounter < 9){ noecho(); char temp; temp = getch(); if(temp >= '0' && temp <= '9' && numberCounter != 4){ echo(); addch(temp); number[numberCounter] = temp; numberCounter++; } if(numberCounter == 4 && temp == '-'){ echo(); addch(temp); number[numberCounter] = temp; numberCounter++; } } number[9] = '\0'; friendList.push_back(Person(nombre,number)); mvprintw(0,0,"%i",friendList.size()); getch(); echo(); clear(); } else if(ans == '2'){ clear(); refresh(); getmaxyx(curscr,height,width); attron(A_BOLD); attron(COLOR_PAIR(4)); mvprintw(height/4,width/4,"Nombre"); attroff(COLOR_PAIR(4)); attron(COLOR_PAIR(5)); mvprintw(height/4,width/2,"Celular"); attroff(COLOR_PAIR(5)); attroff(A_BOLD); for (int i = 0; i < friendList.size(); ++i){ attron(COLOR_PAIR(2)); mvprintw((height/4)+2+i,width/4,friendList.at(i).getName()); attroff(COLOR_PAIR(2)); attron(COLOR_PAIR(3)); mvprintw((height/4)+2+i,width/2,friendList.at(i).getPhone()); attroff(COLOR_PAIR(3)); } getch(); } else if(ans == '3'){ clear(); refresh(); getmaxyx(curscr,height,width); attron(A_BOLD); attron(COLOR_PAIR(4)); mvprintw(height/4,(width/6)+6,"Nombre"); attroff(COLOR_PAIR(4)); attron(COLOR_PAIR(5)); mvprintw(height/4,(width/4)+12,"Celular"); attroff(COLOR_PAIR(5)); attroff(A_BOLD); for (int i = 0; i < friendList.size(); ++i){ attron(COLOR_PAIR(2)); mvprintw((height/4)+2+i,(width/6)+6,friendList.at(i).getName()); attroff(COLOR_PAIR(2)); attron(COLOR_PAIR(3)); mvprintw((height/4)+2+i,(width/4)+12,friendList.at(i).getPhone()); attroff(COLOR_PAIR(3)); } int nameCounter = 0; char nombre[26]; bool nameEnd = false; attron(A_BOLD); attron(COLOR_PAIR(2)); mvprintw(height/4,(width/2)+8,"Nombre: "); attroff(COLOR_PAIR(2)); attroff(A_BOLD); while(nameCounter < 26 && !nameEnd){ noecho(); char temp; temp = getch(); if((temp >= 65 && temp <= 90) || (temp >= 97 && temp <= 122)){ echo(); addch(temp); nombre[nameCounter] = temp; nameCounter++; } else if(temp == 10 && nameCounter != 0){ nameEnd = true; nombre[nameCounter] = '\0'; } } Person persona; persona.setName(nombre); int position = friendList.find(persona); mvprintw(0,0,"%i", position); getch(); if(position != -1){ friendList.erase(position); } } clear(); refresh(); attron(A_BOLD); attron(COLOR_PAIR(4)); mvprintw(move_this_y_1-2,(width-strlen(".-*-.-*-.-*MENU.-*-.-*-.-*"))/2,".-*-.-*-.-*MENU.-*-.-*-.-*"); attroff(COLOR_PAIR(4)); attron(COLOR_PAIR(3)); mvprintw(move_this_y_1-1,(width-strlen("1.-) Agregar contacto."))/2,"1.-) Agregar contacto."); attroff(COLOR_PAIR(3)); attron(COLOR_PAIR(2)); mvprintw(move_this_y_1,(width-strlen("2.-) Listar contactos."))/2,"2.-) Listar contactos."); attroff(COLOR_PAIR(2)); attron(COLOR_PAIR(3)); mvprintw(height/2,(width-strlen("3.-) Eliminar contacto."))/2,"3.-) Eliminar contacto."); attroff(COLOR_PAIR(3)); attron(COLOR_PAIR(1)); mvprintw(move_this_y_2,(width-strlen("4.-) Salir."))/2,"4.-) Salir."); attroff(COLOR_PAIR(1)); attroff(A_BOLD); ans = getch(); } endwin(); return 0; }
void FahrtagWindow::on_tablePersonen_cellChanged(int row, int column) { if (nehme) { nehme = false; // column 1: Name, 2: Beginn, 3: Ende, 4: Aufgabe // wenn name geändert wurde, muss der Index über die namen neu aufgebaut werden, da es sonst probleme gibt if (column == 0) { QStringList *neu = new QStringList(); for(int i = 1; i <= ui->tablePersonen->rowCount(); i++) { QString n = ""; if (ui->tablePersonen->item(i, 0) != nullptr) n = ui->tablePersonen->item(i, 0)->text(); neu->append(n); if (namen->contains(n)) { namen->remove(n); } } if (namen->size() == 1) { fahrtag->removePerson(namen->values().at(0)); } } QString name = ""; if (ui->tablePersonen->item(row,0) != nullptr) name = ui->tablePersonen->item(row,0)->text(); QString beginn = ""; QTime beginnZ = QTime(0,0); if (ui->tablePersonen->item(row,1) != nullptr) { beginn = ui->tablePersonen->item(row,1)->text(); if (beginn != "") { beginnZ = QTime::fromString(beginn, "h:mm"); ui->tablePersonen->item(row,1)->setText(beginnZ.toString("hh:mm")); } } QString ende = ""; QTime endeZ = QTime(0,0); if (ui->tablePersonen->item(row,2) != nullptr) { ende = ui->tablePersonen->item(row,2)->text(); if (ende != "") { endeZ = QTime::fromString(ende, "h:mm"); ui->tablePersonen->item(row,2)->setText(endeZ.toString("hh:mm")); } } QString aufgabe = ""; if (ui->tablePersonen->item(row,3) != nullptr) aufgabe = ui->tablePersonen->item(row,3)->text(); if (name.toUpper().contains("EXTERN")) { Person *p = new Person(name); p->setAusbildungTf(true); p->setAusbildungZf(true); p->setAusbildungRangierer(true); fahrtag->addPerson(p, "", beginnZ, endeZ, aufgabe); } else { ManagerPersonal::Misstake antw = fahrtag->addPerson(name, "", beginnZ, endeZ, aufgabe); switch (antw) { case ManagerPersonal::OK: break; case ManagerPersonal::PersonNichtGefunden: QMessageBox::warning(this, "Fehler", "Die eingegebene Person konnte im System nicht gefunden werden."); break; case ManagerPersonal::FalscheQualifikation: QMessageBox::warning(this, "Fehlene Qualifikation", "Die Aufgabe kann/darf nicht von der angegebenen Person übernommen werden, da dies eine Aufgabe ist, welche eine Ausbildung voraussetzt."); break; default: QMessageBox::warning(this, "Sonstiger Fehler", "Während der Verarbeitung der Eingabe ist ein Fehler unterlaufen.\nPrüfen Sie Ihre Eingaben und versuchen es erneut!"); break; } } nehme = true; } }
int get_age () { return person.get_age(); }
// operator overloading Person Person::operator+ (Person person) { Person temp("blank",22," OPERATOR OVERLOAD!"); temp.setSpeak(person.getSpeak()+temp.getSpeak()); return temp; }