Closed Ok23 closed 4 years ago
Are these 2 different issues? I assume you have 2 problems.
To display a derived class in C++ you have to define this derived class in the XML file as well. If you want to display Circle
you have to define it in the XML file.
Regarding the SFML.
Which one of the two classes you defined does not work for you?
Is sf::Vertex
displayed properly?
~I don't know SFML but shouldn't you rather use m_outlineVertices
?~
~https://github.com/SFML/SFML/blob/master/include/SFML/Graphics/Shape.hpp#L314~
EDIT: probably not.
But besides that your definitions look good and should work. So I'll look into it.
Please also make sure that everything is ok on your side, i.e. you're using the correct vertices container that holds the data, that it is not empty, that sf::Vertex
alone is displayed properly, etc.
Side note, m_vertices.m_vertices
is std::vector
and the extension knows how to deal with this container. So it would be enough to define Ring
using the Container
entry instead of Array
.
(see https://github.com/awulkiew/graphical-debugging/blob/v0.32/examples/cpp.xml#L259)
It works for me.
For this program:
#include <SFML/Graphics/CircleShape.hpp>
int main()
{
sf::Vector2f xy(1, 2);
sf::Vertex v(xy);
std::vector<sf::Vector2f> coords = { {0, 0}, {1, 1}, {2, 2}, {3, 3}, {4, 4} };
std::vector<sf::Vertex> verts(coords.begin(), coords.end());
sf::CircleShape circle1(1);
sf::CircleShape circle2(2);
return 0;
}
with these definitions in the XML file (the same as yours plus sf::CircleShape
added by me):
<Point Id="sf::Vertex">
<Coordinates>
<X>position.x</X>
<Y>position.y</Y>
</Coordinates>
</Point>
<Ring Id="sf::Shape">
<Points>
<Array>
<Pointer>m_vertices.m_vertices._Mypair._Myval2._Myfirst</Pointer>
<Size>m_vertices.m_vertices._Mypair._Myval2._Mylast - m_vertices.m_vertices._Mypair._Myval2._Myfirst</Size>
</Array>
</Points>
</Ring>
<Ring Id="sf::CircleShape">
<Points>
<Container>
<Name>m_vertices.m_vertices</Name>
</Container>
</Points>
</Ring>
I get this:
Have in mind that the extension is allowed to display the variable if the type or id matches the one that is defined. It does not automatically handle the base classes or derived classes of the types in C++. You have to explicitly specify the variable of a desired type. Hence the (sf::Shape&)circle1
in my example above. When I create variable of type sf::CircleShape
but wants to display sf::Shape
I have to cast it to the desired type. This is also why I added the definition for sf::CircleShape
, to avoid casting, so it's sufficient to write circle2
above.
Thanks. How about suggestion integrate SFML and other most popular geometry libraries ?
integrate SFML and other most popular geometry libraries
Yes, that's a good idea, there are many different libraries besides the ones that are already supported. However, I'm busy implementing various features. So you might consider contributing XML file with SFML classes which at the beginning could be placed with the examples and later I'd distribute them with the extension.
Together with the XML files there are also NatVis files allowing Visual Studio to present the variables in a more readable form. So if you want also to see the content of variables in the IDE in a text format you could consider contributing NatVis file too.
Ok, i arleady writing basic support for wykoby
But supported types not enough, come out little weird
How set manually <Points>
?
I don't understand your question. What do you mean by "manually"? Could you show the class you want to write definition of?
template <typename T, std::size_t Dimension>
class ray : public geometric_entity
{
public:
ray(){}
~ray(){}
typedef typename define_point_type<T,Dimension>::PointType PointType;
typedef typename define_vector_type<T,Dimension>::VectorType VectorType;
PointType origin;
VectorType direction;
};
convert it to linestring like
<Linestring Id="wykobi::ray">
<Points>
<Name>origin</Name>
<Name>direction</Name>
</Points>
</Linestring>
Rays are not supported right now. Neither are Segments. And even if Segments were supported it's also not supported to define Points "in-place". Because in order to draw a Ray as a segment you'd have to set the second point as e.g.:
<X>origin.x + 100 * direction.x</X>
<Y>origin.y + 100 * direction.y</Y>
This is not supported.
Keep me posted about missing features like that and I'll add the support later as I did with the Box. If you don't find a definition of a primitive you want to display in the example XML files it means it is not supported. I propose to use a different Issue for that: https://github.com/awulkiew/graphical-debugging/issues/26
The support for Rays was added in v0.33. https://github.com/awulkiew/graphical-debugging/blob/v0.33/examples/cpp.xml#L131-L177
Example:
I'm tried to integrate SFML (https://github.com/SFML/SFML) but not work with xml code