From d44574184094893f61948c55610cbc39b159b09b Mon Sep 17 00:00:00 2001 From: clifford Date: Fri, 6 Nov 2009 22:41:57 +0000 Subject: Clifford Wolf: Some small fixes and improvements git-svn-id: http://svn.clifford.at/openscad/trunk@130 b57f626f-c46c-0410-a088-ec61d464b74c diff --git a/mainwin.cc b/mainwin.cc index cf17c88..fcf7098 100644 --- a/mainwin.cc +++ b/mainwin.cc @@ -237,7 +237,7 @@ MainWindow::MainWindow(const char *filename) setCentralWidget(s1); - connect(editor->document(), SIGNAL(contentsChanged()), this, SLOT(animateUpdate())); + connect(editor->document(), SIGNAL(contentsChanged()), this, SLOT(animateUpdateDocChanged())); connect(screen, SIGNAL(doAnimateUpdate()), this, SLOT(animateUpdate())); // display this window and check for OpenGL 2.0 (OpenCSG) support @@ -410,13 +410,20 @@ void MainWindow::compile(bool procevents) vpr.vec.append(new Value(fmodf(360 - screen->object_rot_z, 360))); root_ctx.set_variable("$vpr", vpr); - root_module = parse(editor->toPlainText().toAscii().data(), false); + last_compiled_doc = editor->toPlainText(); + root_module = parse(last_compiled_doc.toAscii().data(), false); delete highlighter; highlighter = new Highlighter(editor->document()); - if (!root_module) + if (!root_module) { + if (!animate_panel->isVisible()) { + QTextCursor cursor = editor->textCursor(); + cursor.setPosition(parser_error_pos); + editor->setTextCursor(cursor); + } goto fail; + } PRINT("Compiling design (CSG Tree generation)..."); if (procevents) @@ -1217,6 +1224,13 @@ void MainWindow::viewModeAnimate() } } +void MainWindow::animateUpdateDocChanged() +{ + QString current_doc = editor->toPlainText(); + if (current_doc != last_compiled_doc) + animateUpdate(); +} + void MainWindow::animateUpdate() { if (animate_panel->isVisible()) { diff --git a/openscad.h b/openscad.h index 2b2fd77..17a22a1 100644 --- a/openscad.h +++ b/openscad.h @@ -735,6 +735,7 @@ public: QVector background_terms; CSGChain *background_chain; AbstractNode *root_node; + QString last_compiled_doc; bool enableOpenCSG; MainWindow(const char *filename = 0); @@ -818,6 +819,7 @@ public slots: void viewCenter(); void viewPerspective(); void viewOrthogonal(); + void animateUpdateDocChanged(); void animateUpdate(); void dragEnterEvent(QDragEnterEvent *event); void dropEvent(QDropEvent *event); -- cgit v0.10.1