Réagencement pour le TP XML
This commit is contained in:
parent
2bd65d0ce6
commit
19f7a90a8c
12 changed files with 50 additions and 22 deletions
|
@ -39,28 +39,6 @@ endif()
|
|||
|
||||
add_executable(compte_mots compte_mots.cpp)
|
||||
|
||||
add_executable(parseXML xmlParser.cpp xmlParser.h Circle.h Circle.cpp Group.cpp Group.h DrawingElement.cpp DrawingElement.h DrawingElement.cpp)
|
||||
target_link_libraries(parseXML sfml-window sfml-graphics)
|
||||
|
||||
find_path(PugiXML_INCLUDE_DIR pugixml.hpp)
|
||||
target_link_libraries(parseXML pugixml)
|
||||
target_include_directories(parseXML PRIVATE ${PugiXML_INCLUDE_DIR})
|
||||
target_link_directories(parseXML PRIVATE ${PugiXML_INCLUDE_DIR})
|
||||
|
||||
|
||||
if(GTest_FOUND)
|
||||
add_executable(xmlTest gTestXMLParser.cpp Circle.h xmlParser.h xmlParser.cpp Circle.cpp Group.cpp Group.h DrawingElement.cpp DrawingElement.h DrawingElement.cpp)
|
||||
|
||||
target_link_libraries(xmlTest sfml-window sfml-graphics)
|
||||
|
||||
target_include_directories(xmlTest PRIVATE ${PugiXML_INCLUDE_DIR})
|
||||
target_link_directories(xmlTest PRIVATE ${PugiXML_INCLUDE_DIR})
|
||||
target_link_libraries(xmlTest pugixml)
|
||||
|
||||
target_link_libraries(xmlTest ${GTEST_BOTH_LIBRARIES})
|
||||
target_link_options(xmlTest PRIVATE -pthread)
|
||||
endif()
|
||||
|
||||
add_library(polynomial SHARED Polynomial.cpp Polynomial.tpp)
|
||||
#target_link_libraries(polynomial -static)
|
||||
|
||||
|
|
|
@ -1,65 +0,0 @@
|
|||
//
|
||||
// Created by trotfunky on 14/05/19.
|
||||
//
|
||||
|
||||
#include "Circle.h"
|
||||
|
||||
namespace xmlParser
|
||||
{
|
||||
|
||||
Circle::Circle(std::string label, float x, float y, float r, const sf::Color& color) : DrawingElement(std::move(label),x,y,color), r(2)
|
||||
{
|
||||
shape = new sf::CircleShape(r);
|
||||
shape->setPosition(x-r,y-r);
|
||||
shape->setFillColor(color);
|
||||
}
|
||||
|
||||
Circle::Circle(const pugi::xml_node& node) : DrawingElement(node), r(node.attribute("r").as_int(2))
|
||||
{
|
||||
if(label == "Test DrawingElement")
|
||||
{
|
||||
label = "Test Circle";
|
||||
}
|
||||
shape = new sf::CircleShape(r);
|
||||
shape->setPosition(x-r,y-r);
|
||||
shape->setFillColor(color);
|
||||
}
|
||||
|
||||
void Circle::draw(sf::RenderWindow& window)
|
||||
{
|
||||
window.draw(*(dynamic_cast<sf::CircleShape*>(shape)));
|
||||
}
|
||||
|
||||
float Circle::getR() const
|
||||
{
|
||||
return r;
|
||||
}
|
||||
|
||||
void Circle::setR(float newR)
|
||||
{
|
||||
r = newR;
|
||||
dynamic_cast<sf::CircleShape*>(shape)->setRadius(r);
|
||||
shape->setPosition(x-r,y-r);
|
||||
}
|
||||
|
||||
const std::string Circle::toString() const
|
||||
{
|
||||
std::stringstream string;
|
||||
string << label << " at x:" << getX() << " y:" << getY() << " | r:" << getR();
|
||||
string << " color:" << getStringColor();
|
||||
return(string.str());
|
||||
}
|
||||
|
||||
|
||||
void Circle::setX(float newX)
|
||||
{
|
||||
DrawingElement::setX(newX);
|
||||
shape->setPosition(x-r,y-r);
|
||||
}
|
||||
|
||||
void Circle::setY(float newY)
|
||||
{
|
||||
DrawingElement::setY(newY);
|
||||
shape->setPosition(x-r,y-r);
|
||||
}
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
//
|
||||
// Created by trotfunky on 07/05/19.
|
||||
//
|
||||
|
||||
#ifndef SNIPPETS_CIRCLE_H
|
||||
#define SNIPPETS_CIRCLE_H
|
||||
|
||||
#include <string>
|
||||
#include <pugixml.hpp>
|
||||
#include <SFML/Graphics.hpp>
|
||||
#include <sstream>
|
||||
|
||||
#include "DrawingElement.h"
|
||||
|
||||
namespace xmlParser
|
||||
{
|
||||
class Circle : public DrawingElement
|
||||
{
|
||||
public:
|
||||
explicit Circle(std::string label = "Test Circle", float x = 0, float y = 1, float r = 2,
|
||||
const sf::Color& color = sf::Color::Yellow);
|
||||
|
||||
explicit Circle(const pugi::xml_node&);
|
||||
|
||||
void draw(sf::RenderWindow&) override;
|
||||
|
||||
void setX(float newX) override;
|
||||
|
||||
void setY(float newY) override;
|
||||
|
||||
float getR() const;
|
||||
void setR(float newR);
|
||||
|
||||
const std::string toString() const override;
|
||||
private:
|
||||
float r;
|
||||
};
|
||||
}
|
||||
#endif //SNIPPETS_CIRCLE_H
|
|
@ -1,99 +0,0 @@
|
|||
#include <utility>
|
||||
|
||||
//
|
||||
// Created by trotfunky on 15/05/19.
|
||||
//
|
||||
|
||||
#include "DrawingElement.h"
|
||||
|
||||
|
||||
namespace xmlParser
|
||||
{
|
||||
DrawingElement::DrawingElement(std::string label, float x, float y, const sf::Color& color) : x(x), y(-y), label(std::move(label)),
|
||||
color(color), shape(nullptr)
|
||||
{}
|
||||
|
||||
DrawingElement::DrawingElement(const pugi::xml_node& node) : x(node.attribute("x").as_int(0)),
|
||||
y(-node.attribute("y").as_int(1)), label(node.attribute("label").as_string("Test DrawingElement")), shape(nullptr)
|
||||
{
|
||||
setColor(node.attribute("color").as_string("Yellow"));
|
||||
}
|
||||
|
||||
void DrawingElement::draw(sf::RenderWindow& window, float referenceX, float referenceY)
|
||||
{
|
||||
setX(x+referenceX);
|
||||
setY(y-referenceY);
|
||||
draw(window);
|
||||
setX(x-referenceX);
|
||||
setY(y+referenceY);
|
||||
}
|
||||
|
||||
float xmlParser::DrawingElement::getX() const
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
void xmlParser::DrawingElement::setX(float newX)
|
||||
{
|
||||
x = newX;
|
||||
|
||||
if(shape != nullptr)
|
||||
{
|
||||
shape->setPosition(x,-y);
|
||||
}
|
||||
}
|
||||
|
||||
float xmlParser::DrawingElement::getY() const
|
||||
{
|
||||
return -y;
|
||||
}
|
||||
|
||||
void xmlParser::DrawingElement::setY(float newY)
|
||||
{
|
||||
y = newY;
|
||||
|
||||
if(shape != nullptr)
|
||||
{
|
||||
shape->setPosition(x,-y);
|
||||
}
|
||||
}
|
||||
|
||||
const sf::Color& xmlParser::DrawingElement::getColor() const
|
||||
{
|
||||
return color;
|
||||
}
|
||||
|
||||
const std::string DrawingElement::getStringColor() const
|
||||
{
|
||||
return(colorToStr(color));
|
||||
}
|
||||
|
||||
void xmlParser::DrawingElement::setColor(const sf::Color& newColor)
|
||||
{
|
||||
color = newColor;
|
||||
|
||||
if(shape != nullptr)
|
||||
{
|
||||
shape->setFillColor(color);
|
||||
}
|
||||
}
|
||||
|
||||
void DrawingElement::setColor(const std::string& stringColor)
|
||||
{
|
||||
color = strToColor(stringColor);
|
||||
}
|
||||
|
||||
const std::string DrawingElement::toString() const
|
||||
{
|
||||
std::stringstream string;
|
||||
string << label << " at x:" << getX() << " y:" << getY();
|
||||
string << " | color:" << getStringColor();
|
||||
return(string.str());
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& ostream, const DrawingElement& element)
|
||||
{
|
||||
ostream << element.toString();
|
||||
return(ostream);
|
||||
}
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
//
|
||||
// Created by trotfunky on 15/05/19.
|
||||
//
|
||||
|
||||
#ifndef SNIPPETS_DRAWINGELEMENT_H
|
||||
#define SNIPPETS_DRAWINGELEMENT_H
|
||||
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <ostream>
|
||||
|
||||
#include <SFML/Graphics.hpp>
|
||||
#include <pugixml.hpp>
|
||||
|
||||
#include "xmlParser.h"
|
||||
|
||||
namespace xmlParser
|
||||
{
|
||||
class DrawingElement
|
||||
{
|
||||
public:
|
||||
|
||||
explicit DrawingElement(std::string label = "Test DrawingElement", float x = 0, float y = 1,
|
||||
const sf::Color& = sf::Color::Yellow);
|
||||
|
||||
explicit DrawingElement(const pugi::xml_node&);
|
||||
|
||||
virtual void draw(sf::RenderWindow&) = 0;
|
||||
void draw(sf::RenderWindow&, float referenceX, float referenceY);
|
||||
|
||||
std::string label;
|
||||
|
||||
virtual float getX() const;
|
||||
virtual void setX(float newX);
|
||||
|
||||
virtual float getY() const;
|
||||
virtual void setY(float newY);
|
||||
|
||||
const sf::Color& getColor() const;
|
||||
const std::string getStringColor() const;
|
||||
void setColor(const sf::Color& newColor);
|
||||
void setColor(const std::string& stringColor);
|
||||
|
||||
virtual const std::string toString() const;
|
||||
|
||||
friend std::ostream& operator<<(std::ostream&,const DrawingElement&);
|
||||
|
||||
protected:
|
||||
float x;
|
||||
float y;
|
||||
|
||||
sf::Color color;
|
||||
|
||||
sf::Shape* shape;
|
||||
};
|
||||
}
|
||||
|
||||
#endif //SNIPPETS_DRAWINGELEMENT_H
|
|
@ -1,84 +0,0 @@
|
|||
//
|
||||
// Created by trotfunky on 15/05/19.
|
||||
//
|
||||
|
||||
#include "Group.h"
|
||||
|
||||
namespace xmlParser
|
||||
{
|
||||
Group::Group(std::string label, float x, float y, const sf::Color& color) : DrawingElement(std::move(label),x,y,color), drawingElements({})
|
||||
{}
|
||||
|
||||
Group::Group(const pugi::xml_node& node) : DrawingElement(node)
|
||||
{
|
||||
if(label == "Test DrawingElement")
|
||||
{
|
||||
label = "Test Group";
|
||||
}
|
||||
|
||||
if(!strncmp(node.name(),"Drawing",7))
|
||||
{
|
||||
x = 0;
|
||||
y = 0;
|
||||
label = "Drawing";
|
||||
color = sf::Color::Transparent;
|
||||
}
|
||||
|
||||
pugi::xml_object_range circleChildren = node.children();
|
||||
for(pugi::xml_node_iterator child : circleChildren)
|
||||
{
|
||||
pugi::xml_node& childNode = (*child);
|
||||
DrawingElement* newElement = !strncmp(childNode.name(),"Circle",6) ? dynamic_cast<DrawingElement*>(new Circle(childNode)) :
|
||||
!strncmp(childNode.name(),"Group",5) ? dynamic_cast<DrawingElement*>(new Group(childNode)) : nullptr;
|
||||
if(newElement != nullptr)
|
||||
{
|
||||
drawingElements.insert(std::make_pair(newElement->label,newElement));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Group::Group(const std::map<std::string, DrawingElement*>& elements) : Group()
|
||||
{
|
||||
std::transform(elements.begin(),elements.end(),std::inserter(drawingElements,drawingElements.begin()),
|
||||
[](std::pair<std::string,DrawingElement*> pair)
|
||||
{
|
||||
return(pair);
|
||||
});
|
||||
}
|
||||
|
||||
bool Group::addDrawingElement(DrawingElement* drawingElement)
|
||||
{
|
||||
return(drawingElements.insert(std::make_pair(drawingElement->label,drawingElement)).second);
|
||||
}
|
||||
|
||||
bool Group::removeDrawingElement(const std::string& label)
|
||||
{
|
||||
return(drawingElements.erase(label));
|
||||
}
|
||||
|
||||
DrawingElement* Group::getDrawingElement(const std::string& label)
|
||||
{
|
||||
return(drawingElements.at(label));
|
||||
}
|
||||
|
||||
void Group::draw(sf::RenderWindow& window)
|
||||
{
|
||||
for(const auto& element : drawingElements)
|
||||
{
|
||||
element.second->draw(window,x,y);
|
||||
}
|
||||
}
|
||||
|
||||
const std::string Group::toString() const
|
||||
{
|
||||
std::stringstream string;
|
||||
string << label << " at x:" << getX() << " y:" << getY();
|
||||
string << " color:" << getStringColor() << std::endl;
|
||||
|
||||
for(const auto& element : drawingElements)
|
||||
{
|
||||
string << "\t" << *(element.second) << std::endl;
|
||||
}
|
||||
return(string.str());
|
||||
}
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
//
|
||||
// Created by trotfunky on 15/05/19.
|
||||
//
|
||||
|
||||
#ifndef SNIPPETS_GROUP_H
|
||||
#define SNIPPETS_GROUP_H
|
||||
|
||||
#include <pugixml.hpp>
|
||||
#include <map>
|
||||
#include <cstring>
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
|
||||
#include "Circle.h"
|
||||
#include "DrawingElement.h"
|
||||
|
||||
namespace xmlParser
|
||||
{
|
||||
|
||||
class Group : public DrawingElement
|
||||
{
|
||||
public:
|
||||
explicit Group(std::string label = "Test Group", float x = 0, float y = 1,
|
||||
const sf::Color& color = sf::Color::Transparent);
|
||||
|
||||
explicit Group(const pugi::xml_node&);
|
||||
explicit Group(const std::map<std::string, DrawingElement*>&);
|
||||
|
||||
bool addDrawingElement(DrawingElement* drawingElement);
|
||||
bool removeDrawingElement(const std::string& label);
|
||||
|
||||
DrawingElement* getDrawingElement(const std::string&);
|
||||
|
||||
void draw(sf::RenderWindow&) override;
|
||||
|
||||
const std::string toString() const override;
|
||||
private:
|
||||
std::map<std::string,DrawingElement*> drawingElements;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif //SNIPPETS_GROUP_H
|
|
@ -1,198 +0,0 @@
|
|||
//
|
||||
// Created by trotfunky on 07/05/19.
|
||||
//
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <iostream>
|
||||
|
||||
#include "Circle.h"
|
||||
#include "xmlParser.h"
|
||||
#include "SFML/Graphics.hpp"
|
||||
#include "Group.h"
|
||||
|
||||
|
||||
TEST(xmlParserInits,initEmptyCircle)
|
||||
{
|
||||
xmlParser::Circle cercle = xmlParser::Circle();
|
||||
|
||||
EXPECT_EQ(cercle.getX(),0);
|
||||
EXPECT_EQ(cercle.getY(),1);
|
||||
EXPECT_EQ(cercle.getR(),2);
|
||||
EXPECT_EQ(cercle.label,"Test Circle");
|
||||
EXPECT_EQ(cercle.getColor(),sf::Color::Yellow);
|
||||
}
|
||||
|
||||
TEST(xmlParserInits,initEmptyCirclePugiXML)
|
||||
{
|
||||
pugi::xml_node node;
|
||||
xmlParser::Circle cercle = xmlParser::Circle(node);
|
||||
|
||||
EXPECT_EQ(cercle.getX(),0);
|
||||
EXPECT_EQ(cercle.getY(),1);
|
||||
EXPECT_EQ(cercle.getR(),2);
|
||||
EXPECT_EQ(cercle.label,"Test Circle");
|
||||
EXPECT_EQ(cercle.getColor(),sf::Color::Yellow);
|
||||
}
|
||||
|
||||
TEST(xmlParserInits,initEmptyGroup)
|
||||
{
|
||||
xmlParser::Group group = xmlParser::Group();
|
||||
|
||||
EXPECT_EQ(group.getX(),0);
|
||||
EXPECT_EQ(group.getY(),1);
|
||||
EXPECT_EQ(group.label,"Test Group");
|
||||
}
|
||||
|
||||
TEST(xmlParserInits,initEmptyGroupPugiXML)
|
||||
{
|
||||
pugi::xml_node node;
|
||||
xmlParser::Group group = xmlParser::Group(node);
|
||||
|
||||
EXPECT_EQ(group.getX(),0);
|
||||
EXPECT_EQ(group.getY(),1);
|
||||
EXPECT_EQ(group.label,"Test Group");
|
||||
}
|
||||
|
||||
TEST(parseXML,parseXMLCircle)
|
||||
{
|
||||
std::string xml = "<?xml version = \"1.0\"?>\n"
|
||||
"<Circle label=\"testCircle\" x=\"0\" y=\"1\" r=\"2\" color=\"Black\"/>";
|
||||
|
||||
pugi::xml_document doc;
|
||||
pugi::xml_parse_result result = doc.load_string(xml.c_str());
|
||||
ASSERT_NE(0,result);
|
||||
|
||||
pugi::xml_node node = doc.child("Circle");
|
||||
xmlParser::Circle cercle = xmlParser::Circle(node);
|
||||
|
||||
EXPECT_EQ(cercle.getX(),0);
|
||||
EXPECT_EQ(cercle.getY(),1);
|
||||
EXPECT_EQ(cercle.getR(),2);
|
||||
EXPECT_EQ(cercle.label,"testCircle");
|
||||
EXPECT_EQ(cercle.getColor(),sf::Color::Black);
|
||||
}
|
||||
|
||||
|
||||
TEST(parseXML,parseXMLGroup)
|
||||
{
|
||||
std::string xml = "<?xml version = \"1.0\"?>\n"
|
||||
"<Group label=\"testGroup\" x=\"0\" y=\"1\">\n"
|
||||
" <Circle label=\"testCircle1\" x=\"2\" y=\"3\" r=\"4\" color=\"Black\"/>\n"
|
||||
" <Circle label=\"testCircle2\" x=\"5\" y=\"6\" r=\"7\" color=\"Black\"/>\n"
|
||||
"</Group>";
|
||||
|
||||
pugi::xml_document doc;
|
||||
pugi::xml_parse_result result = doc.load_string(xml.c_str());
|
||||
ASSERT_NE(0,result);
|
||||
|
||||
pugi::xml_node node = doc.child("Group");
|
||||
xmlParser::Group group = xmlParser::Group(node);
|
||||
|
||||
EXPECT_EQ(group.getX(),0);
|
||||
EXPECT_EQ(group.getY(),1);
|
||||
EXPECT_EQ(group.label,"testGroup");
|
||||
|
||||
ASSERT_TRUE(group.getDrawingElement("testCircle1"));
|
||||
xmlParser::Circle* testCircle1 = dynamic_cast<xmlParser::Circle*>(group.getDrawingElement("testCircle1"));
|
||||
EXPECT_EQ(testCircle1->getX(),2);
|
||||
EXPECT_EQ(testCircle1->getY(),3);
|
||||
EXPECT_EQ(testCircle1->getR(),4);
|
||||
EXPECT_EQ(testCircle1->getColor(),sf::Color::Black);
|
||||
|
||||
ASSERT_TRUE(group.getDrawingElement("testCircle2"));
|
||||
xmlParser::Circle* testCircle2 = dynamic_cast<xmlParser::Circle*>(group.getDrawingElement("testCircle2"));
|
||||
EXPECT_EQ(testCircle2->getX(),5);
|
||||
EXPECT_EQ(testCircle2->getY(),6);
|
||||
EXPECT_EQ(testCircle2->getR(),7);
|
||||
EXPECT_EQ(testCircle2->getColor(),sf::Color::Black);
|
||||
}
|
||||
|
||||
TEST(parseXML,parseXMLNestGroup)
|
||||
{
|
||||
std::string xml = "<?xml version = \"1.0\"?>\n"
|
||||
"<Group label=\"testGroup1\" x=\"0\" y=\"1\">\n"
|
||||
" <Circle label=\"testCircle\" x=\"2\" y=\"3\" r=\"4\" color=\"Black\"/>\n"
|
||||
" <Group label=\"testGroup2\" x=\"5\" y=\"6\"/>\n"
|
||||
"</Group>";
|
||||
|
||||
pugi::xml_document doc;
|
||||
pugi::xml_parse_result result = doc.load_string(xml.c_str());
|
||||
ASSERT_NE(0,result);
|
||||
|
||||
pugi::xml_node node = doc.child("Group");
|
||||
xmlParser::Group group = xmlParser::Group(node);
|
||||
ASSERT_TRUE(group.getDrawingElement("testGroup2"));
|
||||
|
||||
xmlParser::Group* testGroup2 = dynamic_cast<xmlParser::Group*>(group.getDrawingElement("testGroup2"));
|
||||
EXPECT_EQ(testGroup2->getX(),5);
|
||||
EXPECT_EQ(testGroup2->getY(),6);
|
||||
EXPECT_EQ(testGroup2->label,"testGroup2");
|
||||
}
|
||||
|
||||
TEST(drawFace,drawFace)
|
||||
{
|
||||
std::string xml = "<?xml version=\"1.0\"?>\n"
|
||||
"<!-- Dans cette version de format, les coordonnees (x,y) sont exprimees dans un -->\n"
|
||||
"<!-- repere dont le centre est au centre de l'ecran, les valeurs positives de x -->\n"
|
||||
"<!-- etant vers la droite, les valeurs positives de y etant vers le haut. --> \n"
|
||||
"<Drawing>\n"
|
||||
" <!-- Le noeud suivant cree un cercle dont le centre est en (0,0), -->\n"
|
||||
" <!-- de rayon 200, de couleur noir, qui a pour etiquette -->\n"
|
||||
" <!-- \"contourVisage\" -->\n"
|
||||
" <Circle label=\"contourVisage\" x=\"0\" y=\"0\" r=\"200\" color=\"Black\"/>\n"
|
||||
" <Circle label=\"nez\" x=\"0\" y=\"0\" r=\"20\" color=\"Red\"/>\n"
|
||||
" <!-- Le noeud suivant cree un groupe \"oreilles\" positionne en (0,210) -->\n"
|
||||
" <Group label=\"oreilles\" x=\"0\" y=\"210\">\n"
|
||||
"\t<Group label=\"oreille\" x=\"-210\" y=\"0\">\n"
|
||||
"\t <Circle label=\"c1\" x=\"0\" y=\"0\" r=\"100\" color=\"Black\"/>\n"
|
||||
"\t <Circle label=\"c2\" x=\"0\" y=\"0\" r=\"70\" color=\"Magenta\"/>\n"
|
||||
"\t</Group>\n"
|
||||
"\t<Group label=\"oreille2\" x=\"210\" y=\"0\">\n"
|
||||
"\t <Circle label=\"c1\" x=\"0\" y=\"0\" r=\"100\" color=\"Black\"/>\n"
|
||||
"\t <Circle label=\"c2\" x=\"0\" y=\"0\" r=\"70\" color=\"Magenta\"/>\n"
|
||||
"\t</Group>\n"
|
||||
" </Group>\n"
|
||||
"</Drawing>";
|
||||
|
||||
pugi::xml_document doc;
|
||||
pugi::xml_parse_result result = doc.load_string(xml.c_str());
|
||||
ASSERT_NE(result,0);
|
||||
|
||||
xmlParser::Group drawing = xmlParser::Group(doc.child("Drawing"));
|
||||
drawing.setX(1280/2.0);
|
||||
drawing.setY(-1024/2.0);
|
||||
|
||||
std::cout << drawing << std::endl;
|
||||
|
||||
sf::RenderWindow renderWindow(sf::VideoMode(1280,1024),"DA FACE");
|
||||
sf::RectangleShape rectangleGhost = sf::RectangleShape(sf::Vector2f(660,1024));
|
||||
rectangleGhost.setPosition(310,202);
|
||||
renderWindow.draw(rectangleGhost);
|
||||
|
||||
sf::CircleShape circleGhost = sf::CircleShape(330,100);
|
||||
circleGhost.setPosition(310,202-330);
|
||||
renderWindow.draw(circleGhost);
|
||||
|
||||
drawing.draw(renderWindow);
|
||||
renderWindow.display();
|
||||
|
||||
while (renderWindow.isOpen())
|
||||
{
|
||||
sf::Event event;
|
||||
while (renderWindow.pollEvent(event))
|
||||
{
|
||||
if (event.type == sf::Event::Closed)
|
||||
renderWindow.close();
|
||||
if (event.type == sf::Event::KeyPressed)
|
||||
{
|
||||
renderWindow.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
::testing::InitGoogleTest(&argc,argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
|
@ -1,86 +0,0 @@
|
|||
//
|
||||
// Created by trotfunky on 07/05/19.
|
||||
//
|
||||
|
||||
#include <pugixml.hpp>
|
||||
#include "xmlParser.h"
|
||||
|
||||
namespace xmlParser
|
||||
{
|
||||
const std::string colorToStr(const sf::Color& color)
|
||||
{
|
||||
if(color == sf::Color::Black)
|
||||
{
|
||||
return("Black");
|
||||
}
|
||||
else if(color == sf::Color::White)
|
||||
{
|
||||
return("White");
|
||||
}
|
||||
else if(color == sf::Color::Red)
|
||||
{
|
||||
return("Red");
|
||||
}
|
||||
else if(color == sf::Color::Green)
|
||||
{
|
||||
return("Green");
|
||||
}
|
||||
else if(color == sf::Color::Blue)
|
||||
{
|
||||
return("Blue");
|
||||
}
|
||||
else if(color == sf::Color::Yellow)
|
||||
{
|
||||
return("Yellow");
|
||||
}
|
||||
else if(color == sf::Color::Magenta)
|
||||
{
|
||||
return("Magenta");
|
||||
}
|
||||
else if(color == sf::Color::Cyan)
|
||||
{
|
||||
return("Cyan");
|
||||
}
|
||||
return("Transparent");
|
||||
}
|
||||
|
||||
const sf::Color& strToColor(const std::string& stringColor)
|
||||
{
|
||||
if(stringColor == "Black")
|
||||
{
|
||||
return(sf::Color::Black);
|
||||
}
|
||||
else if(stringColor == "White")
|
||||
{
|
||||
return(sf::Color::White);
|
||||
}
|
||||
else if(stringColor == "Red")
|
||||
{
|
||||
return(sf::Color::Red);
|
||||
}
|
||||
else if(stringColor == "Green")
|
||||
{
|
||||
return(sf::Color::Green);
|
||||
}
|
||||
else if(stringColor == "Blue")
|
||||
{
|
||||
return(sf::Color::Blue);
|
||||
}
|
||||
else if(stringColor == "Yellow")
|
||||
{
|
||||
return(sf::Color::Yellow);
|
||||
}
|
||||
else if(stringColor == "Magenta")
|
||||
{
|
||||
return(sf::Color::Magenta);
|
||||
}
|
||||
else if(stringColor == "Cyan")
|
||||
{
|
||||
return(sf::Color::Cyan);
|
||||
}
|
||||
else
|
||||
{
|
||||
return(sf::Color::Green);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
//
|
||||
// Created by trotfunky on 07/05/19.
|
||||
//
|
||||
|
||||
#ifndef SNIPPETS_XMLPARSER_H
|
||||
#define SNIPPETS_XMLPARSER_H
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <SFML/Graphics.hpp>
|
||||
|
||||
|
||||
namespace xmlParser
|
||||
{
|
||||
const std::string colorToStr(const sf::Color&);
|
||||
const sf::Color& strToColor(const std::string&);
|
||||
}
|
||||
|
||||
#endif //SNIPPETS_XMLPARSER_H
|
Loading…
Add table
Add a link
Reference in a new issue