Example #1
0
/*	FUNCTION:		ViewBook :: DragDropImage
	ARGUMENTS:		texture_id
					mouse_x
					mouse_y
	RETURN:			true if source ownership acquired
	DESCRIPTION:	Hook function called when user drags/drops image to app window	
*/
bool ViewBook :: SurfaceUpdate(MediaSource *source, float mouse_x, float mouse_y)
{
	Paper::TEXTURE_SIDE side = Paper::UNASSIGNED_TEXTURE;
	Paper *page = GetPage(mouse_x, mouse_y, (int *)&side);
	
	LockGL();
	int index = -1;
	if (page == fPages[PAGE_LEFT])
		index = 0;
	else if (page == fPages[PAGE_RIGHT])
		index = 3;
	else if (page == fPages[PAGE_MIDDLE])
	{
		if (side == Paper::FRONT_TEXTURE)
			index = 1;
		else if (side == Paper::BACK_TEXTURE)
			index = 2;
	}
	if (index >= 0)
	{
		if (fMediaSources[index] != GetDefaultMediaSource())
			delete fMediaSources[index];
	} 
	page->SetMediaSource(side, source);
	fMediaSources[index] = source;
	UnlockGL();
	
	return true;
}
Example #2
0
array<Paper,100> Teacher::createManyCrystals() {
  Paper *prototype = new Paper("雪の結晶");
  drawCrystal(*prototype);
  cutAccordanceWithLine(*prototype);

  array<Paper, 100> papers;

  for (int n = 0; n < (int)papers.size(); n++) {
    papers[n] = *(Paper*)(prototype->createClone());
  }
  return papers;
}
Example #3
0
        void Print() {
            Ink ink;
            Paper paper;
            PrinterEngine engine;

            ink.CheckInk();
            paper.CheckPaper();
            engine.LoadDocument();
            engine.FormatDocumentData();
            paper.GetPaperForPrinting();
            engine.PrepareLaser();
            engine.WarmUp();
            engine.InkToPaper();
        }
Example #4
0
void Simulator::burn(Paper& p)
{
    int rmin = 0;
    int cmin = 0;
    int rmax = p.rows - 1;
    int cmax = p.columns - 1;
    float k = 0.4;
    float left = 0, right = 0, top = 0, bottom = 0, self = 0, Tnew = 0, rowid = 0, columnid =0;
    
    
    for (int i = 1; i< p.particleCount;i++)
    {
        
        self = p.paperParticles[i].temperature;
        Tnew = p.paperParticles[i].temperature;
        rowid = i%p.rows;
        columnid = i/p.columns;
        if (columnid != cmin)
        {
            left = p.paperParticles[i-(p.rows)].temperature;
            Tnew = Tnew + ((k + RandomDouble(-0.1, 0.1)) * (left -self));
        }
        if (columnid != cmax)
        {
            right = p.paperParticles[i+(p.rows)].temperature;
            Tnew = Tnew + ((k + RandomDouble(-0.1, 0.1)) * (right - self));
            
        }
        if (rowid != rmin)
        {
            top = p.paperParticles[i -1].temperature;
            Tnew = Tnew + ((k + RandomDouble(-0.1, 0.1)) * (top - self));
            
        }
        if (rowid != rmax)
        {
            bottom = p.paperParticles[i +1].temperature;
            Tnew = Tnew + ((k + RandomDouble(-0.1, 0.1)) *(bottom - self));
        }
        
        p.paperParticles[i].temperature = Tnew;
        
    }
    
    p.drawPaper();
    p.drawMesh();
    
}
Example #5
0
//----------------------------------------------------------------
void Collection::edit_paper()
{
  //Need a mechanism to have the current paper?
  Paper * paper = dynamic_cast<Paper *>(_current_library->get_current_entry());
  if ( ! paper )
    {
      Entry * entry = _current_library->get_current_entry();
      if ( entry->open_new_dialog()  == QDialog::Accepted )
	{
	  update_paper_list();
	}
    }
  else if ( paper->open_new_dialog()  == QDialog::Accepted )
    {
      update_paper_list();
    }
}
Example #6
0
//----------------------------------------------------------------
void Collection::new_paper()
{
  //we should not try to add a paper if no current library;
  if ( !_current_library )
    {
      QMessageBox::about(this, tr("Error"),
			 tr("Error: you have no Libraries defined\n"
			    "you cannot create a new paper"));
      return;
    }
  Paper * paper = new Paper();
  if ( paper->open_new_dialog()  == QDialog::Accepted )
    {
      _stdout << "We should have some data in here now: " 
	      << paper->get_author() << endl;
      _stdout.flush();
      //add the entry to the library
      _current_library->add_entry(paper);
      //add the entry to the list
      add_paper_to_list(*paper,_paper_list);
      update_library_list();
    }
}
Example #7
0
Paper DatabaseHelper::getPaper(int paperId)
{
    QSqlQuery query;
    query.prepare("SELECT year, book_title_id, title, path, comment FROM pl_paper WHERE paper_id = :paper_id");
    query.bindValue(":paper_id", paperId);
    query.exec();

    Paper paper;
    if (!query.last()) return paper;

    paper.setId(paperId);
    paper.setYear(query.value(0).toInt());
    paper.setBookTitle(getBookTitle(query.value(1).toInt()));
    paper.setTitle(query.value(2).toString().toStdString());
    paper.setPath(query.value(3).toString().toStdString());
    paper.setComment(query.value(4).toString().toStdString());

    query.prepare("SELECT author_id FROM pl_paper2author WHERE paper_id = :paper_id ORDER BY rowid ASC");
    query.bindValue(":paper_id", paperId);
    query.exec();

    vector<string> authors;
    while (query.next()) {
        int authorId = query.value(0).toInt();
        authors.push_back(getAuthor(authorId));
    }

    query.prepare("SELECT tag_id FROM pl_paper2tag WHERE paper_id = :paper_id");
    query.bindValue(":paper_id", paperId);
    query.exec();

    vector<string> tags;
    while (query.next()) {
        int tagId = query.value(0).toInt();
        tags.push_back(getTag(tagId));
    }

    paper.setAuthors(authors);
    paper.setTags(tags);

    return paper;
}
Example #8
0
void Pretreatment::countPaper(std::string path)
{
	int num[100] = {0};
	PaperReader pr(path);

	Paper p;
	while(pr.getNextPaper(p))
	{
		cout<<p.getIndex()<<endl;
		if(p.getYear() != 0)
		{
			num[p.getYear()-1936]++;
		}
	}

	ofstream fout;
	fout.open("./paperCount", ios::out);
	
	for(int i = 0; i < 100; i++)
	{
		fout<<i+1936<<" "<<num[i]<<endl;
	}
	fout.close();
}
Example #9
0
//----------------------------------------------------------------
void Collection::import_paper()
{
  //we should not try to add a paper if no current library;
  if ( !_current_library )
    {
      QMessageBox::about(this, tr("Error"),
			 tr("Error: you have no Libraries defined\n"
			    "you cannot create a new paper"));
      return;
    }
  QWebPage * page = _rss_box->page();
  
  QWebFrame * frame = page->mainFrame();

  //now create a new paper and parse out the values we want.
  _parser->setData(frame->toHtml());
  _stdout << "Collection::import_paper title" << _parser->getTitle() << endl;
  _stdout << "Collection::import_paper authors" << _parser->getAuthors() << endl;

  Paper * paper = new Paper();
  paper->set_title(_parser->getTitle());
  paper->set_author(_parser->getAuthors());
  paper->set_abstract(_parser->getAbstract());
  paper->set_date(_parser->getDate());
  paper->set_arxiv_number(_parser->getNumber());

  //Download the damn thing
  _manager = new QNetworkAccessManager(this);
  _manager->get(QNetworkRequest(_parser->getDownloadLocation()));
  connect(_manager, SIGNAL(finished(QNetworkReply*)),
  	  this, SLOT(download_finished(QNetworkReply*)));

  QDir directory(_current_library->get_library_directory()+"/"+_parser->getPaperName());

  _stdout << "Collection::import_paper " <<  directory.absolutePath() << endl; 

  paper->set_file_name(directory.absolutePath());
  
  //add the entry to the library
  _current_library->add_entry(paper);

  //add the entry to the list
  add_paper_to_list(*paper,_paper_list);
  update_library_list();

}
Example #10
0
void Pretreatment::paperDatePretreat(string path)
{

	int max = 0, min = INT_MAX;
	set<string> s;

	PaperReader pr(path);

	Paper p;
	
	while(pr.getNextPaper(p))
	{
		cout<<p.getIndex()<<endl;
		if(p.getYear() < min && p.getYear() != 0)
		{
			min = p.getYear();
		}

		if(p.getYear() > max)
		{
			max = p.getYear();
		}

		s.insert(p.getVenue());
	}

	ofstream fout;
	fout.open("./paperResult_2000", ios::out);
	fout<<"min : "<<min<<" max : "<<max<<endl;

	set<string>::iterator it;

	for(it=s.begin(); it != s.end(); it++)
	{
		fout<<*it<<endl;
	}
	fout.close();

}
Example #11
0
void MainFrameUI::paperReady(Paper p)
{
    label_papername->setText(p.getDescription());
    _exam->showPaper(p);
}
Example #12
0
void Book::addPaper(Paper p) {
    bookContent[p.getNumber()] = &p;
}
Example #13
0
void DatabaseHelper::removePaper(const Paper& paper)
{
    removePaper(paper.getId());
}
Example #14
0
int DatabaseHelper::updatePaper(const Paper& paper)
{
    removePaper(paper.getId());
    return addPaper(paper);
}
Example #15
0
int DatabaseHelper::addPaper(const Paper& paper)
{
    int bookTitleId = getBookTitleId(paper.getBookTitle());
    if (bookTitleId == -1) {
        bookTitleId = addBookTitle(paper.getBookTitle());
    }

    vector<int> authorsId(paper.getAuthors().size());
    for (vector<int>::size_type i = 0; i < paper.getAuthors().size(); ++i) {
        const string& author = paper.getAuthors().at(i);
        int authorId = getAuthorId(author);
        if (authorId == -1) {
            authorId = addAuthor(author);
        }
        authorsId[i] = authorId;
    }

    vector<int> tagsId(paper.getTags().size());
    for (vector<int>::size_type i = 0; i < paper.getTags().size(); ++i) {
        const string& tag = paper.getTags().at(i);
        int tagId = getTagId(tag);
        if (tagId == -1) {
            tagId = addTag(tag);
        }
        tagsId[i] = tagId;
    }

    QSqlQuery query;
    if (paper.getId() <= 0) {
        query.prepare("INSERT INTO pl_paper(year, book_title_id, title, path, comment) "
                      "VALUES(:year, :book_title_id, :title, :path, :comment)");
        query.bindValue(":year", paper.getYear());
        query.bindValue(":book_title_id", bookTitleId);
        query.bindValue(":title", paper.getTitle().c_str());
        query.bindValue(":path", paper.getPath().c_str());
        query.bindValue(":comment", paper.getComment().c_str());
    } else {
        query.prepare("INSERT INTO pl_paper(paper_id, year, book_title_id, title, path, comment) "
                      "VALUES(:paper_id, :year, :book_title_id, :title, :path, :comment)");
        query.bindValue(":paper_id", paper.getId());
        query.bindValue(":year", paper.getYear());
        query.bindValue(":book_title_id", bookTitleId);
        query.bindValue(":title", paper.getTitle().c_str());
        query.bindValue(":path", paper.getPath().c_str());
        query.bindValue(":comment", paper.getComment().c_str());
    }
    query.exec();

    int paperId = query.lastInsertId().toInt();
    QVariantList paperIdList, authorIdList;
    for (int i = 0; i < static_cast<int>(authorsId.size()); ++i) {
        paperIdList.append(paperId);
        authorIdList.append(authorsId[i]);
    }

    query.prepare("INSERT INTO pl_paper2author(paper_id, author_id) "
                  "VALUES(:paper_id, :author_id)");
    query.bindValue(":paper_id", paperIdList);
    query.bindValue(":author_id", authorIdList);
    query.execBatch();

    paperIdList.clear();
    QVariantList tagIdList;
    for (int i = 0; i < static_cast<int>(tagsId.size()); ++i) {
        paperIdList.append(paperId);
        tagIdList.append(tagsId[i]);
    }

    query.prepare("INSERT INTO pl_paper2tag(paper_id, tag_id) "
                  "VALUES(:paper_id, :tag_id)");
    query.bindValue(":paper_id", paperIdList);
    query.bindValue(":tag_id", tagIdList);
    query.execBatch();

    return paperId;
}
void TDefense::studentAction()
{
    QPoint *myTarget = myStudent->getTarget();
    studentShoot(myTarget);

    for (int i = 0; i < myStudentBullets.size(); i++)
    {
        Bullet *curBullet = myStudentBullets[i];
        double bX = curBullet->getX();
        double bY = curBullet->getY();
        double bVX = curBullet->getVX();
        double bVY = curBullet->getVY();
        int bHeight = curBullet->getImage().height();
        int bWidth = curBullet->getImage().width();

        curBullet->move();
        curBullet->setVX(bVX);
        curBullet->setVY(bVY);

        for (int j = 0; j < myProblems.size(); j++)
        {
            Problem *secondProblem = myProblems[j];
            if (curBullet->intersects(secondProblem))
            {
                secondProblem->health--;
                if (secondProblem->health == 0)
                {
                    funds += 10;
                    myProblems.remove(j);
                    numEnemiesShot++;
                }
                studentShotFired = false;
                studentBulletAdded = false;
            }
            else if ((bY <= 0 && bVY < 0) || (bX <= 0 && bVX < 0 || (gpHeight <= (bY + bHeight)) && bY > 0 && bVY > 0) || ((gpWidth == (bX + bWidth)) && bVX > 0 && bVX > 0))
            {
                studentShotFired = false;
                studentBulletAdded = false;
            } // end else if
            if (!studentShotFired && myStudentBullets.size() > 0)
            {
                myStudentBullets.remove(i);
            } // end if
        } // end inner for

        for (int j = 0; j < myAssignments.size(); j++)
        {
            Assignment *secondAssignment = myAssignments[j];
            if (curBullet->intersects(secondAssignment))
            {
                secondAssignment->health--;
                secondAssignment->setImage(assignment2);
                if (secondAssignment->health == 0)
                {
                    funds += 20;
                    myAssignments.remove(j);
                    numEnemiesShot++;
                }
                studentShotFired = false;
                studentBulletAdded = false;
            }
            else if ((bY <= 0 && bVY < 0) || (bX <= 0 && bVX < 0 || (gpHeight <= (bY + bHeight)) && bY > 0 && bVY > 0) || ((gpWidth == (bX + bWidth)) && bVX > 0 && bVX > 0))
            {
                studentShotFired = false;
                studentBulletAdded = false;
            } // end else if
            if (!studentShotFired && myStudentBullets.size() > 0)
            {
                myStudentBullets.remove(i);
            } // end if
        } // end inner for

        for (int j = 0; j < myPapers.size(); j++)
        {
            Paper *secondPaper = myPapers[j];
            if (curBullet->intersects(secondPaper))
            {
                secondPaper->health--;
                switch (secondPaper->health)
                {
                case 4:
                    secondPaper->setImage(paper2);
                    break;
                case 3:
                    secondPaper->setImage(paper3);
                    break;
                case 2:
                    secondPaper->setImage(paper4);
                    break;
                case 1:
                    secondPaper->setImage(paper5);
                    break;
                }
                if (secondPaper->health == 0)
                {
                    funds += 40;
                    myPapers.remove(j);
                    numEnemiesShot++;
                }
                studentShotFired = false;
                studentBulletAdded = false;
            }
            else if ((bY <= 0 && bVY < 0) || (bX <= 0 && bVX < 0 || (gpHeight <= (bY + bHeight)) && bY > 0 && bVY > 0) || ((gpWidth == (bX + bWidth)) && bVX > 0 && bVX > 0))
            {
                studentShotFired = false;
                studentBulletAdded = false;
            } // end else if
            if (!studentShotFired && myStudentBullets.size() > 0)
            {
                myStudentBullets.remove(i);
            } // end if
        } // end inner for

        for (int j = 0; j < myMidterms.size(); j++)
        {
            Midterm *secondMidterm = myMidterms[j];
            if (curBullet->intersects(secondMidterm))
            {
                secondMidterm->health--;
                switch (secondMidterm->health)
                {
                case 17:
                    secondMidterm->setImage(midterm4);
                    break;
                case 16:
                    secondMidterm->setImage(midterm3);
                    break;
                case 15:
                    secondMidterm->setImage(midterm2);
                    break;
                case 14:
                    secondMidterm->setImage(midterm1);
                    break;
                case 13:
                    secondMidterm->setImage(midtermC);
                    break;
                case 12:
                    secondMidterm->setImage(midterm5);
                    break;
                case 11:
                    secondMidterm->setImage(midterm4);
                    break;
                case 10:
                    secondMidterm->setImage(midterm3);
                    break;
                case 9:
                    secondMidterm->setImage(midterm2);
                    break;
                case 8:
                    secondMidterm->setImage(midterm1);
                    break;
                case 7:
                    secondMidterm->setImage(midtermB);
                    break;
                case 6:
                    secondMidterm->setImage(midterm5);
                    break;
                case 5:
                    secondMidterm->setImage(midterm4);
                    break;
                case 4:
                    secondMidterm->setImage(midterm3);
                    break;
                case 3:
                    secondMidterm->setImage(midterm2);
                    break;
                case 2:
                    secondMidterm->setImage(midterm1);
                    break;
                case 1:
                    secondMidterm->setImage(midtermA);
                    break;
                }
                if (secondMidterm->health == 0)
                {
                    funds += 300;
                    myMidterms.remove(j);
                    numEnemiesShot++;
                }
                studentShotFired = false;
                studentBulletAdded = false;
            }
            else if ((bY <= 0 && bVY < 0) || (bX <= 0 && bVX < 0 || (gpHeight <= (bY + bHeight)) && bY > 0 && bVY > 0) || ((gpWidth == (bX + bWidth)) && bVX > 0 && bVX > 0))
            {
                studentShotFired = false;
                studentBulletAdded = false;
            } // end else if
            if (!studentShotFired && myStudentBullets.size() > 0)
            {
                myStudentBullets.remove(i);
            } // end if
        } // end inner for
    } // end outer for
} // end method