# HG changeset patch # User insilmaril # Date 1182262830 0 # Node ID 497fab7d1404a41684e0ba0caeada80caaab58a6 # Parent 5f576e56ad99e2b58b43f6bd9e828813e96de10e Exports can (partly) be scripted diff -r 5f576e56ad99 -r 497fab7d1404 highlighter.cpp --- a/highlighter.cpp Tue Jun 19 14:20:29 2007 +0000 +++ b/highlighter.cpp Tue Jun 19 14:20:30 2007 +0000 @@ -47,6 +47,7 @@ << "\\bdelete\\b" << "\\bdeleteKeepChilds\\b" << "\\bdeleteChilds\\b" + << "\\bexport\\b" << "\\bimportDir\\b" << "\\blinkTo\\b" << "\\bloadImage\\b" diff -r 5f576e56ad99 -r 497fab7d1404 main.cpp --- a/main.cpp Tue Jun 19 14:20:29 2007 +0000 +++ b/main.cpp Tue Jun 19 14:20:30 2007 +0000 @@ -164,7 +164,7 @@ script= ts.read(); f.close(); m.setScript (script); - m.runScript (script); + m.runScriptEverywhere (script); } } diff -r 5f576e56ad99 -r 497fab7d1404 mainwindow.cpp --- a/mainwindow.cpp Tue Jun 19 14:20:29 2007 +0000 +++ b/mainwindow.cpp Tue Jun 19 14:20:30 2007 +0000 @@ -2341,39 +2341,13 @@ void Main::fileExportImage() { MapEditor *me=currentMapEditor(); - if (me) - { - QStringList fl; - QFileDialog *fd=new QFileDialog (this); - fd->setCaption (tr("Export map as image")); - fd->setDirectory (lastImageDir); - fd->setFileMode(QFileDialog::AnyFile); - fd->setFilters (imageIO.getFilters() ); - if (fd->exec()) - { - fl=fd->selectedFiles(); - me->exportImage (fl.first(), imageIO.getType (fd->selectedFilter() ) ); - } - } + if (me) me->exportImage(); } void Main::fileExportASCII() { MapEditor *me=currentMapEditor(); - if (me) - { - ExportASCII ex; - ex.setMapCenter(me->getMapCenter()); - ex.addFilter ("TXT (*.txt)"); - ex.setDir(lastImageDir); - ex.setCaption(vymName+ " -" +tr("Export as ASCII")+" "+tr("(still experimental)")); - if (ex.execDialog() ) - { - me->setExportMode(true); - ex.doExport(); - me->setExportMode(false); - } - } + if (me) me->exportASCII(); } void Main::fileExportCSV() @@ -3638,6 +3612,16 @@ currentMapEditor()->runScript (script); } +void Main::runScriptEverywhere (const QString &script) +{ + MapEditor *me; + for (int i=0;i<=tabWidget->count() -1;i++) + { + me=(MapEditor*)tabWidget->page(i); + if (me) me->runScript (script); + } +} + void Main::windowNextEditor() { if (tabWidget->currentPageIndex() < tabWidget->count()) diff -r 5f576e56ad99 -r 497fab7d1404 mainwindow.h --- a/mainwindow.h Tue Jun 19 14:20:29 2007 +0000 +++ b/mainwindow.h Tue Jun 19 14:20:30 2007 +0000 @@ -191,6 +191,7 @@ bool useFlagGroups(); void setScript(const QString &); void runScript(const QString &); + void runScriptEverywhere (const QString &); private slots: void windowNextEditor(); diff -r 5f576e56ad99 -r 497fab7d1404 mapeditor.cpp --- a/mapeditor.cpp Tue Jun 19 14:20:29 2007 +0000 +++ b/mapeditor.cpp Tue Jun 19 14:20:30 2007 +0000 @@ -483,6 +483,7 @@ QString com=parser.getCommand(); // External commands + ///////////////////////////////////////////////////////////////////// if (com=="addBranch") { if (xelection.isEmpty()) @@ -495,9 +496,9 @@ { QList pl; pl << 0 <<1; - if (parser.checkParamCount(pl)) + if (parser.checkParCount(pl)) { - if (parser.paramCount()==0) + if (parser.parCount()==0) addNewBranchInt (-2); else { @@ -506,6 +507,7 @@ } } } + ///////////////////////////////////////////////////////////////////// } else if (com=="addBranchBefore") { if (xelection.isEmpty()) @@ -516,11 +518,12 @@ parser.setError (Aborted,"Type of selection is not a branch"); } else { - if (parser.paramCount()==0) + if (parser.parCount()==0) { addNewBranchBefore (); } } + ///////////////////////////////////////////////////////////////////// } else if (com==QString("addMapReplace")) { if (xelection.isEmpty()) @@ -529,13 +532,14 @@ } else if (! selb ) { parser.setError (Aborted,"Type of selection is not a branch"); - } else if (parser.checkParamCount(1)) + } else if (parser.checkParCount(1)) { //s=parser.parString (ok,0); // selection t=parser.parString (ok,0); // path to map if (QDir::isRelativePath(t)) t=QDir::convertSeparators (tmpMapDir + "/"+t); addMapReplaceInt(selb->getSelectString(),t); } + ///////////////////////////////////////////////////////////////////// } else if (com==QString("addMapInsert")) { if (xelection.isEmpty()) @@ -546,7 +550,7 @@ parser.setError (Aborted,"Type of selection is not a branch"); } else { - if (parser.checkParamCount(2)) + if (parser.checkParCount(2)) { t=parser.parString (ok,0); // path to map y=parser.parInt(ok,1); // position @@ -554,6 +558,7 @@ addMapInsertInt(t,y); } } + ///////////////////////////////////////////////////////////////////// } else if (com=="clearFlags") { if (xelection.isEmpty() ) @@ -562,11 +567,12 @@ } else if (! selb ) { parser.setError (Aborted,"Type of selection is not a branch"); - } else if (parser.checkParamCount(0)) + } else if (parser.checkParCount(0)) { selb->clearStandardFlags(); selb->updateFlagsToolbar(); } + ///////////////////////////////////////////////////////////////////// } else if (com=="colorBranch") { if (xelection.isEmpty()) @@ -575,11 +581,12 @@ } else if (! selb ) { parser.setError (Aborted,"Type of selection is not a branch"); - } else if (parser.checkParamCount(1)) + } else if (parser.checkParCount(1)) { QColor c=parser.parColor (ok,0); if (ok) colorBranch (c); } + ///////////////////////////////////////////////////////////////////// } else if (com=="colorSubtree") { if (xelection.isEmpty()) @@ -588,11 +595,12 @@ } else if (! selb ) { parser.setError (Aborted,"Type of selection is not a branch"); - } else if (parser.checkParamCount(1)) + } else if (parser.checkParCount(1)) { QColor c=parser.parColor (ok,0); if (ok) colorSubtree (c); } + ///////////////////////////////////////////////////////////////////// } else if (com=="copy") { if (xelection.isEmpty()) @@ -601,10 +609,11 @@ } else if (! selb ) { parser.setError (Aborted,"Type of selection is not a branch"); - } else if (parser.checkParamCount(0)) + } else if (parser.checkParCount(0)) { //FIXME missing action for copy } + ///////////////////////////////////////////////////////////////////// } else if (com=="cut") { if (xelection.isEmpty()) @@ -615,10 +624,11 @@ xelection.type()!=Selection::FloatImage ) { parser.setError (Aborted,"Type of selection is not a branch or floatimage"); - } else if (parser.checkParamCount(0)) + } else if (parser.checkParCount(0)) { cut(); } + ///////////////////////////////////////////////////////////////////// } else if (com=="delete") { if (xelection.isEmpty()) @@ -627,10 +637,11 @@ } else if (xelection.type() != Selection::Branch && xelection.type() != Selection::FloatImage ) { parser.setError (Aborted,"Type of selection is wrong."); - } else if (parser.checkParamCount(0)) + } else if (parser.checkParCount(0)) { deleteSelection(); } + ///////////////////////////////////////////////////////////////////// } else if (com=="deleteKeepChilds") { if (xelection.isEmpty()) @@ -639,10 +650,11 @@ } else if (! selb ) { parser.setError (Aborted,"Type of selection is not a branch"); - } else if (parser.checkParamCount(0)) + } else if (parser.checkParCount(0)) { deleteKeepChilds(); } + ///////////////////////////////////////////////////////////////////// } else if (com=="deleteChilds") { if (xelection.isEmpty()) @@ -651,10 +663,63 @@ } else if (! selb) { parser.setError (Aborted,"Type of selection is not a branch"); - } else if (parser.checkParamCount(0)) + } else if (parser.checkParCount(0)) { deleteChilds(); } + ///////////////////////////////////////////////////////////////////// + } else if (com=="export") + { + /* + if (xelection.isEmpty()) + { + parser.setError (Aborted,"Nothing selected"); + } else if (! selb) + { + parser.setError (Aborted,"Type of selection is not a branch"); + } else + */ + if (parser.parCount()==0) + { + parser.setError (Aborted,"No output format given"); + } else + { + // At least one parameter, which is the outFormat + QString outFormat=parser.parString (ok,0); + if (!ok) + { + parser.setError (Aborted,QString("Unknown export type: %1").arg(outFormat)); + } else + { + QString fname=""; + ok=true; + if (parser.parCount()>=2) + // Hey, we even have a filename + fname=parser.parString(ok,1); + if (!ok) + { + parser.setError (Aborted,"Could not read filename"); + } else + { + if (outFormat == "ascii") + { + exportASCII (fname,false); + } else if (outFormat == "image") + { + QString format="PNG"; + if (parser.parCount()>2) + { + format=parser.parString(ok,2); + } + exportImage (fname,false,format); + } else + { + parser.setError (Aborted,QString("Unknown export type: %1").arg(outFormat)); + } + } + } + } + ///////////////////////////////////////////////////////////////////// } else if (com=="importDir") { if (xelection.isEmpty()) @@ -663,11 +728,12 @@ } else if (! selb ) { parser.setError (Aborted,"Type of selection is not a branch"); - } else if (parser.checkParamCount(1)) + } else if (parser.checkParCount(1)) { s=parser.parString(ok,0); if (ok) importDirInt(s); } + ///////////////////////////////////////////////////////////////////// } else if (com=="linkTo") { if (xelection.isEmpty()) @@ -675,7 +741,7 @@ parser.setError (Aborted,"Nothing selected"); } else if ( selb) { - if (parser.checkParamCount(4)) + if (parser.checkParCount(4)) { // 0 selectstring of parent // 1 num in parent (for branches) @@ -705,7 +771,7 @@ } } else if ( xelection.type() == Selection::FloatImage) { - if (parser.checkParamCount(1)) + if (parser.checkParCount(1)) { // 0 selectstring of parent s=parser.parString(ok,0); @@ -720,6 +786,7 @@ } } else parser.setError (Aborted,"Type of selection is not a floatimage or branch"); + ///////////////////////////////////////////////////////////////////// } else if (com=="loadImage") { if (xelection.isEmpty()) @@ -728,11 +795,12 @@ } else if (! selb ) { parser.setError (Aborted,"Type of selection is not a branch"); - } else if (parser.checkParamCount(1)) + } else if (parser.checkParCount(1)) { s=parser.parString(ok,0); if (ok) loadFloatImageInt (s); } + ///////////////////////////////////////////////////////////////////// } else if (com=="moveBranchUp") { if (xelection.isEmpty() ) @@ -741,10 +809,11 @@ } else if (! selb ) { parser.setError (Aborted,"Type of selection is not a branch"); - } else if (parser.checkParamCount(0)) + } else if (parser.checkParCount(0)) { moveBranchUp(); } + ///////////////////////////////////////////////////////////////////// } else if (com=="moveBranchDown") { if (xelection.isEmpty() ) @@ -753,10 +822,11 @@ } else if (! selb ) { parser.setError (Aborted,"Type of selection is not a branch"); - } else if (parser.checkParamCount(0)) + } else if (parser.checkParCount(0)) { moveBranchDown(); } + ///////////////////////////////////////////////////////////////////// } else if (com=="move") { if (xelection.isEmpty() ) @@ -767,7 +837,7 @@ xelection.type()!=Selection::FloatImage ) { parser.setError (Aborted,"Type of selection is not a branch or floatimage"); - } else if (parser.checkParamCount(2)) + } else if (parser.checkParCount(2)) { x=parser.parInt (ok,0); if (ok) @@ -776,6 +846,7 @@ if (ok) move (x,y); } } + ///////////////////////////////////////////////////////////////////// } else if (com=="moveRel") { if (xelection.isEmpty() ) @@ -786,7 +857,7 @@ xelection.type()!=Selection::Selection::FloatImage ) { parser.setError (Aborted,"Type of selection is not a branch or floatimage"); - } else if (parser.checkParamCount(2)) + } else if (parser.checkParCount(2)) { x=parser.parInt (ok,0); if (ok) @@ -795,8 +866,10 @@ if (ok) moveRel (x,y); } } + ///////////////////////////////////////////////////////////////////// } else if (com=="nop") { + ///////////////////////////////////////////////////////////////////// } else if (com=="paste") { if (xelection.isEmpty() ) @@ -805,7 +878,7 @@ } else if (! selb ) { parser.setError (Aborted,"Type of selection is not a branch"); - } else if (parser.checkParamCount(1)) + } else if (parser.checkParCount(1)) { x=parser.parInt (ok,0); if (ok) pasteNoSave(x); @@ -819,7 +892,7 @@ } else if (! selb ) { parser.setError (Aborted,"Type of selection is not a branch"); - } else if (parser.checkParamCount(4)) + } else if (parser.checkParCount(4)) { QString c,u; c=parser.parString (ok,0); @@ -876,13 +949,14 @@ } } } + ///////////////////////////////////////////////////////////////////// } else if (com=="saveImage") { FloatImageObj *fio=xelection.getFloatImage(); if (!fio) { parser.setError (Aborted,"Type of selection is not an image"); - } else if (parser.checkParamCount(2)) + } else if (parser.checkParCount(2)) { s=parser.parString(ok,0); if (ok) @@ -891,6 +965,7 @@ if (ok) saveFloatImageInt (fio,t,s); } } + ///////////////////////////////////////////////////////////////////// } else if (com=="scroll") { if (xelection.isEmpty() ) @@ -899,18 +974,20 @@ } else if (! selb ) { parser.setError (Aborted,"Type of selection is not a branch"); - } else if (parser.checkParamCount(0)) + } else if (parser.checkParCount(0)) { if (!scrollBranch (selb)) parser.setError (Aborted,"Could not scroll branch"); } + ///////////////////////////////////////////////////////////////////// } else if (com=="select") { - if (parser.checkParamCount(1)) + if (parser.checkParCount(1)) { s=parser.parString(ok,0); if (ok) select (s); } + ///////////////////////////////////////////////////////////////////// } else if (com=="selectLastBranch") { if (xelection.isEmpty() ) @@ -919,7 +996,7 @@ } else if (! selb ) { parser.setError (Aborted,"Type of selection is not a branch"); - } else if (parser.checkParamCount(0)) + } else if (parser.checkParCount(0)) { BranchObj *bo=selb->getLastBranch(); if (!bo) @@ -927,6 +1004,7 @@ selectInt (bo); } + ///////////////////////////////////////////////////////////////////// } else if (com=="selectLastImage") { if (xelection.isEmpty() ) @@ -935,7 +1013,7 @@ } else if (! selb ) { parser.setError (Aborted,"Type of selection is not a branch"); - } else if (parser.checkParamCount(0)) + } else if (parser.checkParCount(0)) { FloatImageObj *fio=selb->getLastFloatImage(); if (!fio) @@ -943,75 +1021,83 @@ selectInt (fio); } + ///////////////////////////////////////////////////////////////////// } else if (com=="setFrameType") { if ( xelection.type()!=Selection::Branch && xelection.type()!= Selection::MapCenter && xelection.type()!=Selection::FloatImage) { parser.setError (Aborted,"Type of selection does not allow setting frame type"); } - else if (parser.checkParamCount(1)) + else if (parser.checkParCount(1)) { s=parser.parString(ok,0); if (ok) setFrameType (s); } + ///////////////////////////////////////////////////////////////////// } else if (com=="setFramePenColor") { if ( xelection.type()!=Selection::Branch && xelection.type()!= Selection::MapCenter && xelection.type()!=Selection::FloatImage) { parser.setError (Aborted,"Type of selection does not allow setting of pen color"); } - else if (parser.checkParamCount(1)) + else if (parser.checkParCount(1)) { QColor c=parser.parColor(ok,0); if (ok) setFramePenColor (c); } + ///////////////////////////////////////////////////////////////////// } else if (com=="setFrameBrushColor") { if ( xelection.type()!=Selection::Branch && xelection.type()!= Selection::MapCenter && xelection.type()!=Selection::FloatImage) { parser.setError (Aborted,"Type of selection does not allow setting brush color"); } - else if (parser.checkParamCount(1)) + else if (parser.checkParCount(1)) { QColor c=parser.parColor(ok,0); if (ok) setFrameBrushColor (c); } + ///////////////////////////////////////////////////////////////////// } else if (com=="setFramePadding") { if ( xelection.type()!=Selection::Branch && xelection.type()!= Selection::MapCenter && xelection.type()!=Selection::FloatImage) { parser.setError (Aborted,"Type of selection does not allow setting frame padding"); } - else if (parser.checkParamCount(1)) + else if (parser.checkParCount(1)) { x=parser.parInt(ok,0); if (ok) setFramePadding(x); } + ///////////////////////////////////////////////////////////////////// } else if (com=="setFrameBorderWidth") { if ( xelection.type()!=Selection::Branch && xelection.type()!= Selection::MapCenter && xelection.type()!=Selection::FloatImage) { parser.setError (Aborted,"Type of selection does not allow setting frame border width"); } - else if (parser.checkParamCount(1)) + else if (parser.checkParCount(1)) { x=parser.parInt(ok,0); if (ok) setFrameBorderWidth (x); } + ///////////////////////////////////////////////////////////////////// } else if (com=="setMapAuthor") { - if (parser.checkParamCount(1)) + if (parser.checkParCount(1)) { s=parser.parString(ok,0); if (ok) setMapAuthor (s); } + ///////////////////////////////////////////////////////////////////// } else if (com=="setMapComment") { - if (parser.checkParamCount(1)) + if (parser.checkParCount(1)) { s=parser.parString(ok,0); if (ok) setMapComment(s); } + ///////////////////////////////////////////////////////////////////// } else if (com=="setMapBackgroundColor") { if (xelection.isEmpty() ) @@ -1020,11 +1106,12 @@ } else if (! xelection.getBranch() ) { parser.setError (Aborted,"Type of selection is not a branch"); - } else if (parser.checkParamCount(1)) + } else if (parser.checkParCount(1)) { QColor c=parser.parColor (ok,0); if (ok) setMapBackgroundColor (c); } + ///////////////////////////////////////////////////////////////////// } else if (com=="setMapDefLinkColor") { if (xelection.isEmpty() ) @@ -1033,18 +1120,20 @@ } else if (! selb ) { parser.setError (Aborted,"Type of selection is not a branch"); - } else if (parser.checkParamCount(1)) + } else if (parser.checkParCount(1)) { QColor c=parser.parColor (ok,0); if (ok) setMapDefLinkColor (c); } + ///////////////////////////////////////////////////////////////////// } else if (com=="setMapLinkStyle") { - if (parser.checkParamCount(1)) + if (parser.checkParCount(1)) { s=parser.parString (ok,0); if (ok) setMapLinkStyle(s); } + ///////////////////////////////////////////////////////////////////// } else if (com=="setHeading") { if (xelection.isEmpty() ) @@ -1053,12 +1142,13 @@ } else if (! selb ) { parser.setError (Aborted,"Type of selection is not a branch"); - } else if (parser.checkParamCount(1)) + } else if (parser.checkParCount(1)) { s=parser.parString (ok,0); if (ok) setHeading (s); } + ///////////////////////////////////////////////////////////////////// } else if (com=="setHideExport") { if (xelection.isEmpty() ) @@ -1067,11 +1157,12 @@ } else if (xelection.type()!=Selection::Branch && xelection.type() != Selection::MapCenter &&xelection.type()!=Selection::FloatImage) { parser.setError (Aborted,"Type of selection is not a branch or floatimage"); - } else if (parser.checkParamCount(1)) + } else if (parser.checkParCount(1)) { b=parser.parBool(ok,0); if (ok) setHideExport (b); } + ///////////////////////////////////////////////////////////////////// } else if (com=="setIncludeImagesHorizontally") { if (xelection.isEmpty() ) @@ -1080,11 +1171,12 @@ } else if (! selb) { parser.setError (Aborted,"Type of selection is not a branch"); - } else if (parser.checkParamCount(1)) + } else if (parser.checkParCount(1)) { b=parser.parBool(ok,0); if (ok) setIncludeImagesHor(b); } + ///////////////////////////////////////////////////////////////////// } else if (com=="setIncludeImagesVertically") { if (xelection.isEmpty() ) @@ -1093,11 +1185,12 @@ } else if (! selb) { parser.setError (Aborted,"Type of selection is not a branch"); - } else if (parser.checkParamCount(1)) + } else if (parser.checkParCount(1)) { b=parser.parBool(ok,0); if (ok) setIncludeImagesVer(b); } + ///////////////////////////////////////////////////////////////////// } else if (com=="setHideLinkUnselected") { if (xelection.isEmpty() ) @@ -1106,18 +1199,20 @@ } else if ( xelection.type()!=Selection::Branch && xelection.type()!= Selection::MapCenter && xelection.type()!=Selection::FloatImage) { parser.setError (Aborted,"Type of selection does not allow hiding the link"); - } else if (parser.checkParamCount(1)) + } else if (parser.checkParCount(1)) { b=parser.parBool(ok,0); if (ok) setHideLinkUnselected(b); } + ///////////////////////////////////////////////////////////////////// } else if (com=="setSelectionColor") { - if (parser.checkParamCount(1)) + if (parser.checkParCount(1)) { QColor c=parser.parColor (ok,0); if (ok) setSelectionColorInt (c); } + ///////////////////////////////////////////////////////////////////// } else if (com=="setURL") { if (xelection.isEmpty() ) @@ -1126,11 +1221,12 @@ } else if (! selb ) { parser.setError (Aborted,"Type of selection is not a branch"); - } else if (parser.checkParamCount(1)) + } else if (parser.checkParCount(1)) { s=parser.parString (ok,0); if (ok) setURL(s); } + ///////////////////////////////////////////////////////////////////// } else if (com=="setVymLink") { if (xelection.isEmpty() ) @@ -1139,12 +1235,13 @@ } else if (! selb ) { parser.setError (Aborted,"Type of selection is not a branch"); - } else if (parser.checkParamCount(1)) + } else if (parser.checkParCount(1)) { s=parser.parString (ok,0); if (ok) setVymLinkInt(s); } } + ///////////////////////////////////////////////////////////////////// else if (com=="setFlag") { if (xelection.isEmpty() ) @@ -1153,7 +1250,7 @@ } else if (! selb ) { parser.setError (Aborted,"Type of selection is not a branch"); - } else if (parser.checkParamCount(1)) + } else if (parser.checkParCount(1)) { s=parser.parString(ok,0); if (ok) @@ -1162,6 +1259,7 @@ selb->updateFlagsToolbar(); } } + ///////////////////////////////////////////////////////////////////// } else if (com=="setFrameType") { if (xelection.isEmpty() ) @@ -1170,12 +1268,13 @@ } else if (! selb ) { parser.setError (Aborted,"Type of selection is not a branch"); - } else if (parser.checkParamCount(1)) + } else if (parser.checkParCount(1)) { s=parser.parString(ok,0); if (ok) setFrameType (s); } + ///////////////////////////////////////////////////////////////////// } else if (com=="toggleFlag") { if (xelection.isEmpty() ) @@ -1184,7 +1283,7 @@ } else if (! selb ) { parser.setError (Aborted,"Type of selection is not a branch"); - } else if (parser.checkParamCount(1)) + } else if (parser.checkParCount(1)) { s=parser.parString(ok,0); if (ok) @@ -1193,6 +1292,7 @@ selb->updateFlagsToolbar(); } } + ///////////////////////////////////////////////////////////////////// } else if (com=="unscroll") { if (xelection.isEmpty() ) @@ -1201,11 +1301,12 @@ } else if (! selb ) { parser.setError (Aborted,"Type of selection is not a branch"); - } else if (parser.checkParamCount(0)) + } else if (parser.checkParCount(0)) { if (!unscrollBranch (selb)) parser.setError (Aborted,"Could not unscroll branch"); } + ///////////////////////////////////////////////////////////////////// } else if (com=="unscrollChilds") { if (xelection.isEmpty() ) @@ -1214,10 +1315,11 @@ } else if (! selb ) { parser.setError (Aborted,"Type of selection is not a branch"); - } else if (parser.checkParamCount(0)) + } else if (parser.checkParCount(0)) { unscrollChilds (); } + ///////////////////////////////////////////////////////////////////// } else if (com=="unsetFlag") { if (xelection.isEmpty() ) @@ -1226,7 +1328,7 @@ } else if (! selb ) { parser.setError (Aborted,"Type of selection is not a branch"); - } else if (parser.checkParamCount(1)) + } else if (parser.checkParCount(1)) { s=parser.parString(ok,0); if (ok) @@ -1616,14 +1718,6 @@ return hidemode; } -void MapEditor::exportImage(QString fn) -{ - setExportMode (true); - QPixmap pix (getPixmap()); - pix.save(fn, "PNG"); - setExportMode (false); -} - void MapEditor::setExportMode (bool b) { // should be called before and after exports @@ -1634,11 +1728,57 @@ setHideTmpMode (BranchObj::HideNone); } -void MapEditor::exportImage(QString fn, QString format) +void MapEditor::exportASCII(QString fname,bool askName) { + ExportASCII ex; + ex.setMapCenter(mapCenter); + if (fname=="") + ex.setFile (mapName+".txt"); + else + ex.setFile (fname); + + if (askName) + { + //ex.addFilter ("TXT (*.txt)"); + ex.setDir(lastImageDir); + //ex.setCaption(vymName+ " -" +tr("Export as ASCII")+" "+tr("(still experimental)")); + ex.execDialog() ; + } + if (!ex.canceled()) + { + setExportMode(true); + ex.doExport(); + setExportMode(false); + } +} + +void MapEditor::exportImage(QString fname, bool askName, QString format) +{ + if (fname=="") + { + fname=mapName+".png"; + format="PNG"; + } + + if (askName) + { + QStringList fl; + QFileDialog *fd=new QFileDialog (this); + fd->setCaption (tr("Export map as image")); + fd->setDirectory (lastImageDir); + fd->setFileMode(QFileDialog::AnyFile); + fd->setFilters (imageIO.getFilters() ); + if (fd->exec()) + { + fl=fd->selectedFiles(); + fname=fl.first(); + format=imageIO.getType(fd->selectedFilter()); + } + } + setExportMode (true); QPixmap pix (getPixmap()); - pix.save(fn, format); + pix.save(fname, format); setExportMode (false); } @@ -1684,7 +1824,7 @@ file.close(); // Now write image, too - exportImage (dir+"/images/"+mapName+".png"); + exportImage (dir+"/images/"+mapName+".png","PNG"); setExportMode (false); } diff -r 5f576e56ad99 -r 497fab7d1404 mapeditor.h --- a/mapeditor.h Tue Jun 19 14:20:29 2007 +0000 +++ b/mapeditor.h Tue Jun 19 14:20:30 2007 +0000 @@ -136,8 +136,10 @@ BranchObj::HideTmpMode getHideTmpMode(); // temporary hide stuff public: void setExportMode (bool); //!< Set or unset temporary hiding of objects during export - void exportImage (QString fn); //!< Export as PNG - void exportImage (QString fn, QString); //!< Export in given format + void exportASCII (QString fname="",bool askForName=true); //!< Export as ASCII + + /*! Save as image */ + void exportImage (QString fname="",bool askForName=true,QString format="PNG"); void exportOOPresentation(const QString &,const QString &); //!< Export as OpenOfficeOrg presentation void exportXML(const QString&); //!< Export as XML to directory void clear(); //!< Clear map diff -r 5f576e56ad99 -r 497fab7d1404 parser.cpp --- a/parser.cpp Tue Jun 19 14:20:29 2007 +0000 +++ b/parser.cpp Tue Jun 19 14:20:30 2007 +0000 @@ -98,7 +98,7 @@ return paramList; } -int Parser::paramCount() +int Parser::parCount() { return paramList.count(); } @@ -141,13 +141,13 @@ } -bool Parser::checkParamCount (QList plist) +bool Parser::checkParCount (QList plist) { QStringList expList; QString expected; for (int i=0; i paramList.count()) @@ -193,7 +193,7 @@ int Parser::parInt (bool &ok,const uint &index) { - if (checkParamIsInt (index)) + if (checkParIsInt (index)) return paramList[index].toInt (&ok, 10); ok=false; return 0; diff -r 5f576e56ad99 -r 497fab7d1404 parser.h --- a/parser.h Tue Jun 19 14:20:29 2007 +0000 +++ b/parser.h Tue Jun 19 14:20:30 2007 +0000 @@ -14,15 +14,15 @@ QString getAtom(); QString getCommand(); QStringList getParameters(); - int paramCount(); + int parCount(); QString errorMessage(); QString errorDescription(); ErrorLevel errorLevel(); void setError (ErrorLevel level,const QString &description); void resetError(); - bool checkParamCount (QList plist); - bool checkParamCount (const int &index); - bool checkParamIsInt (const int &index); + bool checkParCount (QList plist); + bool checkParCount (const int &index); + bool checkParIsInt (const int &index); int parInt (bool &,const uint &index); QString parString(bool &ok,const int &index); bool parBool (bool &ok, const int &index); diff -r 5f576e56ad99 -r 497fab7d1404 tex/vym.tex --- a/tex/vym.tex Tue Jun 19 14:20:29 2007 +0000 +++ b/tex/vym.tex Tue Jun 19 14:20:30 2007 +0000 @@ -24,12 +24,12 @@ \end{center} } \newcommand{\hint}[1]{ - \begin{center} + \begin{center} \begin{tabular}{|rp{12cm}|} \hline - {\bf Hint}:& #1\\ \hline \end{tabular} - \end{center} + \marginpar{\Huge !} + \end{center} } \newcommand{\vym}{{\sc vym }} @@ -39,6 +39,8 @@ \newcommand{\da}{$\downarrow$} \newcommand{\key}[1]{[#1]} +\newenvironment{code}[1] { \verbatim #1}{\endverbatim } + \hypersetup{bookmarks, bookmarksopen, pdftitle={VYM - a tool for visual thinking }, pdfauthor={Uwe Drechsel}, @@ -1078,11 +1080,21 @@ several maps at once. - \section{Scripts} \label{scripts} - %FIXME +\section{Scripts} \label{scripts} %FIXME +TODO: This section of the \vym manual is not complete yet, sorry. - +\subsection{Example scripts} +\subsubsection{Export a set of maps} +\begin{code} +\# Simple vym script to export images of various maps simultanously +export ("image"); +\end{code} +The script above can be used to export all maps in a directory +automatically. If the script is named {\tt export-image.vys}, call \vym with +\begin{code} +\$ vym --quit --run export-image.vys *.vym +\end{code} \section{Contributing to \vym} @@ -1163,11 +1175,11 @@ Make sure you have installed your Qt environment properly, see the Qt documentation for details. You need to have the Qt command {\tt qmake} in your {\tt PATH}-environment, then run -\begin{verbatim} -qmake -make -make install -\end{verbatim} +\begin{code} +\$ qmake +$ make +$ make install +\end{code} The last command {\tt make install} needs root-permissions. Of course it may be omitted, if you just want to test \vym. @@ -1179,9 +1191,9 @@ compressed archive of data. If you want to have a closer look into the data structure map called "mapname.vym", just uncompress the map manually using -\begin{verbatim} - unzip mapname.vym -\end{verbatim} +\begin{code} +\$ unzip mapname.vym +\end{code} This will create directories named {\tt images} and {\tt flags} in your current directory and also the map itself, usually named {\tt mapname.xml}. @@ -1190,22 +1202,18 @@ This XML file can be loaded directly into \vym, it does not have to be compressed. If you want to compress all the data yourself, use -\begin{verbatim} - zip -r mapname.vym . -\end{verbatim} +\begin{code} +\$ zip -r mapname.vym . +\end{code} to compress all data in your current directory. \subsection{New features} There are lots of features which might find their way into \vym. Together with \vym you should have received a directory with several -maps e.g. on SUSE~LINUX this is -\begin{center} - {\tt /usr/share/doc/packages/vym/demos} -\end{center} -where you find the map {\tt todo.vym}. It lists quite a lot of things to -be done in future. If you have more ideas, contact the development team -at -{\tt vym-devel@lists.sourceforge.net}. +example maps. You find them by clicking Help \ra Open~vym~example~maps. +There you will find the map {\tt vym-projectplan.vym}. It lists quite a +lot of things to be done in future. If you have more ideas, contact the +development team at {\tt vym-devel@lists.sourceforge.net}. \subsection{New languages support} @@ -1216,12 +1224,11 @@ needed. In some Linux distributions the development tools are in an extra package, e.g. on SUSE LINUX you should have installed: -\begin{verbatim} - qt3-devel.rpm - qt3-devel-doc.rpm - qt3-devel-tools.rpm - qt3-man.rpm -\end{verbatim} +\begin{code} +libqt4-devel.rpm +libqt4-devel-doc.rpm +libqt4-devel-tools.rpm +\end{code} If you don't have QT in your system, you can get it from \href{http://www.trolltech.com}{http://www.trolltech.com} Once you are able to compile vym yourself, you can translate the text in vym diff -r 5f576e56ad99 -r 497fab7d1404 version.h --- a/version.h Tue Jun 19 14:20:29 2007 +0000 +++ b/version.h Tue Jun 19 14:20:30 2007 +0000 @@ -5,9 +5,9 @@ #define __VYM_NAME "VYM" #define __VYM_VERSION "1.8.73" -#define __VYM_CODENAME "Codename: 1.9.0-beta-1" -//#define __VYM_CODENAME "Codename: development version" -#define __VYM_BUILD_DATE "June 18, 2007" +//#define __VYM_CODENAME "Codename: 1.9.0-beta-1" +#define __VYM_CODENAME "Codename: development version" +#define __VYM_BUILD_DATE "June 19, 2007" bool checkVersion(const QString &);