But working better than it did before.
Assuming you like turtles_all_the_way_down.script to infinite
loop when going back up.
string msg = m_text_edit->toPlainText().toStdString();
Real scale = bounds.h / Real(2);
Debug("Insert \"%s\" at %f, %f, scale %f", msg.c_str(), Float(xx), Float(yy), Float(scale));
+#ifndef QUADTREE_DISABLED
+ m_doc.SetQuadtreeInsertNode(m_view.GetCurrentQuadtreeNode());
+#endif
m_doc.AddText(msg, scale, xx, yy);
+#ifndef QUADTREE_DISABLED
+ m_doc.PropagateQuadChanges(m_view.GetCurrentQuadtreeNode());
+#endif
m_view.ForceRenderDirty();
m_view.ForceBufferDirty();
m_view.ForceBoundsDirty();
bounds.w /= Real(m_screen.ViewportWidth());
bounds.h /= Real(m_screen.ViewportHeight());
+#ifndef QUADTREE_DISABLED
+ m_doc.SetQuadtreeInsertNode(m_view.GetCurrentQuadtreeNode());
+#endif
m_doc.ParseSVG(m_text_edit->toPlainText().toStdString(), bounds);
+#ifndef QUADTREE_DISABLED
+ m_doc.PropagateQuadChanges(m_view.GetCurrentQuadtreeNode());
+#endif
m_view.ForceRenderDirty();
m_view.ForceBufferDirty();
m_view.ForceBoundsDirty();
bounds.w /= Real(m_screen.ViewportWidth());
bounds.h /= Real(m_screen.ViewportHeight());
+#ifndef QUADTREE_DISABLED
+ m_doc.SetQuadtreeInsertNode(m_view.GetCurrentQuadtreeNode());
+#endif
m_doc.LoadSVG(filename.toStdString(), bounds);
+#ifndef QUADTREE_DISABLED
+ m_doc.PropagateQuadChanges(m_view.GetCurrentQuadtreeNode());
+#endif
m_view.ForceRenderDirty();
m_view.ForceBufferDirty();
m_view.ForceBoundsDirty();
break;
case AT_LoadSVG:
{
+#ifndef QUADTREE_DISABLED
+ view->Doc().SetQuadtreeInsertNode(view->GetCurrentQuadtreeNode());
+#endif
#ifdef TRANSFORM_OBJECTS_NOT_VIEW
view->Doc().LoadSVG(currentAction.textargs, Rect(Real(1)/Real(2),Real(1)/Real(2),Real(1)/Real(800),Real(1)/Real(600)));
#else
const Rect & bounds = view->GetBounds();
view->Doc().LoadSVG(currentAction.textargs, Rect(bounds.x+bounds.w/Real(2),bounds.y+bounds.h/Real(2),bounds.w/Real(800),bounds.h/Real(600)));
#endif
+#ifndef QUADTREE_DISABLED
+ view->Doc().PropagateQuadChanges(view->GetCurrentQuadtreeNode());
+#endif
currentAction.type = AT_WaitFrame;
view->ForceRenderDirty();
view->ForceBufferDirty();
m_objects.bounds.push_back(bounds);
m_objects.data_indices.push_back(data_index);
#ifndef QUADTREE_DISABLED
+ if (qti == -1) qti = m_current_insert_node;
if (qti != -1)
{
QuadTreeIndex new_qti = qti;
}
done: // matches is not amused, but sulix is nice and moved it inside the #ifdef for him.
m_count++;
- PropagateQuadChanges(qti);
}
return m_count-1;
#else // words fail me (still not amused)
class Document
{
public:
- Document(const std::string & filename = "", const std::string & font_filename = "fonts/DejaVuSansMono.ttf") : m_objects(), m_count(0), m_font_data(NULL), m_font()
+ Document(const std::string & filename = "", const std::string & font_filename = "fonts/DejaVuSansMono.ttf") : m_objects(), m_current_insert_node(-1), m_count(0), m_font_data(NULL), m_font()
{
Load(filename);
if (font_filename != "")
unsigned AddPath(unsigned start_index, unsigned end_index, const Colour & shading=Colour(0.6,0.6,0.6,1), const Colour & stroke=Colour(0,0,0,0));
unsigned AddBezier(const Bezier & bezier);
- unsigned Add(ObjectType type, const Rect & bounds, unsigned data_index = 0, QuadTreeIndex qtnode = 0);
+ unsigned Add(ObjectType type, const Rect & bounds, unsigned data_index = 0, QuadTreeIndex qtnode = -1);
unsigned AddBezierData(const Bezier & bezier);
unsigned AddPathData(const Path & path);
void PropagateQuadChanges(QuadTreeIndex node);
// Returns the number of objects the current object formed when clipped, the objects in question are added to the end of the document.
int ClipObjectToQuadChild(int object_id, QuadTreeNodeChildren type);
+
+ void SetQuadtreeInsertNode(QuadTreeIndex node) { m_current_insert_node = node; }
#endif
void ClearObjects()
#ifndef QUADTREE_DISABLED
QuadTree m_quadtree;
void GenBaseQuadtree();
+
+ QuadTreeIndex m_current_insert_node;
#endif
unsigned m_count;
unsigned char * m_font_data;
void SaveGPUBMP(const char * filename);
Document & Doc() {return m_document;}
+#ifndef QUADTREE_DISABLED
+ QuadTreeIndex GetCurrentQuadtreeNode() { return m_current_quadtree_node; }
+#endif
private:
struct GPUObjBounds