From: Shamus Hammons Date: Tue, 15 Feb 2011 06:40:57 +0000 (+0000) Subject: In the middle of chasing down MDI not activating bug, renaming of Graphic to X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a18a12fc3bcb18e5c7ca5494d7f97fb8b93f90a2;p=architektonas In the middle of chasing down MDI not activating bug, renaming of Graphic to Drawing, fixing of filee export to bitmap. --- diff --git a/README b/README index 83ca2b5..db3dfaf 100644 --- a/README +++ b/README @@ -53,8 +53,8 @@ good name and hope to live up to the expectations that such a name gives! @-~ Installation ~-@ -Architektonas is built on the Qt 4 framework; it requires version 4.6.3 or -later. We build it using gcc v4.4.3; we can't guarantee that it will compile on +Architektonas is built on the Qt 4 framework; it requires version 4.7.1 or +later. We build it using gcc v4.4.5; we can't guarantee that it will compile on lesser versions but you never know. Building Architektonas should be as easy as typing: diff --git a/architektonas.pro b/architektonas.pro index b9b6b50..6ebcc5d 100644 --- a/architektonas.pro +++ b/architektonas.pro @@ -88,7 +88,6 @@ HEADERS += \ src/base/leader.h \ src/base/line.h \ src/base/linetypepattern.h \ - src/base/mainwindowinterface.h \ src/base/mathextra.h \ src/base/modification.h \ src/base/paintinterface.h \ diff --git a/src/base/actioninterface.cpp b/src/base/actioninterface.cpp index 1b4d5d8..00c5439 100644 --- a/src/base/actioninterface.cpp +++ b/src/base/actioninterface.cpp @@ -53,6 +53,8 @@ ActionInterface::ActionInterface(const char * name, EntityContainer & ec, { DEBUG->print("ActionInterface::ActionInterface: Setting up action: \"%s\"", name); +// Is it? Doesn't seem like it. Whenever you change snap types, the preview disappears. +// Not sure what's going on with that. //This doesn't work properly; not sure why that is... //Actually, it's working perfectly. Now we just need to propagate the fixes everywhere. :-/ // We'll use snapperVisibility for the save/restore functionality... @@ -63,8 +65,9 @@ ActionInterface::ActionInterface(const char * name, EntityContainer & ec, finished = false; // Graphic provides a pointer to the graphic if the entity container is a - // graphic (i.e. can also hold layers). - graphic = ec.getGraphic(); + // drawing (i.e. can also hold layers). +#warning "!!! Need to rename graphic to drawing !!!" + graphic = ec.GetDrawing(); // Document pointer will be used for undo / redo document = ec.getDocument(); diff --git a/src/base/block.cpp b/src/base/block.cpp index 967e7e5..9ce031e 100644 --- a/src/base/block.cpp +++ b/src/base/block.cpp @@ -46,40 +46,40 @@ Entity * Block::clone() LayerList * Block::getLayerList() { - Drawing * g = getGraphic(); + Drawing * d = GetDrawing(); - if (g) - return g->getLayerList(); + if (d) + return d->getLayerList(); return NULL; } BlockList * Block::getBlockList() { - Drawing * g = getGraphic(); + Drawing * d = GetDrawing(); - if (g) - return g->getBlockList(); + if (d) + return d->getBlockList(); return NULL; } bool Block::save() { - Drawing * g = getGraphic(); + Drawing * d = GetDrawing(); - if (g) - return g->save(); + if (d) + return d->save(); return false; } bool Block::saveAs(const QString & filename, RS2::FormatType type) { - Drawing * g = getGraphic(); + Drawing * d = GetDrawing(); - if (g) - return g->saveAs(filename, type); + if (d) + return d->saveAs(filename, type); return false; } @@ -87,14 +87,14 @@ bool Block::saveAs(const QString & filename, RS2::FormatType type) /** * Sets the parent documents modified status to 'm'. */ -void Block::setModified(bool m) +void Block::setModified(bool state) { - Drawing * p = getGraphic(); + Drawing * d = GetDrawing(); - if (p) - p->setModified(m); + if (d) + d->setModified(state); - modified = m; + modified = state; } /** @return RS2::EntityBlock */ diff --git a/src/base/creation.cpp b/src/base/creation.cpp index 55051b4..eb1c7c7 100644 --- a/src/base/creation.cpp +++ b/src/base/creation.cpp @@ -41,7 +41,8 @@ Creation::Creation(EntityContainer * container, GraphicView * graphicView, if (container != NULL) { - graphic = container->getGraphic(); +#warning "!!! need to rename graphic to drawing !!!" + graphic = container->GetDrawing(); document = container->getDocument(); } else diff --git a/src/base/dimaligned.cpp b/src/base/dimaligned.cpp index c25ea9f..8aed4c1 100644 --- a/src/base/dimaligned.cpp +++ b/src/base/dimaligned.cpp @@ -85,13 +85,13 @@ VectorSolutions DimAligned::getRefPoints() QString DimAligned::getMeasuredLabel() { double dist = edata.extensionPoint1.distanceTo(edata.extensionPoint2); - Drawing * graphic = getGraphic(); + Drawing * drawing = GetDrawing(); QString ret; - if (graphic != NULL) + if (drawing) { - ret = Units::formatLinear(dist, graphic->getUnit(), - graphic->getLinearFormat(), graphic->getLinearPrecision()); + ret = Units::formatLinear(dist, drawing->getUnit(), + drawing->getLinearFormat(), drawing->getLinearPrecision()); } else { diff --git a/src/base/dimdiametric.cpp b/src/base/dimdiametric.cpp index 934c1f2..3ba48eb 100644 --- a/src/base/dimdiametric.cpp +++ b/src/base/dimdiametric.cpp @@ -71,19 +71,13 @@ QString DimDiametric::getMeasuredLabel() { // Definitive dimension line: double dist = data.definitionPoint.distanceTo(edata.definitionPoint); + Drawing * drawing = GetDrawing(); - Drawing* graphic = getGraphic(); + if (drawing) + return Units::formatLinear(dist, drawing->getUnit(), + drawing->getLinearFormat(), drawing->getLinearPrecision()); - QString ret; - if (graphic!=NULL) { - ret = Units::formatLinear(dist, graphic->getUnit(), - graphic->getLinearFormat(), graphic->getLinearPrecision()); - } - else { - ret = QString("%1").arg(dist); - } - - return ret; + return QString("%1").arg(dist); } VectorSolutions DimDiametric::getRefPoints() diff --git a/src/base/dimlinear.cpp b/src/base/dimlinear.cpp index 16063aa..239d186 100644 --- a/src/base/dimlinear.cpp +++ b/src/base/dimlinear.cpp @@ -93,19 +93,13 @@ QString DimLinear::getMeasuredLabel() // Definitive dimension line: double dist = dimP1.distanceTo(dimP2); - Drawing * graphic = getGraphic(); + Drawing * drawing = GetDrawing(); - QString ret; + if (drawing) + return Units::formatLinear(dist, drawing->getUnit(), + drawing->getLinearFormat(), drawing->getLinearPrecision()); - if (graphic) - ret = Units::formatLinear(dist, graphic->getUnit(), - graphic->getLinearFormat(), graphic->getLinearPrecision()); - else - ret = QString("%1").arg(dist); -//It's properly creating the label... -//printf("DimLinear::getMeasuredLabel: label=\"%s\"\n", ret.toAscii().data()); - - return ret; + return QString("%1").arg(dist); } bool DimLinear::hasEndpointsWithinWindow(Vector v1, Vector v2) diff --git a/src/base/dimradial.cpp b/src/base/dimradial.cpp index dd78362..40e3985 100644 --- a/src/base/dimradial.cpp +++ b/src/base/dimradial.cpp @@ -68,27 +68,22 @@ DimRadialData DimRadial::getEData() const */ QString DimRadial::getMeasuredLabel() { - // Definitive dimension line: - double dist = data.definitionPoint.distanceTo(edata.definitionPoint); + // Definitive dimension line: + double dist = data.definitionPoint.distanceTo(edata.definitionPoint); + Drawing * drawing = GetDrawing(); - Drawing* graphic = getGraphic(); + if (drawing) + return Units::formatLinear(dist, drawing->getUnit(), + drawing->getLinearFormat(), drawing->getLinearPrecision()); - QString ret; - if (graphic!=NULL) { - ret = Units::formatLinear(dist, graphic->getUnit(), - graphic->getLinearFormat(), graphic->getLinearPrecision()); - } else { - ret = QString("%1").arg(dist); - } - - return ret; + return QString("%1").arg(dist); } -VectorSolutions DimRadial::getRefPoints() { - VectorSolutions ret(edata.definitionPoint, - data.definitionPoint, data.middleOfText); - return ret; +VectorSolutions DimRadial::getRefPoints() +{ + return VectorSolutions(edata.definitionPoint, + data.definitionPoint, data.middleOfText); } /** diff --git a/src/base/document.h b/src/base/document.h index 8c0044e..a8cf645 100644 --- a/src/base/document.h +++ b/src/base/document.h @@ -9,11 +9,12 @@ class BlockList; class LayerList; /** - * Base class for documents. Documents can be either graphics or - * blocks and are typically shown in graphic views. Documents hold - * an active pen for drawing in the Document, a file name and they - * know whether they have been modified or not. + * Base class for documents. Documents can be either Drawings or Blocks and are + * typically shown in graphic views. Documents hold an active pen for drawing + * in the Document, a file name and they know whether they have been modified + * or not. * + * @author James Hammons * @author Andrew Mustun */ class Document: public EntityContainer, public Undo diff --git a/src/base/drawing.cpp b/src/base/drawing.cpp index d376e04..27f4935 100644 --- a/src/base/drawing.cpp +++ b/src/base/drawing.cpp @@ -67,10 +67,10 @@ Drawing::~Drawing() { } -/** @return RS2::EntityGraphic */ +/** @return RS2::EntityDrawing */ /*virtual*/ RS2::EntityType Drawing::rtti() const { - return RS2::EntityGraphic; + return RS2::EntityDrawing; } /** @@ -84,7 +84,7 @@ unsigned long int Drawing::countLayerEntities(Layer * layer) { for(Entity * t=firstEntity(RS2::ResolveNone); t!=NULL; t=nextEntity(RS2::ResolveNone)) { - if (t->getLayer()!=NULL && t->getLayer()->getName()==layer->getName()) + if (t->getLayer() != NULL && t->getLayer()->getName() == layer->getName()) { c += t->countDeep(); } @@ -113,13 +113,9 @@ void Drawing::newDoc() DEBUG->print("Drawing::newDoc"); clear(); - clearLayers(); clearBlocks(); - addLayer(new Layer("0")); - //addLayer(new Layer("ByBlock")); - setModified(false); } diff --git a/src/base/entity.cpp b/src/base/entity.cpp index b9c42e3..aa6abb7 100644 --- a/src/base/entity.cpp +++ b/src/base/entity.cpp @@ -428,14 +428,14 @@ void Entity::setParent(EntityContainer * p) * or the parent's parent graphic or NULL if none of the parents * are stored in a graphic. */ -Drawing * Entity::getGraphic() +Drawing * Entity::GetDrawing() { - if (rtti() == RS2::EntityGraphic) + if (rtti() == RS2::EntityDrawing) return (Drawing *)this; else if (parent == NULL) return NULL; else - return parent->getGraphic(); + return parent->GetDrawing(); } /** @@ -554,10 +554,10 @@ Vector Entity::getSize() const */ void Entity::addGraphicVariable(const QString & key, double val, int code) { - Drawing * graphic = getGraphic(); + Drawing * drawing = GetDrawing(); - if (graphic != NULL) - graphic->addVariable(key, val, code); + if (drawing) + drawing->addVariable(key, val, code); } /** @@ -568,10 +568,10 @@ void Entity::addGraphicVariable(const QString & key, double val, int code) */ void Entity::addGraphicVariable(const QString & key, int val, int code) { - Drawing * graphic = getGraphic(); + Drawing * drawing = GetDrawing(); - if (graphic != NULL) - graphic->addVariable(key, val, code); + if (drawing) + drawing->addVariable(key, val, code); } /** @@ -582,10 +582,10 @@ void Entity::addGraphicVariable(const QString & key, int val, int code) */ void Entity::addGraphicVariable(const QString & key, const QString & val, int code) { - Drawing * graphic = getGraphic(); + Drawing * drawing = GetDrawing(); - if (graphic != NULL) - graphic->addVariable(key, val, code); + if (drawing) + drawing->addVariable(key, val, code); } /** @@ -599,11 +599,11 @@ void Entity::addGraphicVariable(const QString & key, const QString & val, int co */ double Entity::getGraphicVariableDouble(const QString & key, double def) { - Drawing * graphic = getGraphic(); + Drawing * drawing = GetDrawing(); double ret = def; - if (graphic != NULL) - ret = graphic->getVariableDouble(key, def); + if (drawing) + ret = drawing->getVariableDouble(key, def); return ret; } @@ -619,11 +619,11 @@ double Entity::getGraphicVariableDouble(const QString & key, double def) */ int Entity::getGraphicVariableInt(const QString & key, int def) { - Drawing * graphic = getGraphic(); + Drawing * drawing = GetDrawing(); int ret = def; - if (graphic != NULL) - ret = graphic->getVariableInt(key, def); + if (drawing) + ret = drawing->getVariableInt(key, def); return ret; } @@ -639,11 +639,11 @@ int Entity::getGraphicVariableInt(const QString & key, int def) */ QString Entity::getGraphicVariableString(const QString & key, const QString & def) { - Drawing * graphic = getGraphic(); + Drawing * drawing = GetDrawing(); QString ret = def; - if (graphic != NULL) - ret = graphic->getVariableString(key, def); + if (drawing) + ret = drawing->getVariableString(key, def); return ret; } @@ -654,11 +654,11 @@ QString Entity::getGraphicVariableString(const QString & key, const QString & de */ RS2::Unit Entity::getGraphicUnit() { - Drawing * graphic = getGraphic(); + Drawing * drawing = GetDrawing(); RS2::Unit ret = RS2::None; - if (graphic != NULL) - ret = graphic->getUnit(); + if (drawing) + ret = drawing->getUnit(); return ret; } @@ -668,8 +668,7 @@ RS2::Unit Entity::getGraphicUnit() */ /*virtual*/ VectorSolutions Entity::getRefPoints() { - VectorSolutions ret; - return ret; + return VectorSolutions(); } /** @@ -788,12 +787,8 @@ Layer * Entity::getLayer(bool resolve) const */ void Entity::setLayer(const QString & name) { - Drawing * graphic = getGraphic(); - - if (graphic != NULL) - layer = graphic->findLayer(name); - else - layer = NULL; + Drawing * drawing = GetDrawing(); + layer = (drawing ? drawing->findLayer(name) : NULL); } /** @@ -811,12 +806,8 @@ void Entity::setLayer(Layer * l) */ void Entity::setLayerToActive() { - Drawing * graphic = getGraphic(); - - if (graphic != NULL) - layer = graphic->getActiveLayer(); - else - layer = NULL; + Drawing * drawing = GetDrawing(); + layer = (drawing ? drawing->getActiveLayer() : NULL); } /** @@ -932,12 +923,12 @@ double Entity::getStyleFactor(GraphicView * view) //styleFactor = getStyleFactor(); // the factor caused by the unit: RS2::Unit unit = RS2::None; - Drawing * g = getGraphic(); + Drawing * d = GetDrawing(); - if (g != NULL) + if (d) { - unit = g->getUnit(); - //double scale = g->getPaperScale(); + unit = d->getUnit(); + //double scale = d->getPaperScale(); styleFactor = Units::convert(1.0, RS2::Millimeter, unit); // / scale; } @@ -951,10 +942,10 @@ double Entity::getStyleFactor(GraphicView * view) if (view->isPrinting() || view->isPrintPreview() || view->isDraftMode() == false) { - Drawing * graphic = getGraphic(); + Drawing * drawing = GetDrawing(); - if (graphic != NULL && graphic->getPaperScale() > 1.0e-6) - styleFactor /= graphic->getPaperScale(); + if (drawing && drawing->getPaperScale() > 1.0e-6) + styleFactor /= drawing->getPaperScale(); } } diff --git a/src/base/entity.h b/src/base/entity.h index c7c996c..429ded2 100644 --- a/src/base/entity.h +++ b/src/base/entity.h @@ -59,7 +59,7 @@ class Entity: public Undoable virtual double getLength(); EntityContainer * getParent() const; void setParent(EntityContainer * p); - Drawing * getGraphic(); + Drawing * GetDrawing(); Block * getBlock(); Insert * getInsert(); Entity * getBlockOrInsert(); diff --git a/src/base/enums.h b/src/base/enums.h index 667f311..dd5678b 100644 --- a/src/base/enums.h +++ b/src/base/enums.h @@ -95,7 +95,7 @@ public: EntityBlock, /**< Block (Group definition) */ EntityFontChar, /**< Font character */ EntityInsert, /**< Insert (Group instance) */ - EntityGraphic, /**< Graphic with layers */ + EntityDrawing, /**< Drawing with layers */ EntityPoint, /**< Point */ EntityLine, /**< Line */ EntityPolyline, /**< Polyline */ diff --git a/src/base/fileio.cpp b/src/base/fileio.cpp index cde23ea..8390be1 100644 --- a/src/base/fileio.cpp +++ b/src/base/fileio.cpp @@ -89,15 +89,14 @@ FilterInterface * FileIO::getExportFilter(RS2::FormatType t) } /** - * Calls the import method of the filter responsible for the format - * of the given file. + * Calls the import method of the filter responsible for the format of the + * given file. * - * @param graphic The container to which we will add - * entities. Usually that's an Drawing entity but - * it can also be a polyline, text, ... + * @param drawing The container to which we will add entities. Usually that's + * an Drawing entity but it can also be a polyline, text, ... * @param file Path and name of the file to import. */ -bool FileIO::fileImport(Drawing & graphic, const QString & file, RS2::FormatType type) +bool FileIO::fileImport(Drawing & drawing, const QString & file, RS2::FormatType type) { DEBUG->print("Trying to import file '%s'...", file.toAscii().data()); @@ -106,7 +105,7 @@ bool FileIO::fileImport(Drawing & graphic, const QString & file, RS2::FormatType filter = getImportFilter(t); if (filter) - return filter->fileImport(graphic, file, t); + return filter->fileImport(drawing, file, t); else { DEBUG->print(Debug::D_WARNING, "FileIO::fileImport: failed to import file: %s", @@ -117,12 +116,12 @@ bool FileIO::fileImport(Drawing & graphic, const QString & file, RS2::FormatType } /** - * Calls the export method of the object responsible for the format - * of the given file. + * Calls the export method of the object responsible for the format of the + * given file. * * @param file Path and name of the file to import. */ -bool FileIO::fileExport(Drawing & graphic, const QString & file, RS2::FormatType type) +bool FileIO::fileExport(Drawing & drawing, const QString & file, RS2::FormatType type) { DEBUG->print("FileIO::fileExport"); @@ -139,7 +138,7 @@ bool FileIO::fileExport(Drawing & graphic, const QString & file, RS2::FormatType FilterInterface * filter = getExportFilter(type); if (filter) - return filter->fileExport(graphic, file, type); + return filter->fileExport(drawing, file, type); DEBUG->print("FileIO::fileExport: no filter found"); diff --git a/src/base/fileio.h b/src/base/fileio.h index d3b90ed..97b0f5a 100644 --- a/src/base/fileio.h +++ b/src/base/fileio.h @@ -26,9 +26,9 @@ class FileIO QList getFilterList(); FilterInterface * getImportFilter(RS2::FormatType t); FilterInterface * getExportFilter(RS2::FormatType t); - bool fileImport(Drawing & graphic, const QString & file, + bool fileImport(Drawing & dwg, const QString & file, RS2::FormatType type = RS2::FormatUnknown); - bool fileExport(Drawing & graphic, const QString & file, + bool fileExport(Drawing & dwg, const QString & file, RS2::FormatType type = RS2::FormatUnknown); RS2::FormatType detectFormat(const QString & file); diff --git a/src/base/filterdxf.cpp b/src/base/filterdxf.cpp index 5bc1058..72f7960 100644 --- a/src/base/filterdxf.cpp +++ b/src/base/filterdxf.cpp @@ -1074,7 +1074,7 @@ void FilterDXF::setVariableVector(const char * key, double v1, double v2, double DEBUG->print("FilterDXF::setVariableVector"); // update document's variable list: - if (currentContainer->rtti() == RS2::EntityGraphic) + if (currentContainer->rtti() == RS2::EntityDrawing) ((Drawing *)currentContainer)->addVariable(QString(key), Vector(v1, v2, v3), code); } @@ -1083,16 +1083,16 @@ void FilterDXF::setVariableVector(const char * key, double v1, double v2, double */ void FilterDXF::setVariableString(const char * key, const char * value, int code) { - DEBUG->print("FilterDXF::setVariableString"); + DEBUG->print("FilterDXF::setVariableString"); - // update local DXF variable list: - variables.add(QString(key), QString(value), code); + // update local DXF variable list: + variables.add(QString(key), QString(value), code); - // update document's variable list: - if (currentContainer->rtti()==RS2::EntityGraphic) { - ((Drawing*)currentContainer)->addVariable(QString(key), - QString(value), code); - } + // update document's variable list: + if (currentContainer->rtti()==RS2::EntityDrawing) + { + ((Drawing *)currentContainer)->addVariable(QString(key), QString(value), code); + } } @@ -1100,14 +1100,15 @@ void FilterDXF::setVariableString(const char * key, const char * value, int code /** * Sets an int variable from the DXF file. */ -void FilterDXF::setVariableInt(const char* key, int value, int code) { - DEBUG->print("FilterDXF::setVariableInt"); +void FilterDXF::setVariableInt(const char* key, int value, int code) +{ + DEBUG->print("FilterDXF::setVariableInt"); - // update document's variable list: - if (currentContainer->rtti()==RS2::EntityGraphic) { - ((Drawing*)currentContainer)->addVariable(QString(key), - value, code); - } + // update document's variable list: + if (currentContainer->rtti()==RS2::EntityDrawing) + { + ((Drawing *)currentContainer)->addVariable(QString(key), value, code); + } } @@ -1115,14 +1116,15 @@ void FilterDXF::setVariableInt(const char* key, int value, int code) { /** * Sets a double variable from the DXF file. */ -void FilterDXF::setVariableDouble(const char* key, double value, int code) { - DEBUG->print("FilterDXF::setVariableDouble"); +void FilterDXF::setVariableDouble(const char* key, double value, int code) +{ + DEBUG->print("FilterDXF::setVariableDouble"); - // update document's variable list: - if (currentContainer->rtti() == RS2::EntityGraphic) + // update document's variable list: + if (currentContainer->rtti() == RS2::EntityDrawing) { - ((Drawing *)currentContainer)->addVariable(QString(key), value, code); - } + ((Drawing *)currentContainer)->addVariable(QString(key), value, code); + } } /** diff --git a/src/base/grid.cpp b/src/base/grid.cpp index 163a12b..bfb9cc8 100644 --- a/src/base/grid.cpp +++ b/src/base/grid.cpp @@ -56,7 +56,7 @@ void Grid::update() if (!graphicView->isGridOn()) return; - Drawing * graphic = graphicView->getGraphic(); + Drawing * drawing = graphicView->GetDrawing(); // auto scale grid? settings.beginGroup("Appearance"); @@ -67,8 +67,8 @@ void Grid::update() // get grid setting Vector userGrid; - if (graphic != NULL) - userGrid = graphic->getVariableVector("$GRIDUNIT", Vector(-1.0, -1.0)); + if (drawing != NULL) + userGrid = drawing->getVariableVector("$GRIDUNIT", Vector(-1.0, -1.0)); // delete old grid: if (pt != NULL) @@ -99,10 +99,10 @@ void Grid::update() RS2::Unit unit = RS2::None; RS2::LinearFormat format = RS2::Decimal; - if (graphic != NULL) + if (drawing != NULL) { - unit = graphic->getUnit(); - format = graphic->getLinearFormat(); + unit = drawing->getUnit(); + format = drawing->getLinearFormat(); } Vector gridWidth; @@ -310,16 +310,12 @@ void Grid::update() && graphicView->toGuiDY(gridWidth.y) > 2) { // find grid boundaries - double left = (int)(graphicView->toGraphX(0) / gridWidth.x) - * gridWidth.x; + double left = (int)(graphicView->toGraphX(0) / gridWidth.x) * gridWidth.x; double right = (int)(graphicView->toGraphX(graphicView->getWidth()) / gridWidth.x) * gridWidth.x; - double top = (int)(graphicView->toGraphY(0) + double top = (int)(graphicView->toGraphY(0) / gridWidth.y) * gridWidth.y; + double bottom = (int)(graphicView->toGraphY(graphicView->getHeight()) / gridWidth.y) * gridWidth.y; - double bottom = - (int)(graphicView->toGraphY(graphicView->getHeight()) - / gridWidth.y) * gridWidth.y; - left -= gridWidth.x; right += gridWidth.x; diff --git a/src/base/information.cpp b/src/base/information.cpp index 6c63857..4838f97 100644 --- a/src/base/information.cpp +++ b/src/base/information.cpp @@ -64,7 +64,7 @@ bool Information::isTrimmable(Entity * e) return true; } else if (e->getParent()->rtti() == RS2::EntityContainer - || e->getParent()->rtti() == RS2::EntityGraphic + || e->getParent()->rtti() == RS2::EntityDrawing || e->getParent()->rtti() == RS2::EntityBlock) { // normal entity: @@ -108,10 +108,10 @@ bool Information::isTrimmable(Entity * e1, Entity * e2) } } else if ((e1->getParent()->rtti() == RS2::EntityContainer - || e1->getParent()->rtti() == RS2::EntityGraphic + || e1->getParent()->rtti() == RS2::EntityDrawing || e1->getParent()->rtti() == RS2::EntityBlock) && (e2->getParent()->rtti() == RS2::EntityContainer - || e2->getParent()->rtti() == RS2::EntityGraphic + || e2->getParent()->rtti() == RS2::EntityDrawing || e2->getParent()->rtti() == RS2::EntityBlock)) { // normal entities: diff --git a/src/base/insert.cpp b/src/base/insert.cpp index c6b9ea1..7cc6a9a 100644 --- a/src/base/insert.cpp +++ b/src/base/insert.cpp @@ -86,25 +86,15 @@ Block * Insert::getBlockForInsert() BlockList * blkList; if (!data.blockSource) - { - blkList = (getGraphic() ? getGraphic()->getBlockList() : NULL); - } + blkList = (GetDrawing() ? GetDrawing()->getBlockList() : NULL); else - { blkList = data.blockSource; - } Block * blk = NULL; if (blkList) blk = blkList->find(data.name); -/*??? - if (blk) - { - } -*/ - block = blk; return blk; diff --git a/src/base/mainwindowinterface.h b/src/base/mainwindowinterface.h deleted file mode 100644 index 2fa4f7a..0000000 --- a/src/base/mainwindowinterface.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef __MAINWINDOWINTERFACE_H__ -#define __MAINWINDOWINTERFACE_H__ - -class GraphicView; -class Document; - -/** - * Interface for main application windows. - */ -class MainWindowInterface -{ -public: - MainWindowInterface() {} - virtual ~MainWindowInterface() {} - - virtual GraphicView * getGraphicView() = 0; - virtual Document * getDocument() = 0; - - virtual void createNewDocument(const QString & fileName = QString::null, Document * doc = NULL) = 0; - virtual void showSimulationControls() = 0; -}; - -#endif diff --git a/src/base/modification.cpp b/src/base/modification.cpp index 9cac119..5e7f937 100644 --- a/src/base/modification.cpp +++ b/src/base/modification.cpp @@ -39,11 +39,12 @@ Modification::Modification(EntityContainer & container, GraphicView * graphicView, bool handleUndo) { - this->container = &container; - this->graphicView = graphicView; - this->handleUndo = handleUndo; - graphic = container.getGraphic(); - document = container.getDocument(); + this->container = &container; + this->graphicView = graphicView; + this->handleUndo = handleUndo; +#warning "!!! Need to rename graphic to drawing !!!" + graphic = container.GetDrawing(); + document = container.getDocument(); } /** diff --git a/src/base/selection.cpp b/src/base/selection.cpp index ce50e01..8550de1 100644 --- a/src/base/selection.cpp +++ b/src/base/selection.cpp @@ -33,7 +33,8 @@ Selection::Selection(EntityContainer & container, GraphicView * graphicView) { this->container = &container; this->graphicView = graphicView; - graphic = container.getGraphic(); +#warning "!!! Need to rename graphic to drawing !!!" + graphic = container.GetDrawing(); } /** @@ -148,12 +149,9 @@ void Selection::selectIntersected(const Vector & v1, const Vector & v2, bool sel Line line(NULL, LineData(v1, v2)); bool inters; - for (Entity* e=container->firstEntity(); e!=NULL; - e=container->nextEntity()) { - //for (uint i=0; icount(); ++i) { - //Entity* e = container->entityAt(i); - - if (e!=NULL && e->isVisible()) + for(Entity * e=container->firstEntity(); e!=NULL; e=container->nextEntity()) + { + if (e && e->isVisible()) { inters = false; @@ -245,33 +243,37 @@ void Selection::selectContour(Entity * e) //for (uint i=0; icount(); ++i) { //Entity* en = container->entityAt(i); - if (en!=NULL && en->isVisible() && - en->isAtomic() && en->isSelected()!=select && - (en->getLayer()==NULL || en->getLayer()->isLocked()==false)) + if (en && en->isVisible() && en->isAtomic() + && en->isSelected() != select && (en->getLayer() == NULL + || en->getLayer()->isLocked() == false)) { ae = (AtomicEntity *)en; bool doit = false; // startpoint connects to 1st point - if (ae->getStartpoint().distanceTo(p1)<1.0e-4) { + if (ae->getStartpoint().distanceTo(p1) < 1.0e-4) + { doit = true; p1 = ae->getEndpoint(); } // endpoint connects to 1st point - else if (ae->getEndpoint().distanceTo(p1)<1.0e-4) { + else if (ae->getEndpoint().distanceTo(p1) < 1.0e-4) + { doit = true; p1 = ae->getStartpoint(); } // startpoint connects to 2nd point - else if (ae->getStartpoint().distanceTo(p2)<1.0e-4) { + else if (ae->getStartpoint().distanceTo(p2) < 1.0e-4) + { doit = true; p2 = ae->getEndpoint(); } // endpoint connects to 1st point - else if (ae->getEndpoint().distanceTo(p2)<1.0e-4) { + else if (ae->getEndpoint().distanceTo(p2) < 1.0e-4) + { doit = true; p2 = ae->getStartpoint(); } @@ -296,7 +298,8 @@ void Selection::selectContour(Entity * e) } } } - } while(found); + } + while(found); } /** diff --git a/src/forms/dlgarc.cpp b/src/forms/dlgarc.cpp index 847667a..f013f51 100644 --- a/src/forms/dlgarc.cpp +++ b/src/forms/dlgarc.cpp @@ -35,14 +35,14 @@ void DlgArc::setArc(Arc & a) arc = &a; //pen = arc->getPen(); ui.wPen->setPen(arc->getPen(false), true, false, "Pen"); - Drawing * graphic = arc->getGraphic(); + Drawing * drawing = arc->GetDrawing(); - if (graphic != NULL) - ui.cbLayer->init(*(graphic->getLayerList()), false, false); + if (drawing) + ui.cbLayer->init(*(drawing->getLayerList()), false, false); Layer * lay = arc->getLayer(false); - if (lay != NULL) + if (lay) ui.cbLayer->setLayer(*lay); QString s; diff --git a/src/forms/dlgcircle.cpp b/src/forms/dlgcircle.cpp index f332890..a117dd2 100644 --- a/src/forms/dlgcircle.cpp +++ b/src/forms/dlgcircle.cpp @@ -35,10 +35,10 @@ void DlgCircle::setCircle(Circle & c) circle = &c; //pen = circle->getPen(); ui.wPen->setPen(circle->getPen(false), true, false, "Pen"); - Drawing * graphic = circle->getGraphic(); + Drawing * drawing = circle->GetDrawing(); - if (graphic != NULL) - ui.cbLayer->init(*(graphic->getLayerList()), false, false); + if (drawing) + ui.cbLayer->init(*(drawing->getLayerList()), false, false); Layer * lay = circle->getLayer(false); diff --git a/src/forms/dlgdimension.cpp b/src/forms/dlgdimension.cpp index 11340ad..b6297c3 100644 --- a/src/forms/dlgdimension.cpp +++ b/src/forms/dlgdimension.cpp @@ -33,10 +33,10 @@ void DlgDimension::setDim(Dimension & d) { dim = &d; ui.wPen->setPen(dim->getPen(false), true, false, "Pen"); - Drawing * graphic = dim->getGraphic(); + Drawing * drawing = dim->GetDrawing(); - if (graphic) - ui.cbLayer->init(*(graphic->getLayerList()), false, false); + if (drawing) + ui.cbLayer->init(*(drawing->getLayerList()), false, false); Layer * lay = dim->getLayer(false); diff --git a/src/forms/dlgdimlinear.cpp b/src/forms/dlgdimlinear.cpp index ba92dec..a4355af 100644 --- a/src/forms/dlgdimlinear.cpp +++ b/src/forms/dlgdimlinear.cpp @@ -34,10 +34,10 @@ void DlgDimLinear::setDim(DimLinear & d) { dim = &d; ui.wPen->setPen(dim->getPen(false), true, false, "Pen"); - Drawing * graphic = dim->getGraphic(); + Drawing * drawing = dim->GetDrawing(); - if (graphic) - ui.cbLayer->init(*(graphic->getLayerList()), false, false); + if (drawing) + ui.cbLayer->init(*(drawing->getLayerList()), false, false); Layer * lay = dim->getLayer(false); diff --git a/src/forms/dlgellipse.cpp b/src/forms/dlgellipse.cpp index 2b4eda5..2a5a9d5 100644 --- a/src/forms/dlgellipse.cpp +++ b/src/forms/dlgellipse.cpp @@ -35,10 +35,10 @@ void DlgEllipse::setEllipse(Ellipse & e) ellipse = &e; //pen = ellipse->getPen(); ui.wPen->setPen(ellipse->getPen(false), true, false, "Pen"); - Drawing * graphic = ellipse->getGraphic(); + Drawing * drawing = ellipse->GetDrawing(); - if (graphic != NULL) - ui.cbLayer->init(*(graphic->getLayerList()), false, false); + if (drawing) + ui.cbLayer->init(*(drawing->getLayerList()), false, false); Layer * lay = ellipse->getLayer(false); diff --git a/src/forms/dlginsert.cpp b/src/forms/dlginsert.cpp index be029bf..a66d8ca 100644 --- a/src/forms/dlginsert.cpp +++ b/src/forms/dlginsert.cpp @@ -35,10 +35,10 @@ void DlgInsert::setInsert(Insert & i) insert = &i; //pen = insert->getPen(); ui.wPen->setPen(insert->getPen(false), true, false, "Pen"); - Drawing * graphic = insert->getGraphic(); + Drawing * drawing = insert->GetDrawing(); - if (graphic) - ui.cbLayer->init(*(graphic->getLayerList()), false, false); + if (drawing) + ui.cbLayer->init(*(drawing->getLayerList()), false, false); Layer * lay = insert->getLayer(false); diff --git a/src/forms/dlgline.cpp b/src/forms/dlgline.cpp index 0374cb3..cf233b6 100644 --- a/src/forms/dlgline.cpp +++ b/src/forms/dlgline.cpp @@ -35,10 +35,10 @@ void DlgLine::setLine(Line & l) line = &l; //pen = line->getPen(); ui.wPen->setPen(line->getPen(false), true, false, "Pen"); - Drawing * graphic = line->getGraphic(); + Drawing * drawing = line->GetDrawing(); - if (graphic) - ui.cbLayer->init(*(graphic->getLayerList()), false, false); + if (drawing) + ui.cbLayer->init(*(drawing->getLayerList()), false, false); Layer * lay = line->getLayer(false); diff --git a/src/forms/dlgpoint.cpp b/src/forms/dlgpoint.cpp index bb276ff..163e1c5 100644 --- a/src/forms/dlgpoint.cpp +++ b/src/forms/dlgpoint.cpp @@ -35,10 +35,10 @@ void DlgPoint::setPoint(Point & p) point = &p; ui.wPen->setPen(point->getPen(false), true, false, "Pen"); - Drawing * graphic = point->getGraphic(); + Drawing * drawing = point->GetDrawing(); - if (graphic) - ui.cbLayer->init(*(graphic->getLayerList()), false, false); + if (drawing) + ui.cbLayer->init(*(drawing->getLayerList()), false, false); Layer * lay = point->getLayer(false); diff --git a/src/forms/dlgspline.cpp b/src/forms/dlgspline.cpp index 7624a22..e0a852a 100644 --- a/src/forms/dlgspline.cpp +++ b/src/forms/dlgspline.cpp @@ -34,11 +34,11 @@ void DlgSpline::setSpline(Spline & e) spline = &e; //pen = spline->getPen(); ui.wPen->setPen(spline->getPen(false), true, false, "Pen"); - Drawing * graphic = spline->getGraphic(); + Drawing * drawing = spline->GetDrawing(); Layer * lay = spline->getLayer(false); - if (graphic) - ui.cbLayer->init(*(graphic->getLayerList()), false, false); + if (drawing) + ui.cbLayer->init(*(drawing->getLayerList()), false, false); if (lay) ui.cbLayer->setLayer(*lay); diff --git a/src/forms/exitdialog.cpp b/src/forms/exitdialog.cpp index 0f69f8a..59c8e7c 100644 --- a/src/forms/exitdialog.cpp +++ b/src/forms/exitdialog.cpp @@ -63,11 +63,6 @@ void ExitDialog::setTitle(const QString & text) setWindowTitle(text); } -void ExitDialog::setForce(bool force) -{ - ui.bCancel->setDisabled(force); -} - void ExitDialog::slotSaveAs() { done(3); diff --git a/src/forms/exitdialog.h b/src/forms/exitdialog.h index d06ae3b..843e1f8 100644 --- a/src/forms/exitdialog.h +++ b/src/forms/exitdialog.h @@ -14,7 +14,6 @@ class ExitDialog: public QDialog public slots: void setText(const QString & text); void setTitle(const QString & text); - void setForce(bool force); void slotSaveAs(); void slotSave(); diff --git a/src/mainapp/applicationwindow.cpp b/src/mainapp/applicationwindow.cpp index 61da666..45c96aa 100644 --- a/src/mainapp/applicationwindow.cpp +++ b/src/mainapp/applicationwindow.cpp @@ -19,6 +19,7 @@ #include "applicationwindow.h" #include +#include #include "actiondrawlinefree.h" #include "actionlibraryinsert.h" #include "actionprintpreview.h" @@ -79,18 +80,15 @@ extern QSplashScreen * splash; * Constructor. Initializes the app. */ ApplicationWindow::ApplicationWindow(): -// Q3MainWindow(0, "", Qt::WDestructiveClose), QG_MainWindowInterface() QMainWindow((QWidget *)NULL/*,this is not a Qt::WindowFlags --> Qt::WA_DeleteOnClose*/), QG_MainWindowInterface() { DEBUG->print("ApplicationWindow::ApplicationWindow"); appWindow = this; -//no assistant = NULL; workspace = NULL; +#warning "!!! Need to create new application icon !!!" DEBUG->print("ApplicationWindow::ApplicationWindow: setting icon"); -// setIcon(qPixmapFromMimeSource(QC_APP_ICON)); -// setWindowIcon(qPixmapFromMimeSource(QC_APP_ICON)); setWindowIcon(QIcon(":/res/" QC_APP_ICON)); CreateQtActions(this); @@ -119,25 +117,18 @@ ApplicationWindow::ApplicationWindow(): dialogFactory = new QC_DialogFactory(this, optionWidget); DEBUG->print("ApplicationWindow::ApplicationWindow: creating dialogFactory: OK"); DEBUG->print("setting dialog factory object"); - - if (DialogFactory::instance() == NULL) - DEBUG->print("no DialogFactory instance"); - else - DEBUG->print("got DialogFactory instance"); - + DEBUG->print("%s DialogFactory instance", (DialogFactory::instance() ? "got" : "no")); DialogFactory::instance()->setFactoryObject(dialogFactory); DEBUG->print("setting dialog factory object: OK"); DEBUG->print("ApplicationWindow::ApplicationWindow: init settings"); initSettings(); - DEBUG->print("ApplicationWindow::ApplicationWindow: init MDI"); initMDI(); // Disable menu and toolbar items - emit windowsChanged(FALSE); + emit windowsChanged(false); -//FAIL statusBar()->showMessage(QC_APPNAME " Ready", 2000); statusBar()->showMessage("Architektonas Ready", 2000); //setFocusPolicy(WheelFocus); } @@ -161,14 +152,7 @@ ApplicationWindow::~ApplicationWindow() DEBUG->print("ApplicationWindow::~ApplicationWindow: deleting dialog factory"); delete dialogFactory; DEBUG->print("ApplicationWindow::~ApplicationWindow: deleting dialog factory: OK"); - -//no DEBUG->print("ApplicationWindow::~ApplicationWindow: " -// "deleting assistant.."); -// if (assistant!=NULL) { -// delete assistant; -// } -// DEBUG->print("ApplicationWindow::~ApplicationWindow: " -// "deleting assistant: OK"); + DEBUG->print("ApplicationWindow::~ApplicationWindow: OK"); } @@ -404,7 +388,7 @@ void ApplicationWindow::initActions() menu->addAction(actionFilePrintPreview); tb->addAction(actionFilePrintPreview); connect(actionFilePrintPreview, SIGNAL(toggled(bool)), this, SLOT(slotFilePrintPreview(bool))); - connect(this, SIGNAL(printPreviewChanged(bool)), actionFilePrintPreview, SLOT(setOn(bool))); +//??? connect(this, SIGNAL(printPreviewChanged(bool)), actionFilePrintPreview, SLOT(setOn(bool))); connect(this, SIGNAL(windowsChanged(bool)), actionFilePrintPreview, SLOT(setEnabled(bool))); menu->addSeparator(); @@ -486,7 +470,7 @@ void ApplicationWindow::initActions() tb->addAction(actionViewGrid); actionViewGrid->setChecked(true); connect(actionViewGrid, SIGNAL(toggled(bool)), this, SLOT(slotViewGrid(bool))); - connect(this, SIGNAL(gridChanged(bool)), actionViewGrid, SLOT(setOn(bool))); +//??? connect(this, SIGNAL(gridChanged(bool)), actionViewGrid, SLOT(setOn(bool))); connect(this, SIGNAL(windowsChanged(bool)), actionViewGrid, SLOT(setEnabled(bool))); settings.beginGroup("Appearance"); @@ -498,23 +482,9 @@ void ApplicationWindow::initActions() tb->addAction(actionViewDraft); actionViewDraft->setChecked(draftMode); connect(actionViewDraft, SIGNAL(toggled(bool)), this, SLOT(slotViewDraft(bool))); - connect(this, SIGNAL(draftChanged(bool)), actionViewDraft, SLOT(setOn(bool))); +//??? connect(this, SIGNAL(draftChanged(bool)), actionViewDraft, SLOT(setOn(bool))); connect(this, SIGNAL(windowsChanged(bool)), actionViewDraft, SLOT(setEnabled(bool))); - /* - action = actionFactory.createAction(RS2::ActionViewLayerList, this); - action->addTo(menu); - action->setChecked(true); - action = actionFactory.createAction(RS2::ActionViewBlockList, this); - action->addTo(menu); - action->setChecked(true); - action = actionFactory.createAction(RS2::ActionViewOptionToolbar, this); - action->addTo(menu); - action->setChecked(true); - action = actionFactory.createAction(RS2::ActionViewCommandLine, this); - action->addTo(menu); - action->setChecked(true);*/ - // action = actionFactory.createAction(RS2::ActionZoomRedraw, actionHandler); menu->addAction(actionZoomRedraw); tb->addAction(actionZoomRedraw); @@ -807,35 +777,27 @@ void ApplicationWindow::initActions() #endif menu = new QMenu(tr("&Dimension"), this); -// action = actionFactory.createAction(RS2::ActionDimAligned, actionHandler); menu->addAction(actionDimAligned); connect(actionDimAligned, SIGNAL(activated()), actionHandler, SLOT(slotDimAligned())); connect(this, SIGNAL(windowsChanged(bool)), actionDimAligned, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionDimLinear, actionHandler); menu->addAction(actionDimLinear); connect(actionDimLinear, SIGNAL(activated()), actionHandler, SLOT(slotDimLinear())); connect(this, SIGNAL(windowsChanged(bool)), actionDimLinear, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionDimLinearHor, actionHandler); menu->addAction(actionDimLinearHor); connect(actionDimLinearHor, SIGNAL(activated()), actionHandler, SLOT(slotDimLinearHor())); connect(this, SIGNAL(windowsChanged(bool)), actionDimLinearHor, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionDimLinearVer, actionHandler); menu->addAction(actionDimLinearVer); connect(actionDimLinearVer, SIGNAL(activated()), actionHandler, SLOT(slotDimLinearVer())); connect(this, SIGNAL(windowsChanged(bool)), actionDimLinearVer, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionDimRadial, actionHandler); menu->addAction(actionDimRadial); connect(actionDimRadial, SIGNAL(activated()), actionHandler, SLOT(slotDimRadial())); connect(this, SIGNAL(windowsChanged(bool)), actionDimRadial, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionDimDiametric, actionHandler); menu->addAction(actionDimDiametric); connect(actionDimDiametric, SIGNAL(activated()), actionHandler, SLOT(slotDimDiametric())); connect(this, SIGNAL(windowsChanged(bool)), actionDimDiametric, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionDimAngular, actionHandler); menu->addAction(actionDimAngular); connect(actionDimAngular, SIGNAL(activated()), actionHandler, SLOT(slotDimAngular())); connect(this, SIGNAL(windowsChanged(bool)), actionDimAngular, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionDimLeader, actionHandler); menu->addAction(actionDimLeader); connect(actionDimLeader, SIGNAL(activated()), actionHandler, SLOT(slotDimLeader())); connect(this, SIGNAL(windowsChanged(bool)), actionDimLeader, SLOT(setEnabled(bool))); @@ -848,81 +810,60 @@ void ApplicationWindow::initActions() // Modifying actions: // menu = new QMenu(tr("&Modify"), this); -// action = actionFactory.createAction(RS2::ActionModifyMove, actionHandler); menu->addAction(actionModifyMove); connect(actionModifyMove, SIGNAL(activated()), actionHandler, SLOT(slotModifyMove())); connect(this, SIGNAL(windowsChanged(bool)), actionModifyMove, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionModifyRotate, actionHandler); menu->addAction(actionModifyRotate); connect(actionModifyRotate, SIGNAL(activated()), actionHandler, SLOT(slotModifyRotate())); connect(this, SIGNAL(windowsChanged(bool)), actionModifyRotate, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionModifyScale, actionHandler); menu->addAction(actionModifyScale); connect(actionModifyScale, SIGNAL(activated()), actionHandler, SLOT(slotModifyScale())); connect(this, SIGNAL(windowsChanged(bool)), actionModifyScale, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionModifyMirror, actionHandler); menu->addAction(actionModifyMirror); connect(actionModifyMirror, SIGNAL(activated()), actionHandler, SLOT(slotModifyMirror())); connect(this, SIGNAL(windowsChanged(bool)), actionModifyMirror, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionModifyMoveRotate, actionHandler); menu->addAction(actionModifyMoveRotate); connect(actionModifyMoveRotate, SIGNAL(activated()), actionHandler, SLOT(slotModifyMoveRotate())); connect(this, SIGNAL(windowsChanged(bool)), actionModifyMoveRotate, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionModifyRotate2, actionHandler); menu->addAction(actionModifyRotate2); connect(actionModifyRotate2, SIGNAL(activated()), actionHandler, SLOT(slotModifyRotate2())); connect(this, SIGNAL(windowsChanged(bool)), actionModifyRotate2, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionModifyTrim, actionHandler); menu->addAction(actionModifyTrim); connect(actionModifyTrim, SIGNAL(activated()), actionHandler, SLOT(slotModifyTrim())); connect(this, SIGNAL(windowsChanged(bool)), actionModifyTrim, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionModifyTrim2, actionHandler); menu->addAction(actionModifyTrim2); connect(actionModifyTrim2, SIGNAL(activated()), actionHandler, SLOT(slotModifyTrim2())); connect(this, SIGNAL(windowsChanged(bool)), actionModifyTrim2, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionModifyTrimAmount, actionHandler); menu->addAction(actionModifyTrimAmount); connect(actionModifyTrimAmount, SIGNAL(activated()), actionHandler, SLOT(slotModifyTrimAmount())); connect(this, SIGNAL(windowsChanged(bool)), actionModifyTrimAmount, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionModifyBevel, actionHandler); menu->addAction(actionModifyBevel); connect(actionModifyBevel, SIGNAL(activated()), actionHandler, SLOT(slotModifyBevel())); connect(this, SIGNAL(windowsChanged(bool)), actionModifyBevel, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionModifyRound, actionHandler); menu->addAction(actionModifyRound); connect(actionModifyRound, SIGNAL(activated()), actionHandler, SLOT(slotModifyRound())); connect(this, SIGNAL(windowsChanged(bool)), actionModifyRound, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionModifyCut, actionHandler); menu->addAction(actionModifyCut); connect(actionModifyCut, SIGNAL(activated()), actionHandler, SLOT(slotModifyCut())); connect(this, SIGNAL(windowsChanged(bool)), actionModifyCut, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionModifyStretch, actionHandler); menu->addAction(actionModifyStretch); connect(actionModifyStretch, SIGNAL(activated()), actionHandler, SLOT(slotModifyStretch())); connect(this, SIGNAL(windowsChanged(bool)), actionModifyStretch, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionModifyEntity, actionHandler); menu->addAction(actionModifyEntity); connect(actionModifyEntity, SIGNAL(activated()), actionHandler, SLOT(slotModifyEntity())); connect(this, SIGNAL(windowsChanged(bool)), actionModifyEntity, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionModifyAttributes, actionHandler); menu->addAction(actionModifyAttributes); connect(actionModifyAttributes, SIGNAL(activated()), actionHandler, SLOT(slotModifyAttributes())); connect(this, SIGNAL(windowsChanged(bool)), actionModifyAttributes, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionModifyDelete, actionHandler); menu->addAction(actionModifyDelete); connect(actionModifyDelete, SIGNAL(activated()), actionHandler, SLOT(slotModifyDelete())); connect(this, SIGNAL(windowsChanged(bool)), actionModifyDelete, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionModifyDeleteQuick, actionHandler); menu->addAction(actionModifyDeleteQuick); connect(actionModifyDeleteQuick, SIGNAL(activated()), actionHandler, SLOT(slotModifyDeleteQuick())); connect(this, SIGNAL(windowsChanged(bool)), actionModifyDeleteQuick, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionModifyExplodeText, actionHandler); menu->addAction(actionModifyExplodeText); connect(actionModifyExplodeText, SIGNAL(activated()), actionHandler, SLOT(slotModifyExplodeText())); connect(this, SIGNAL(windowsChanged(bool)), actionModifyExplodeText, SLOT(setEnabled(bool))); -//// action = actionFactory.createAction(RS2::ActionModifyDeleteFree, actionHandler); -//// menu->addAction(action); -// action = actionFactory.createAction(RS2::ActionBlocksExplode, actionHandler); menu->addAction(actionBlocksExplode); connect(actionBlocksExplode, SIGNAL(activated()), actionHandler, SLOT(slotBlocksExplode())); connect(this, SIGNAL(windowsChanged(bool)), actionBlocksExplode, SLOT(setEnabled(bool))); @@ -931,48 +872,39 @@ void ApplicationWindow::initActions() // Snapping actions: // menu = new QMenu(tr("&Snap"), this); -// action = actionFactory.createAction(RS2::ActionSnapFree, actionHandler); menu->addAction(actionSnapFree); actionHandler->setActionSnapFree(actionSnapFree); // ???Why??? connect(actionSnapFree, SIGNAL(activated()), actionHandler, SLOT(slotSnapFree())); connect(this, SIGNAL(windowsChanged(bool)), actionSnapFree, SLOT(setEnabled(bool))); actionSnapFree->setChecked(true); -// action = actionFactory.createAction(RS2::ActionSnapGrid, actionHandler); menu->addAction(actionSnapGrid); actionHandler->setActionSnapGrid(actionSnapGrid); // ???Why??? connect(actionSnapGrid, SIGNAL(activated()), actionHandler, SLOT(slotSnapGrid())); connect(this, SIGNAL(windowsChanged(bool)), actionSnapGrid, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionSnapEndpoint, actionHandler); menu->addAction(actionSnapEndpoint); actionHandler->setActionSnapEndpoint(actionSnapEndpoint); // ???Why??? connect(actionSnapEndpoint, SIGNAL(activated()), actionHandler, SLOT(slotSnapEndpoint())); connect(this, SIGNAL(windowsChanged(bool)), actionSnapEndpoint, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionSnapOnEntity, actionHandler); menu->addAction(actionSnapOnEntity); actionHandler->setActionSnapOnEntity(actionSnapOnEntity); // ???Why??? connect(actionSnapOnEntity, SIGNAL(activated()), actionHandler, SLOT(slotSnapOnEntity())); connect(this, SIGNAL(windowsChanged(bool)), actionSnapOnEntity, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionSnapCenter, actionHandler); menu->addAction(actionSnapCenter); actionHandler->setActionSnapCenter(actionSnapCenter); // ???Why??? connect(actionSnapCenter, SIGNAL(activated()), actionHandler, SLOT(slotSnapCenter())); connect(this, SIGNAL(windowsChanged(bool)), actionSnapCenter, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionSnapMiddle, actionHandler); menu->addAction(actionSnapMiddle); actionHandler->setActionSnapMiddle(actionSnapMiddle); // ???Why??? connect(actionSnapMiddle, SIGNAL(activated()), actionHandler, SLOT(slotSnapMiddle())); connect(this, SIGNAL(windowsChanged(bool)), actionSnapMiddle, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionSnapDist, actionHandler); menu->addAction(actionSnapDist); actionHandler->setActionSnapDist(actionSnapDist); // ???Why??? connect(actionSnapDist, SIGNAL(activated()), actionHandler, SLOT(slotSnapDist())); connect(this, SIGNAL(windowsChanged(bool)), actionSnapDist, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionSnapIntersection, actionHandler); menu->addAction(actionSnapIntersection); actionHandler->setActionSnapIntersection(actionSnapIntersection); // ???Why??? connect(actionSnapIntersection, SIGNAL(activated()), actionHandler, SLOT(slotSnapIntersection())); connect(this, SIGNAL(windowsChanged(bool)), actionSnapIntersection, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionSnapIntersectionManual, actionHandler); menu->addAction(actionSnapIntersectionManual); actionHandler->setActionSnapIntersectionManual(actionSnapIntersectionManual); // ???Why??? connect(actionSnapIntersectionManual, SIGNAL(activated()), actionHandler, SLOT(slotSnapIntersectionManual())); @@ -980,23 +912,19 @@ void ApplicationWindow::initActions() menu->addSeparator(); -// action = actionFactory.createAction(RS2::ActionRestrictNothing, actionHandler); menu->addAction(actionRestrictNothing); actionHandler->setActionRestrictNothing(actionRestrictNothing); // ???WHY??? connect(actionRestrictNothing, SIGNAL(activated()), actionHandler, SLOT(slotRestrictNothing())); connect(this, SIGNAL(windowsChanged(bool)), actionRestrictNothing, SLOT(setEnabled(bool))); actionRestrictNothing->setChecked(true); -// action = actionFactory.createAction(RS2::ActionRestrictOrthogonal, actionHandler); menu->addAction(actionRestrictOrthogonal); actionHandler->setActionRestrictOrthogonal(actionRestrictOrthogonal); // ???WHY??? connect(actionRestrictOrthogonal, SIGNAL(activated()), actionHandler, SLOT(slotRestrictOrthogonal())); connect(this, SIGNAL(windowsChanged(bool)), actionRestrictOrthogonal, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionRestrictHorizontal, actionHandler); menu->addAction(actionRestrictHorizontal); actionHandler->setActionRestrictHorizontal(actionRestrictHorizontal); // ???WHY??? connect(actionRestrictHorizontal, SIGNAL(activated()), actionHandler, SLOT(slotRestrictHorizontal())); connect(this, SIGNAL(windowsChanged(bool)), actionRestrictHorizontal, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionRestrictVertical, actionHandler); menu->addAction(actionRestrictVertical); actionHandler->setActionRestrictVertical(actionRestrictVertical); // ???WHY??? connect(actionRestrictVertical, SIGNAL(activated()), actionHandler, SLOT(slotRestrictVertical())); @@ -1004,11 +932,9 @@ void ApplicationWindow::initActions() menu->addSeparator(); -// action = actionFactory.createAction(RS2::ActionSetRelativeZero, actionHandler); menu->addAction(actionSetRelativeZero); connect(actionSetRelativeZero, SIGNAL(activated()), actionHandler, SLOT(slotSetRelativeZero())); connect(this, SIGNAL(windowsChanged(bool)), actionSetRelativeZero, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionLockRelativeZero, actionHandler); menu->addAction(actionLockRelativeZero); actionHandler->setActionLockRelativeZero(actionLockRelativeZero); connect(actionLockRelativeZero, SIGNAL(toggled(bool)), actionHandler, SLOT(slotLockRelativeZero(bool))); // ???WHY??? @@ -1019,8 +945,6 @@ void ApplicationWindow::initActions() // Info actions: // menu = new QMenu(tr("&Info"), this); - //action = actionFactory.createAction(RS2::ActionInfoInside, actionHandler); - //menu->addAction(action); menu->addAction(actionInfoDist); connect(actionInfoDist, SIGNAL(activated()), actionHandler, SLOT(slotInfoDist())); connect(this, SIGNAL(windowsChanged(bool)), actionInfoDist, SLOT(setEnabled(bool))); @@ -1042,27 +966,21 @@ void ApplicationWindow::initActions() // Layer actions: // menu = new QMenu(tr("&Layer"), this); -// action = actionFactory.createAction(RS2::ActionLayersDefreezeAll, actionHandler); menu->addAction(actionLayersDefreezeAll); connect(actionLayersDefreezeAll, SIGNAL(activated()), actionHandler, SLOT(slotLayersDefreezeAll())); connect(this, SIGNAL(windowsChanged(bool)), actionLayersDefreezeAll, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionLayersFreezeAll, actionHandler); menu->addAction(actionLayersFreezeAll); connect(actionLayersFreezeAll, SIGNAL(activated()), actionHandler, SLOT(slotLayersFreezeAll())); connect(this, SIGNAL(windowsChanged(bool)), actionLayersFreezeAll, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionLayersAdd, actionHandler); menu->addAction(actionLayersAdd); connect(actionLayersAdd, SIGNAL(activated()), actionHandler, SLOT(slotLayersAdd())); connect(this, SIGNAL(windowsChanged(bool)), actionLayersAdd, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionLayersRemove, actionHandler); menu->addAction(actionLayersRemove); connect(actionLayersRemove, SIGNAL(activated()), actionHandler, SLOT(slotLayersRemove())); connect(this, SIGNAL(windowsChanged(bool)), actionLayersRemove, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionLayersEdit, actionHandler); menu->addAction(actionLayersEdit); connect(actionLayersEdit, SIGNAL(activated()), actionHandler, SLOT(slotLayersEdit())); connect(this, SIGNAL(windowsChanged(bool)), actionLayersEdit, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionLayersToggleView, actionHandler); menu->addAction(actionLayersToggleView); connect(actionLayersToggleView, SIGNAL(activated()), actionHandler, SLOT(slotLayersToggleView())); connect(this, SIGNAL(windowsChanged(bool)), actionLayersToggleView, SLOT(setEnabled(bool))); @@ -1071,39 +989,30 @@ void ApplicationWindow::initActions() // Block actions: // menu = new QMenu(tr("&Block"), this); -// action = actionFactory.createAction(RS2::ActionBlocksDefreezeAll, actionHandler); menu->addAction(actionBlocksDefreezeAll); connect(actionBlocksDefreezeAll, SIGNAL(activated()), actionHandler, SLOT(slotBlocksDefreezeAll())); connect(this, SIGNAL(windowsChanged(bool)), actionBlocksDefreezeAll, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionBlocksFreezeAll, actionHandler); menu->addAction(actionBlocksFreezeAll); connect(actionBlocksFreezeAll, SIGNAL(activated()), actionHandler, SLOT(slotBlocksFreezeAll())); connect(this, SIGNAL(windowsChanged(bool)), actionBlocksFreezeAll, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionBlocksAdd, actionHandler); menu->addAction(actionBlocksAdd); connect(actionBlocksAdd, SIGNAL(activated()), actionHandler, SLOT(slotBlocksAdd())); connect(this, SIGNAL(windowsChanged(bool)), actionBlocksAdd, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionBlocksRemove, actionHandler); menu->addAction(actionBlocksRemove); connect(actionBlocksRemove, SIGNAL(activated()), actionHandler, SLOT(slotBlocksRemove())); connect(this, SIGNAL(windowsChanged(bool)), actionBlocksRemove, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionBlocksAttributes, actionHandler); menu->addAction(actionBlocksAttributes); connect(actionBlocksAttributes, SIGNAL(activated()), actionHandler, SLOT(slotBlocksAttributes())); connect(this, SIGNAL(windowsChanged(bool)), actionBlocksAttributes, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionBlocksInsert, actionHandler); menu->addAction(actionBlocksInsert); connect(actionBlocksInsert, SIGNAL(activated()), actionHandler, SLOT(slotBlocksInsert())); connect(this, SIGNAL(windowsChanged(bool)), actionBlocksInsert, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionBlocksEdit, actionHandler); menu->addAction(actionBlocksEdit); connect(actionBlocksEdit, SIGNAL(activated()), actionHandler, SLOT(slotBlocksEdit())); connect(this, SIGNAL(windowsChanged(bool)), actionBlocksEdit, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionBlocksCreate, actionHandler); menu->addAction(actionBlocksCreate); connect(actionBlocksCreate, SIGNAL(activated()), actionHandler, SLOT(slotBlocksCreate())); connect(this, SIGNAL(windowsChanged(bool)), actionBlocksCreate, SLOT(setEnabled(bool))); -// action = actionFactory.createAction(RS2::ActionBlocksExplode, actionHandler); menu->addAction(actionBlocksExplode); connect(actionBlocksExplode, SIGNAL(activated()), actionHandler, SLOT(slotBlocksExplode())); connect(this, SIGNAL(windowsChanged(bool)), actionBlocksExplode, SLOT(setEnabled(bool))); @@ -1157,55 +1066,30 @@ void ApplicationWindow::initActions() connect(helpManual, SIGNAL(activated()), this, SLOT(slotHelpManual())); testDumpEntities = new QAction("Dump &Entities", this); -// testDumpEntities = new QAction("Dump Entities", "Dump &Entities", 0, this); connect(testDumpEntities, SIGNAL(activated()), this, SLOT(slotTestDumpEntities())); - testDumpUndo = new QAction("Undo Info", this); -// testDumpUndo = new QAction("Dump Undo Info", "Undo Info", 0, this); connect(testDumpUndo, SIGNAL(activated()), this, SLOT(slotTestDumpUndo())); - testUpdateInserts = new QAction("&Update Inserts", this); -// testUpdateInserts = new QAction("Update Inserts", "&Update Inserts", 0, this); connect(testUpdateInserts, SIGNAL(activated()), this, SLOT(slotTestUpdateInserts())); - testDrawFreehand = new QAction("Draw Freehand", this); -// testDrawFreehand = new QAction("Draw Freehand", "Draw Freehand", 0, this); connect(testDrawFreehand, SIGNAL(activated()), this, SLOT(slotTestDrawFreehand())); - testInsertBlock = new QAction("Insert Block", this); -// testInsertBlock = new QAction("Insert Block", "Insert Block", 0, this); connect(testInsertBlock, SIGNAL(activated()), this, SLOT(slotTestInsertBlock())); - testInsertText = new QAction("Insert Text", this); -// testInsertText = new QAction("Insert Text", "Insert Text", 0, this); connect(testInsertText, SIGNAL(activated()), this, SLOT(slotTestInsertText())); - testInsertImage = new QAction("Insert Image", this); -// testInsertImage = new QAction("Insert Image", "Insert Image", 0, this); connect(testInsertImage, SIGNAL(activated()), this, SLOT(slotTestInsertImage())); - testUnicode = new QAction("Unicode", this); -// testUnicode = new QAction("Unicode", "Unicode", 0, this); connect(testUnicode, SIGNAL(activated()), this, SLOT(slotTestUnicode())); - testInsertEllipse = new QAction("Insert Ellipse", this); -// testInsertEllipse = new QAction("Insert Ellipse", "Insert Ellipse", 0, this); connect(testInsertEllipse, SIGNAL(activated()), this, SLOT(slotTestInsertEllipse())); - testMath01 = new QAction("Math01", this); -// testMath01 = new QAction("Math01", "Math01", 0, this); connect(testMath01, SIGNAL(activated()), this, SLOT(slotTestMath01())); - testResize640 = new QAction("Resize 1", this); -// testResize640 = new QAction("Resize to 640x480", "Resize 1", 0, this); connect(testResize640, SIGNAL(activated()), this, SLOT(slotTestResize640())); - testResize800 = new QAction("Resize 2", this); -// testResize800 = new QAction("Resize to 800x600", "Resize 2", 0, this); connect(testResize800, SIGNAL(activated()), this, SLOT(slotTestResize800())); - testResize1024 = new QAction("Resize 3", this); -// testResize1024 = new QAction("Resize to 1024x768", "Resize 3", 0, this); connect(testResize1024, SIGNAL(activated()), this, SLOT(slotTestResize1024())); } @@ -1230,43 +1114,35 @@ void ApplicationWindow::initMenuBar() // menuBar entry helpMenu helpMenu = new QMenu(tr("&Help"), this); - helpMenu->addAction(helpManual);//helpManual->addTo(helpMenu); - -// helpMenu->insertSeparator(helpManual); + helpMenu->addAction(helpManual); helpMenu->addSeparator(); - - helpMenu->addAction(helpAboutApp);//helpAboutApp->addTo(helpMenu); + helpMenu->addAction(helpAboutApp); // menuBar entry test menu testMenu = new QMenu(tr("De&bugging"), this); - testMenu->addAction(testDumpEntities);//testDumpEntities->addTo(testMenu); - testMenu->addAction(testDumpUndo);//testDumpUndo->addTo(testMenu); - testMenu->addAction(testUpdateInserts);//testUpdateInserts->addTo(testMenu); - testMenu->addAction(testDrawFreehand);//testDrawFreehand->addTo(testMenu); - testMenu->addAction(testInsertBlock);//testInsertBlock->addTo(testMenu); - testMenu->addAction(testInsertText);//testInsertText->addTo(testMenu); - testMenu->addAction(testInsertImage);//testInsertImage->addTo(testMenu); - testMenu->addAction(testInsertEllipse);//testInsertEllipse->addTo(testMenu); - testMenu->addAction(testUnicode);//testUnicode->addTo(testMenu); - testMenu->addAction(testMath01);//testMath01->addTo(testMenu); - testMenu->addAction(testResize640);//testResize640->addTo(testMenu); - testMenu->addAction(testResize800);//testResize800->addTo(testMenu); - testMenu->addAction(testResize1024);//testResize1024->addTo(testMenu); + testMenu->addAction(testDumpEntities); + testMenu->addAction(testDumpUndo); + testMenu->addAction(testUpdateInserts); + testMenu->addAction(testDrawFreehand); + testMenu->addAction(testInsertBlock); + testMenu->addAction(testInsertText); + testMenu->addAction(testInsertImage); + testMenu->addAction(testInsertEllipse); + testMenu->addAction(testUnicode); + testMenu->addAction(testMath01); + testMenu->addAction(testResize640); + testMenu->addAction(testResize800); + testMenu->addAction(testResize1024); // menuBar configuration #ifdef SCRIPTING -// menuBar()->insertItem(tr("&Scripts"), scriptMenu); menuBar()->addMenu(scriptMenu); #endif -// menuBar()->insertItem(tr("&Window"), windowsMenu); menuBar()->addMenu(windowsMenu); #warning "!!!" -// menuBar()->insertSeparator(); -// menuBar()->insertItem(tr("&Help"), helpMenu); menuBar()->addMenu(helpMenu); if (QC_DEBUGGING) -// menuBar()->insertItem(tr("De&bugging"), testMenu); menuBar()->addMenu(testMenu); recentFiles = new RecentFiles(this, fileMenu); @@ -1279,13 +1155,10 @@ void ApplicationWindow::initToolBar() { DEBUG->print("ApplicationWindow::initToolBar()"); -// fileToolBar = new Q3ToolBar(this, "File Operations"); fileToolBar = addToolBar(tr("File Operations")); fileToolBar->setObjectName("file"); -// editToolBar = new Q3ToolBar(this, "Edit Operations"); editToolBar = addToolBar(tr("Edit Operations")); editToolBar->setObjectName("edit"); -// zoomToolBar = new Q3ToolBar(this, "Zoom Operations"); zoomToolBar = addToolBar(tr("Zoom Operations")); zoomToolBar->setObjectName("zoom"); penToolBar = new PenToolBar(this, "Pen Selection"); @@ -1341,17 +1214,19 @@ void ApplicationWindow::initStatusBar() DEBUG->print("ApplicationWindow::initStatusBar()"); statusBar()->setMinimumHeight(32); - coordinateWidget = new CoordinateWidget(statusBar());//, "coordinates"); + coordinateWidget = new CoordinateWidget(statusBar()); statusBar()->addWidget(coordinateWidget); - mouseWidget = new MouseWidget(statusBar());//, "mouse info"); + mouseWidget = new MouseWidget(statusBar()); statusBar()->addWidget(mouseWidget); - selectionWidget = new SelectionWidget(statusBar());//, "selections"); + selectionWidget = new SelectionWidget(statusBar()); statusBar()->addWidget(selectionWidget); } /** * Initializes the global application settings from the * config file (unix, mac) or registry (windows). + * (Actually, this uses the Qt settings subsystem, so we don't have to worry + * about that crap.) */ void ApplicationWindow::initSettings() { @@ -1363,14 +1238,12 @@ void ApplicationWindow::initSettings() QString filename = settings.value(QString("File") + QString::number(i + 1)).toString(); if (!filename.isEmpty()) -// recentFiles->add(filename); recentFiles->add(filename); } settings.endGroup(); if (recentFiles->count() > 0) -// updateRecentFilesMenu(); recentFiles->UpdateGUI(); settings.beginGroup("Geometry"); @@ -1380,8 +1253,6 @@ void ApplicationWindow::initSettings() settings.endGroup(); #ifdef __APPLE__ -// if (windowY < 30) -// windowY = 30; if (windowSize.y() < 30) windowSize.y() = 30; #endif @@ -1529,30 +1400,6 @@ void ApplicationWindow::initView() DEBUG->print(" done"); } -/** - * Creates a new toolbar. - * Implementation from QG_MainWindowInterface. - * Can be called from scripts to add individual GUI elements. - */ -/*QToolBar* ApplicationWindow::createToolBar(const QString& name) { - QToolBar* tb = new QToolBar(this, name); - tb->setLabel(name); - return tb; -}*/ - -/** - * Creates a new button in the given tool bar for running a script. - */ -/*void ApplicationWindow::addToolBarButton(QToolBar* tb) { - if (tb!=NULL) { - QAction* action = new QAction("Blah", - QPixmap::fromMimeSource("zoomwindow.png"), - "&Blah", QKeySequence(), NULL); - action->setStatusTip("Blah blah"); - action->addTo(tb); - } -}*/ - /** * Goes back to the previous menu or one step in the current action. */ @@ -1606,35 +1453,32 @@ void ApplicationWindow::slotError(const QString & msg) } /** - * Hands focus back to the application window. In the rare event - * of a escape press from the layer widget (e.g after switching desktops - * in XP). + * Hands focus back to the application window. In the rare event of a escape + * press from the layer widget (e.g after switching desktops in XP). */ void ApplicationWindow::slotFocus() { - //QG_GraphicView* graphicView = getGraphicView(); - /*if (graphicView!=NULL) { - graphicView->setFocus(); -} - else {*/ setFocus(); - //} } /** * Called when a document window was activated. */ -void ApplicationWindow::slotWindowActivated(QMdiSubWindow * /*w*/) +//void ApplicationWindow::slotWindowActivated(QMdiSubWindow * /*w*/) +void ApplicationWindow::slotWindowActivated(QMdiSubWindow * sw) { +//This passes in a QMdiSubWindow, so why don't we use it??? +// Now, we do. :-) +//#warning "!!! ApplicationWindow::slotWindowActivated() ignores passed in value !!!" DEBUG->print("ApplicationWindow::slotWindowActivated begin"); //the following does: return (MDIWindow *)workspace->activeSubWindow(); //which means the subwindow is NOT being activated!!! - MDIWindow * m = getMDIWindow(); +// MDIWindow * m = getMDIWindow(); + MDIWindow * m = (MDIWindow *)sw; DEBUG->print(/*Debug::D_CRITICAL,*/ "ApplicationWindow::slotWindowActivated m=%08X", m); - - if (m) - DEBUG->print(/*Debug::D_CRITICAL,*/ "ApplicationWindow::slotWindowActivated m->getDoc=%08X", m->getDocument()); + DEBUG->print(/*Debug::D_CRITICAL,*/ "ApplicationWindow::slotWindowActivated m->getDoc=%08X", + (m ? m->getDocument() : 0)); if (m && m->getDocument()) { @@ -1644,17 +1488,19 @@ void ApplicationWindow::slotWindowActivated(QMdiSubWindow * /*w*/) bool showByBlock = m->getDocument()->rtti() == RS2::EntityBlock; layerWidget->setLayerList(m->getDocument()->getLayerList(), showByBlock); - coordinateWidget->setGraphic(m->getGraphic()); + coordinateWidget->setGraphic(m->GetDrawing()); #ifdef RS_CAM simulationControls->setGraphicView(m->getGraphicView()); #endif // Only graphics show blocks. (blocks don't) - if (m->getDocument()->rtti() == RS2::EntityGraphic) - blockWidget->setBlockList(m->getDocument()->getBlockList()); - else - blockWidget->setBlockList(NULL); +// if (m->getDocument()->rtti() == RS2::EntityDrawing) +// blockWidget->setBlockList(m->getDocument()->getBlockList()); +// else +// blockWidget->setBlockList(NULL); + blockWidget->setBlockList(m->getDocument()->rtti() == RS2::EntityDrawing + ? m->getDocument()->getBlockList() : NULL); // Update all inserts in this graphic (blocks might have changed): m->getDocument()->updateInserts(); @@ -1667,17 +1513,33 @@ void ApplicationWindow::slotWindowActivated(QMdiSubWindow * /*w*/) slotPenChanged(penToolBar->getPen()); // update toggle button status: - if (m->getGraphic()) + if (m->GetDrawing()) { - emit(gridChanged(m->getGraphic()->isGridOn())); - emit(printPreviewChanged(m->getGraphicView()->isPrintPreview())); +//This is odd... why do this when you can just call the function directly? It's +//IN this class after all... +// emit(gridChanged(m->GetDrawing()->isGridOn())); +// emit(printPreviewChanged(m->getGraphicView()->isPrintPreview())); + actionViewGrid->setChecked(m->GetDrawing()->isGridOn()); + actionFilePrintPreview->setChecked(m->getGraphicView()->isPrintPreview()); } } +//This works, but for some reason after this function is over, the subwindow is no +//longer activated. Need to find out why. +//OK, I can see that the workspace isn't getting this window as activated or current. +//Which means that something is definitely wrong here... + //Seems to work now. //#warning "This is failing... !!! FIX !!!" +printf("slotWindowActivated(QMdiSubWindow *): m=%08X, m->getDocument()=%08X...\n", (uint)m, (uint)(m ? m->getDocument() : 0)); +printf("slotWindowActivated(QMdiSubWindow *): activeWindow=%08X...\n", (uint)workspace->activeSubWindow()); +printf("slotWindowActivated(QMdiSubWindow *): currentWindow=%08X...\n", (uint)workspace->currentSubWindow()); +// slotWindowActivated(QMdiSubWindow * /*w*/): m=00000000, m->getDocument()=00000000... + // Disable/Enable menu and toolbar items - emit windowsChanged(m != NULL && m->getDocument() != NULL); +//This is odd... why do this when you can just call the function directly? It's +//IN this class after all... + emit(windowsChanged(m != NULL && m->getDocument() != NULL)); DEBUG->print("ApplicationWindow::slotWindowActivated end"); } @@ -1708,11 +1570,14 @@ void ApplicationWindow::slotWindowsMenuAboutToShow() #warning "!!! Qt4 implementation of insertItem is vastly different from Qt3--FIX !!!" #endif QList windows = workspace->subWindowList(); +//printf("ApplicationWindow::slotWindowsMenuAboutToShow(): workspace->activeSubWindow = %08X\n", workspace->activeSubWindow()); +//printf("ApplicationWindow::slotWindowsMenuAboutToShow(): workspace->currentSubWindow = %08X\n", workspace->currentSubWindow()); //#warning "Need to add window numbers underlined so can access windows via keyboard. !!! FIX !!!" //[DONE] - for(int i=0; i Windows.at(i) = %08X\n", windows.at(i)); // int id = windowsMenu->insertItem(windows.at(i)->caption(), this, SLOT(slotWindowsMenuActivated(int))); //For some reason the triggered() signal created here is type bool... Dunno why... //It's signalling using the QAction signal, which is type bool (checked or not). @@ -1722,7 +1587,9 @@ void ApplicationWindow::slotWindowsMenuAboutToShow() QAction * action = new QAction(actionName, this); action->setCheckable(true); action->setData(i); - action->setChecked(workspace->activeSubWindow() == windows.at(i)); +//Neither of these work... +// action->setChecked(workspace->activeSubWindow() == windows.at(i)); + action->setChecked(workspace->currentSubWindow() == windows.at(i)); windowsMenu->addAction(action); connect(windowsMenu, SIGNAL(triggered(QAction *)), this, SLOT(slotWindowsMenuActivated(QAction *))); // connect(blockWidget, SIGNAL(escape()), this, SLOT(slotFocus())); @@ -1749,10 +1616,13 @@ void ApplicationWindow::slotWindowsMenuActivated(QAction * id) // QMdiSubWindow * w = workspace->subWindowList().at(id); QMdiSubWindow * w = workspace->subWindowList().at(id->data().toInt()); +printf("ApplicationWindow::slotWindowsMenuActivated: QMdiSubWindow * w = %08X\n", (uint32_t)w); if (w != NULL) - w->showMaximized(); + workspace->setActiveSubWindow(w); +// w->showMaximized(); // w->setFocus(); +printf("--> w is%s activated (activeSW=%08X)\n", (workspace->activeSubWindow() ? "" : " NOT"), (uint32_t)(workspace->activeSubWindow())); } /** @@ -1858,8 +1728,8 @@ void ApplicationWindow::slotCamExportAuto() { */ /** - * Called when something changed in the pen tool bar - * (e.g. color, width, style). + * Called when something changed in the pen tool bar (e.g. color, width, + * style). */ void ApplicationWindow::slotPenChanged(Pen pen) { @@ -1874,10 +1744,10 @@ void ApplicationWindow::slotPenChanged(Pen pen) } /** - * Creates a new MDI window with the given document or a new - * document if 'doc' is NULL. + * Creates a new MDI window with the given document or a new document if 'doc' + * is NULL. */ -MDIWindow * ApplicationWindow::slotFileNew(Document * doc) +MDIWindow * ApplicationWindow::slotFileNew(Document * doc/*= NULL*/) { DEBUG->print("ApplicationWindow::slotFileNew() begin"); @@ -1886,7 +1756,7 @@ MDIWindow * ApplicationWindow::slotFileNew(Document * doc) statusBar()->showMessage(tr("Creating new file...")); -#warning "QWidget::setMinimumSize: (/QMdi::ControlLabel) Negative sizes (-1,-1) are not possible" +//#warning "QWidget::setMinimumSize: (/QMdi::ControlLabel) Negative sizes (-1,-1) are not possible" DEBUG->print(" creating MDI window"); // MDIWindow * w = new MDIWindow(doc, workspace, 0, Qt::WA_DeleteOnClose); MDIWindow * w = new MDIWindow(doc, workspace, 0, Qt::SubWindow); @@ -1895,21 +1765,17 @@ MDIWindow * ApplicationWindow::slotFileNew(Document * doc) connect(w, SIGNAL(signalClosing()), this, SLOT(slotFileClosing())); if (w->getDocument()->rtti() == RS2::EntityBlock) -// w->setCaption(tr("Block '%1'").arg(((Block *)(w->getDocument()))->getName())); w->setWindowTitle(tr("Block '%1'").arg(((Block *)(w->getDocument()))->getName())); else -// w->setCaption(tr("unnamed document %1").arg(id)); - w->setWindowTitle(tr("unnamed document %1").arg(id)); + w->setWindowTitle(tr("Untitled Document %1").arg(id)); -// w->setIcon(qPixmapFromMimeSource("document.png")); -// w->setWindowIcon(qPixmapFromMimeSource("document.png")); w->setWindowIcon(QIcon(":/res/document.png")); +#if 0 // only graphics offer block lists, blocks don't DEBUG->print(" adding listeners"); Drawing * graphic = w->getDocument()->getGraphic(); -#if 0 if (graphic != NULL) { // Link the graphic's layer list to the pen tool bar @@ -1938,7 +1804,8 @@ MDIWindow * ApplicationWindow::slotFileNew(Document * doc) #if 1 //bugfix for Qt3->4 conversion DEBUG->print(/*Debug::D_CRITICAL,*/ "ApplicationWindow::slotFileNew: adding window to workspace..."); // workspace->addWindow(w); - workspace->addSubWindow(w); + QMdiSubWindow * sw = workspace->addSubWindow(w); +printf("MDIWindow=%08X, QMdiSubWindow=%08X\n", (uint)w, (uint)sw); #endif DEBUG->print(" showing MDI window"); @@ -1958,13 +1825,20 @@ MDIWindow * ApplicationWindow::slotFileNew(Document * doc) // w->setFocus(); //printf("--> ApplicationWindow::slotFileNew(): w %s focus...\n", (w->hasFocus() ? "has" : "DOES NOT HAVE")); #endif - -#warning "!!! Parameter to slotWindowActivated() is ignored !!!" - slotWindowActivated(w); +//neither of these work either +//w->activateWindow(); +//w->setFocus(); +//w->activateWindow(); +//w->raise(); + +//not anymore... #warning "!!! Parameter to slotWindowActivated() is ignored !!!" +//Hm, this should be called when the window is actually activated by the QMdiArea... +//Not sure why this isn't happening... +// slotWindowActivated(w); statusBar()->showMessage(tr("New Drawing created."), 2000); DEBUG->print("ApplicationWindow::slotFileNew() OK"); - setFocus(); +// setFocus(); return w; } @@ -2037,7 +1911,7 @@ void ApplicationWindow::slotFileOpen(const QString & fileName, RS2::FormatType t // link the block widget to the new document: blockWidget->setBlockList(w->getDocument()->getBlockList()); // link coordinate widget to graphic - coordinateWidget->setGraphic(w->getGraphic()); + coordinateWidget->setGraphic(w->GetDrawing()); #ifdef RS_CAM // link the layer widget to the new document: simulationControls->setGraphicView(w->getGraphicView()); @@ -2051,7 +1925,7 @@ void ApplicationWindow::slotFileOpen(const QString & fileName, RS2::FormatType t QApplication::restoreOverrideCursor(); QMessageBox::information(this, QMessageBox::tr("Warning"), tr("Cannot open the file\n%1\nPlease check the permissions.") .arg(fileName), QMessageBox::Ok); - w->setForceClosing(true); +// w->setForceClosing(true); w->close(); return; } @@ -2283,7 +2157,7 @@ void ApplicationWindow::slotFileExport() // show options dialog: ImageOptionsDialog dlg(this); - dlg.setGraphicSize(w->getGraphic()->getSize()); + dlg.setGraphicSize(w->GetDrawing()->getSize()); if (dlg.exec()) { @@ -2319,11 +2193,11 @@ bool ApplicationWindow::slotFileExport(const QString & name, const QString & for return false; } - Drawing * graphic = w->getDocument()->getGraphic(); + Drawing * drawing = w->getDocument()->GetDrawing(); - if (!graphic) + if (!drawing) { - DEBUG->print(Debug::D_WARNING, "ApplicationWindow::slotFileExport: no graphic"); + DEBUG->print(Debug::D_WARNING, "ApplicationWindow::slotFileExport: no drawing"); return false; } @@ -2361,9 +2235,9 @@ bool ApplicationWindow::slotFileExport(const QString & name, const QString & for else gv.setBackground(Color(255, 255, 255)); - gv.setContainer(graphic); + gv.setContainer(drawing); gv.zoomAuto(false); - gv.drawEntity(graphic, true); + gv.drawEntity(drawing, true); #if 0 QImageIO iio; @@ -2378,14 +2252,19 @@ bool ApplicationWindow::slotFileExport(const QString & name, const QString & for ret = true; } #else -#warning "ApplicationWindow::slotFileExport(): Need to port to Qt4... !!! FIX !!!" +// QImage image = buffer->toImage(); +// QImageWriter writer; +// writer.setFileName(name); +// writer.setFormat(format.toAscii().data()); + QImageWriter writer(name, format.toAscii().data()); + +// if (writer.write(image)) + if (writer.write(buffer->toImage())) + ret = true; #endif QApplication::restoreOverrideCursor(); - // GraphicView deletes painter -// painter->end(); - //no, it doesn't delete painter; delete buffer; @@ -2451,18 +2330,18 @@ void ApplicationWindow::slotFilePrint() return; } - Drawing * graphic = w->getDocument()->getGraphic(); + Drawing * drawing = w->getDocument()->GetDrawing(); - if (graphic == NULL) + if (drawing == NULL) { - DEBUG->print(Debug::D_WARNING, "ApplicationWindow::slotFilePrint: no graphic"); + DEBUG->print(Debug::D_WARNING, "ApplicationWindow::slotFilePrint: no drawing"); return; } statusBar()->showMessage(tr("Printing...")); QPrinter * printer = new QPrinter(QPrinter::HighResolution); bool landscape = false; - printer->setPageSize(RS2::rsToQtPaperFormat(graphic->getPaperFormat(&landscape))); + printer->setPageSize(RS2::rsToQtPaperFormat(drawing->getPaperFormat(&landscape))); if (landscape) printer->setOrientation(QPrinter::Landscape); @@ -2502,20 +2381,17 @@ void ApplicationWindow::slotFilePrint() // double fx = (double)metr.width() / metr.widthMM() * Units::getFactorToMM(graphic->getUnit()); // double fy = (double)metr.height() / metr.heightMM() * Units::getFactorToMM(graphic->getUnit()); - double fx = (double)printer->width() / printer->widthMM() * Units::getFactorToMM(graphic->getUnit()); - double fy = (double)printer->height() / printer->heightMM() * Units::getFactorToMM(graphic->getUnit()); + double fx = (double)printer->width() / printer->widthMM() * Units::getFactorToMM(drawing->getUnit()); + double fy = (double)printer->height() / printer->heightMM() * Units::getFactorToMM(drawing->getUnit()); double f = (fx + fy) / 2; - double scale = graphic->getPaperScale(); + double scale = drawing->getPaperScale(); - gv.setOffset((int)(graphic->getPaperInsertionBase().x * f), - (int)(graphic->getPaperInsertionBase().y * f)); + gv.setOffset((int)(drawing->getPaperInsertionBase().x * f), + (int)(drawing->getPaperInsertionBase().y * f)); gv.setFactor(f * scale); - gv.setContainer(graphic); - gv.drawEntity(graphic, true); + gv.setContainer(drawing); + gv.drawEntity(drawing, true); - // GraphicView deletes painter -// painter->end(); - //no delete painter; settings.beginGroup("Print"); @@ -2548,7 +2424,7 @@ void ApplicationWindow::slotFilePrintPreview(bool on) return; } - // close print preview: + // Close print preview: if (!on) { DEBUG->print("ApplicationWindow::slotFilePrintPreview(): off"); @@ -2559,7 +2435,7 @@ void ApplicationWindow::slotFilePrintPreview(bool on) slotFileClose(); } } - // open print preview: + // Open print preview: else { // look for an existing print preview: @@ -2580,8 +2456,6 @@ void ApplicationWindow::slotFilePrintPreview(bool on) MDIWindow * w = new MDIWindow(parent->getDocument(), workspace, 0, Qt::SubWindow); w->setAttribute(Qt::WA_DeleteOnClose); parent->addChildWindow(w); - //connect(w, SIGNAL(signalClosing()), - // this, SLOT(slotFileClosing())); // w->setCaption(tr("Print preview for %1").arg(parent->caption())); w->setWindowTitle(tr("Print preview for %1").arg(parent->windowTitle())); @@ -2592,22 +2466,14 @@ void ApplicationWindow::slotFilePrintPreview(bool on) w->getGraphicView()->setBackground(Color(255, 255, 255)); w->getGraphicView()->setDefaultAction(new ActionPrintPreview(*w->getDocument(), *w->getGraphicView())); - // only graphics offer block lists, blocks don't - DEBUG->print(" adding listeners"); - Drawing * graphic = w->getDocument()->getGraphic(); + // Only drawings offer block lists; blocks themselves don't +// DEBUG->print(" adding listeners"); + Drawing * drawing = w->getDocument()->GetDrawing(); - if (graphic) + if (drawing) { -#if 0 - // Link the layer list to the pen tool bar - graphic->addLayerListListener(penToolBar); - // Link the layer list to the layer widget - graphic->addLayerListListener(layerWidget); - // Link the block list to the block widget - graphic->addBlockListListener(blockWidget); -#endif // Center by default: - graphic->centerToPage(); + drawing->centerToPage(); } // Link the graphic view to the mouse widget: @@ -2647,25 +2513,12 @@ void ApplicationWindow::slotFileQuit() statusBar()->showMessage(tr("Exiting application...")); - if (queryExit(false)) + if (QueryExit()) qApp->exit(0); } -#if 0 -/** - * Forces termination of QCad (demo version). - */ -void ApplicationWindow::slotFileDemoQuit() -{ - statusBar()->showMessage(tr("Exiting application...")); - - queryExit(true); - qApp->exit(0); -} -#endif - /** - * Shows / hides the grid. + * Shows/hides the grid. * * @param toggle true: show, false: hide. */ @@ -2677,10 +2530,10 @@ void ApplicationWindow::slotViewGrid(bool toggle) if (m != NULL) { - Drawing * g = m->getGraphic(); + Drawing * d = m->GetDrawing(); - if (g != NULL) - g->setGridOn(toggle); + if (d != NULL) + d->setGridOn(toggle); } updateGrids(); @@ -2690,7 +2543,7 @@ void ApplicationWindow::slotViewGrid(bool toggle) } /** - * Enables / disables the draft mode. + * Enables/disables draft mode. * * @param toggle true: enable, false: disable. */ @@ -2698,14 +2551,6 @@ void ApplicationWindow::slotViewDraft(bool toggle) { DEBUG->print("ApplicationWindow::slotViewDraft()"); - /*MDIWindow* m = getMDIWindow(); - if (m!=NULL) { - Drawing* g = m->getGraphic(); - if (g!=NULL) { - g->setDraftOn(toggle); - } -}*/ - settings.beginGroup("Appearance"); settings.setValue("DraftMode", toggle); settings.endGroup(); @@ -2714,26 +2559,21 @@ void ApplicationWindow::slotViewDraft(bool toggle) } /** - * Redraws all mdi windows. + * Redraws all MDI windows. */ void ApplicationWindow::redrawAll() { - if (workspace) - { - QList windows = workspace->subWindowList(); + if (workspace == NULL) + return; - for(int i=0; i windows = workspace->subWindowList(); - if (m) - { - QG_GraphicView * gv = m->getGraphicView(); + for(int i=0; igetGraphicView(); - if (gv) - gv->redraw(); - } - } + if (gv) + gv->redraw(); } } @@ -2742,22 +2582,17 @@ void ApplicationWindow::redrawAll() */ void ApplicationWindow::updateGrids() { - if (workspace) - { - QList windows = workspace->subWindowList(); + if (workspace == NULL) + return; - for(int i=0; i windows = workspace->subWindowList(); - if (m) - { - QG_GraphicView * gv = m->getGraphicView(); + for(int i=0; igetGraphicView(); - if (gv) - gv->updateGrid(); - } - } + if (gv) + gv->updateGrid(); } } @@ -2776,102 +2611,6 @@ void ApplicationWindow::slotViewStatusBar(bool showSB) statusBar()->hide(); } -/** - * Shows / hides the layer list. - * - * @param toggle true: show, false: hide. - */ -/*void ApplicationWindow::slotViewLayerList(bool toggle) { - DEBUG->print("ApplicationWindow::slotViewLayerList()"); - - if (toggle==false) { - layerDockWindow->hide(); - } else { - layerDockWindow->show(); - } -} -*/ - -/** - * Shows / hides the block list. - * - * @param toggle true: show, false: hide. - */ -/* -void ApplicationWindow::slotViewBlockList(bool toggle) { - DEBUG->print("ApplicationWindow::slotViewBlockList()"); - - if (toggle==false) { - blockDockWindow->hide(); - } else { - blockDockWindow->show(); - } -} -*/ - -/** - * Shows / hides the command line. - * - * @param toggle true: show, false: hide. - */ -/* -void ApplicationWindow::slotViewCommandLine(bool toggle) { - DEBUG->print("ApplicationWindow::slotViewCommandLine()"); - - if (toggle==false) { - commandDockWindow->hide(); - //QG_GraphicView* graphicView = getGraphicView(); - //if (graphicView!=NULL) { - //graphicView->setFocus(); - //} - setFocus(); - } else { - commandDockWindow->show(); - } -} -*/ - -/** - * Shows / hides the option toolbar. - * - * @param toggle true: show, false: hide. - */ -/* -void ApplicationWindow::slotViewOptionToolbar(bool toggle) { - DEBUG->print("ApplicationWindow::slotViewOptionToolbar()"); - - if (toggle==false) { - optionWidget->hide(); - } else { - optionWidget->show(); - } -} -*/ - -/** - * Creates a new MDI window for editing the selected block. - */ -/* -void ApplicationWindow::slotBlocksEdit() { - DEBUG->print("ApplicationWindow::slotBlocksEdit()"); - - MDIWindow* parent = getMDIWindow(); - if (parent!=NULL) { - BlockList* blist = blockWidget->getBlockList(); - if (blist!=NULL) { - Block* blk = blist->getActiveBlock(); - if (blk!=NULL) { - MDIWindow* w = slotFileNew(blk); - // the parent needs a pointer to the block window and - // vice versa - parent->addChildWindow(w); - w->getGraphicView()->zoomAuto(); - } - } - } -} -*/ - /** * Shows the dialog for general application preferences. */ @@ -2879,7 +2618,7 @@ void ApplicationWindow::slotOptionsGeneral() { DIALOGFACTORY->requestOptionsGeneralDialog(); - // update background color of all open drawings: + // Update background color of all open drawings: settings.beginGroup("Appearance"); QColor color(settings.value("BackgroundColor", "#000000").toString()); QColor gridColor(settings.value("GridColor", "Gray").toString()); @@ -2890,7 +2629,7 @@ void ApplicationWindow::slotOptionsGeneral() QList windows = workspace->subWindowList(); - for(int i=0; iprint("ApplicationWindow::slotHelpAbout()"); +#if 0 QStringList modules; #ifdef RS_CAM @@ -2954,26 +2694,16 @@ void ApplicationWindow::slotHelpAbout() modulesString = modules.join(", "); else modulesString = tr("None"); +#endif QMessageBox box(this); box.setWindowTitle(tr("About...")); - box.setText(QString("") + // no center for main stream QCad -#ifdef QC_ABOUT_HEADER - QString("
") + - QString(QC_ABOUT_HEADER) + -#else -//FAIL "

"+ QC_APPNAME+ "

" + - "

Architektonas

" + -#endif - tr("Version: %1").arg("1.0.0") + "
" + - tr("Date: %1").arg(__DATE__) + "
" + - QString("© 2010 Underground Software,
James Hammons") + - "
" + - QString("Portions © 2001-2003 RibbonSoft") + - "
" -#ifdef QC_ABOUT_ADD_COMPANY - + QString("
") + QC_ABOUT_ADD_COMPANY -#endif + box.setText(QString("
") + + "

Architektonas

" + + tr("Version: %1").arg("1.0.0") + "
" + + tr("Date: %1").arg(__DATE__) + "
" + + QString("© 2010 Underground Software,
James Hammons") + "
" + + QString("Portions © 2001-2003 RibbonSoft") + "
" + QString("
") ); #ifndef QC_ABOUT_HEADER @@ -3395,7 +3125,7 @@ void ApplicationWindow::slotTestInsertBlock() Document * d = getDocument(); - if (d != NULL && d->rtti() == RS2::EntityGraphic) + if (d != NULL && d->rtti() == RS2::EntityDrawing) { Drawing * graphic = (Drawing *)d; @@ -3741,23 +3471,23 @@ void ApplicationWindow::slotTestInsertImage() Document * d = getDocument(); - if (d != NULL) - { - Drawing * graphic = (Drawing *)d; + if (d == NULL) + return; - if (graphic == NULL) - return; + Drawing * drawing = (Drawing *)d; - Image * image; - ImageData imageData; + if (drawing == NULL) + return; - imageData = ImageData(0, Vector(50.0, 30.0), Vector(0.5, 0.5), Vector(-0.5, 0.5), Vector(640, 480), "/home/andrew/data/image.png", 50, 50, 0); - image = new Image(graphic, imageData); + Image * image; + ImageData imageData; - image->setLayerToActive(); - image->setPen(Pen(Color(255, 0, 0), RS2::Width01, RS2::SolidLine)); - graphic->addEntity(image); - } + imageData = ImageData(0, Vector(50.0, 30.0), Vector(0.5, 0.5), Vector(-0.5, 0.5), Vector(640, 480), "/home/andrew/data/image.png", 50, 50, 0); + image = new Image(drawing, imageData); + + image->setLayerToActive(); + image->setPen(Pen(Color(255, 0, 0), RS2::Width01, RS2::SolidLine)); + drawing->addEntity(image); } /** @@ -3914,49 +3644,27 @@ void ApplicationWindow::slotTestResize1024() /** * overloaded for Message box on last window exit. */ -bool ApplicationWindow::queryExit(bool force) +bool ApplicationWindow::QueryExit(void) { DEBUG->print("ApplicationWindow::queryExit()"); - bool succ = true; - - // demo: - if (force) - { - QMessageBox::information(this, QMessageBox::tr("Warning"), - tr("This is a %1 version " - "which terminates\n" - "automatically after 10min. This software is\n" - "not intended for production use. Please buy\n" - "a full version of the application from\n%2.\n" - "You can save your work now.") -//FAIL .arg(QC_APPNAME) - .arg("Architektonas") -#ifdef QC_CUSTOM_VENDOR - .arg(QC_CUSTOM_VENDOR), -#else - .arg("RibbonSoft, http://www.ribbonsoft.com"), -#endif - QMessageBox::Ok); - } - + bool success = true; QList list = workspace->subWindowList(); -// for(QWidget * w=list.first(); w!=NULL; w=list.next()) for(int i=0; icloseMDI(force); + success = ((MDIWindow *)list[i])->CloseMDI(); - if (!succ) + if (!success) break; } - if (succ) + if (success) storeSettings(); DEBUG->print("ApplicationWindow::queryExit(): OK"); - return succ; + return success; } /** @@ -3986,7 +3694,7 @@ void ApplicationWindow::keyPressEvent(QKeyEvent * e) GraphicView * graphicView = getGraphicView(); if (graphicView) - graphicView->keyPressEvent(e); + graphicView->_keyPressEvent(e); e->accept(); } @@ -4076,13 +3784,15 @@ void ApplicationWindow::keyReleaseEvent(QKeyEvent * e) GraphicView * graphicView = getGraphicView(); if (graphicView) - graphicView->keyReleaseEvent(e); + graphicView->_keyReleaseEvent(e); e->accept(); } break; } +// THIS LOOKS LIKE A BUG TO ME... +#warning "!!! keyPressEvent called in keyReleaseEvent !!!" // Q3MainWindow::keyPressEvent(e); QMainWindow::keyPressEvent(e); } @@ -4104,15 +3814,18 @@ QMdiArea * ApplicationWindow::getWorkspace() } /** - * @return Pointer to the currently active MDI Window or NULL if no - * MDI Window is active. + * @return Pointer to the currently active MDI Window or NULL if no MDI Window + * is active. */ MDIWindow * ApplicationWindow::getMDIWindow() { DEBUG->print(/*Debug::D_CRITICAL,*/ "ApplicationWindow::getMDIWindow: workspace=%08X", workspace); +// Here is the problem: Window isn't active... if (workspace) { +printf("ApplicationWindow::getMDIWindow: activeSubWindow =%08X\n", (uint)workspace->activeSubWindow()); +printf("ApplicationWindow::getMDIWindow: currentSubWindow=%08X\n", (uint)workspace->currentSubWindow()); DEBUG->print("ApplicationWindow::getMDIWindow: activeSubWindow=%08X", workspace->activeSubWindow()); return (MDIWindow *)workspace->activeSubWindow(); } @@ -4159,6 +3872,7 @@ MDIWindow * ApplicationWindow::getMDIWindow() getDocument()->setFilename(fileName); } +#if 0 /** * Implementation from QG_MainWindowInterface. * @@ -4176,6 +3890,7 @@ MDIWindow * ApplicationWindow::getMDIWindow() { return actionHandler; } +#endif /** * Implementation from QG_MainWindowInterface. diff --git a/src/mainapp/applicationwindow.h b/src/mainapp/applicationwindow.h index 6423c28..2ae4329 100644 --- a/src/mainapp/applicationwindow.h +++ b/src/mainapp/applicationwindow.h @@ -48,10 +48,10 @@ class ApplicationWindow: public QMainWindow, public QG_MainWindowInterface void storeSettings(); void initMDI(); void initView(); - bool queryExit(bool force); + bool QueryExit(void); /** Catch hotkey for giving focus to command line. */ - virtual void keyPressEvent(QKeyEvent* e); + virtual void keyPressEvent(QKeyEvent * e); virtual void keyReleaseEvent(QKeyEvent * e); public slots: @@ -59,7 +59,6 @@ class ApplicationWindow: public QMainWindow, public QG_MainWindowInterface void finishSplashScreen(); void slotFocus(); void slotBack(); - //void slotNext(); void slotEnter(); void slotFocusCommandLine(); void slotError(const QString & msg); @@ -76,14 +75,9 @@ class ApplicationWindow: public QMainWindow, public QG_MainWindowInterface MDIWindow * slotFileNew(Document * doc = NULL); /** opens a document */ void slotFileOpen(); - /** - * opens a recent file document - * @param id File Menu id of the file - */ + /** opens a recent file document */ void slotFileOpenRecent(void); - /** - * opens the given file. - */ + /** opens the given file. */ void slotFileOpen(const QString & fileName, RS2::FormatType type); /** saves a document */ void slotFileSave(); @@ -104,27 +98,13 @@ class ApplicationWindow: public QMainWindow, public QG_MainWindowInterface /** exits the application */ void slotFileQuit(); -#if 0 - /** forces to quit QCad (demo) */ - void slotFileDemoQuit(); -#endif - /** toggle the grid */ void slotViewGrid(bool toggle); /** toggle the draft mode */ void slotViewDraft(bool toggle); /** toggle the statusbar */ void slotViewStatusBar(bool toggle); - /** toggle the layerlist */ - //void slotViewLayerList(bool toggle); - /** toggle the blocklist */ - //void slotViewBlockList(bool toggle); - /** toggle the command line */ - //void slotViewCommandLine(bool toggle); - /** toggle the option toolbar */ - //void slotViewOptionToolbar(bool toggle); - - //void slotBlocksEdit(); + void slotOptionsGeneral(); void slotScriptOpenIDE(); @@ -137,7 +117,7 @@ class ApplicationWindow: public QMainWindow, public QG_MainWindowInterface void slotInsertBlock(); void slotInsertBlock(const QString & name); - /** shows an about dlg*/ + /** shows an about dlg */ void slotHelpAbout(); void slotHelpManual(); @@ -169,36 +149,32 @@ class ApplicationWindow: public QMainWindow, public QG_MainWindowInterface void slotTestResize1024(); signals: - void gridChanged(bool on); - void draftChanged(bool on); - void printPreviewChanged(bool on); - void windowsChanged(bool windowsLeft); +// void gridChanged(bool on); +// void draftChanged(bool on); +// void printPreviewChanged(bool on); + void windowsChanged(bool); public: static ApplicationWindow * getAppWindow(); QMdiArea * getWorkspace(); MDIWindow * getMDIWindow(); - virtual GraphicView * getGraphicView(); - virtual Document * getDocument(); - virtual void createNewDocument(const QString & fileName = QString::null, Document * doc = NULL); - virtual QMainWindow * GetMainWindow(); - virtual ActionHandler * getActionHandler(); - virtual void showSimulationControls(); - /** - * @return Pointer to the qsa object. - */ #ifdef SCRIPTING + /** + * @return Pointer to the qsa object. + */ QSProject * getQSAProject(); #endif void redrawAll(); void updateGrids(); - /** - * Implementation from QG_MainWindowInterface. - */ + /** Implementation from QG_MainWindowInterface. */ virtual void setFocus2(); + virtual GraphicView * getGraphicView(); + virtual Document * getDocument(); + virtual void createNewDocument(const QString & fileName = QString::null, Document * doc = NULL); + virtual void showSimulationControls(); protected: void closeEvent(QCloseEvent *); @@ -277,8 +253,6 @@ class ApplicationWindow: public QMainWindow, public QG_MainWindowInterface // Toolbar for CAD tools CadToolBar * cadToolBar; -//No. QAssistantClient * assistant; - QAction * scriptOpenIDE; QAction * scriptRun; diff --git a/src/mainapp/commands.cpp b/src/mainapp/commands.cpp index 083d45f..f8e74b8 100644 --- a/src/mainapp/commands.cpp +++ b/src/mainapp/commands.cpp @@ -20,7 +20,7 @@ #include "debug.h" // Class variable -Commands * Commands::uniqueInstance = NULL; +/*static*/ Commands * Commands::uniqueInstance = NULL; /** * Constructor. Initiates main command dictionary. diff --git a/src/mainapp/commands.h b/src/mainapp/commands.h index 05d84c9..2b261e7 100644 --- a/src/mainapp/commands.h +++ b/src/mainapp/commands.h @@ -7,10 +7,9 @@ #define COMMANDS Commands::instance() /** - * Class which holds all commands for the command line. This - * is separated in this module to alow the use of different - * languages for the gui and the command interface. - * Implemented as singleton. + * Class which holds all commands for the command line. This is separated in + * this module to alow the use of different languages for the GUI and the + * command interface. Implemented as singleton. * * @author Andrew Mustun */ @@ -35,8 +34,6 @@ class Commands: public QObject private: Commands(); ~Commands(); -// Q3Dict mainCommands; -// Q3Dict shortCommands; QMultiHash mainCommands; QMultiHash shortCommands; }; diff --git a/src/mainapp/graphicview.cpp b/src/mainapp/graphicview.cpp index d29de4a..8fe4e84 100644 --- a/src/mainapp/graphicview.cpp +++ b/src/mainapp/graphicview.cpp @@ -113,9 +113,9 @@ void GraphicView::cleanUp() * connected to this view is a graphic and valid. * NULL otherwise. */ -Drawing * GraphicView::getGraphic() +Drawing * GraphicView::GetDrawing() { - if (container && container->rtti() == RS2::EntityGraphic) + if (container && container->rtti() == RS2::EntityDrawing) return (Drawing *)container; return NULL; @@ -376,7 +376,7 @@ bool GraphicView::isGridOn() { if (container) { - Drawing * d = container->getGraphic(); + Drawing * d = container->GetDrawing(); if (d) return d->isGridOn(); @@ -530,7 +530,7 @@ void GraphicView::enter() * Called by the actual GUI class which implements the GraphicView * interface to notify qcadlib about mouse events. */ -void GraphicView::mousePressEvent(QMouseEvent * e) +void GraphicView::_mousePressEvent(QMouseEvent * e) { if (eventHandler) eventHandler->MousePressEvent(e); @@ -540,7 +540,7 @@ void GraphicView::mousePressEvent(QMouseEvent * e) * Called by the actual GUI class which implements the GraphicView * interface to notify qcadlib about mouse events. */ -void GraphicView::mouseReleaseEvent(QMouseEvent * e) +void GraphicView::_mouseReleaseEvent(QMouseEvent * e) { DEBUG->print("GraphicView::mouseReleaseEvent"); @@ -564,13 +564,13 @@ void GraphicView::mouseReleaseEvent(QMouseEvent * e) * Called by the actual GUI class which implements the GraphicView * interface to notify qcadlib about mouse events. */ -void GraphicView::mouseMoveEvent(QMouseEvent * e) +void GraphicView::_mouseMoveEvent(QMouseEvent * e) { DEBUG->print("GraphicView::mouseMoveEvent begin"); Drawing * drawing = NULL; - if (container->rtti() == RS2::EntityGraphic) + if (container->rtti() == RS2::EntityDrawing) drawing = (Drawing *)container; DEBUG->print("GraphicView::mouseMoveEvent 001"); @@ -605,7 +605,7 @@ void GraphicView::mouseMoveEvent(QMouseEvent * e) * Called by the actual GUI class which implements the GraphicView * interface to notify qcadlib about mouse events. */ -void GraphicView::mouseLeaveEvent() +void GraphicView::_mouseLeaveEvent() { if (eventHandler) eventHandler->MouseLeaveEvent(); @@ -615,7 +615,7 @@ void GraphicView::mouseLeaveEvent() * Called by the actual GUI class which implements the GraphicView * interface to notify qcadlib about mouse events. */ -void GraphicView::mouseEnterEvent() +void GraphicView::_mouseEnterEvent() { if (eventHandler) eventHandler->MouseEnterEvent(); @@ -625,7 +625,7 @@ void GraphicView::mouseEnterEvent() * Called by the actual GUI class which implements the GraphicView * interface to notify qcadlib about key events. */ -void GraphicView::keyPressEvent(QKeyEvent * e) +void GraphicView::_keyPressEvent(QKeyEvent * e) { if (eventHandler) eventHandler->KeyPressEvent(e); @@ -635,7 +635,7 @@ void GraphicView::keyPressEvent(QKeyEvent * e) * Called by the actual GUI class which implements the GraphicView * interface to notify qcadlib about key events. */ -void GraphicView::keyReleaseEvent(QKeyEvent * e) +void GraphicView::_keyReleaseEvent(QKeyEvent * e) { if (eventHandler) eventHandler->KeyReleaseEvent(e); @@ -1126,13 +1126,13 @@ void GraphicView::zoomPage() if (simulationRunning) return; - Drawing * graphic = container->getGraphic(); + Drawing * drawing = container->GetDrawing(); - if (graphic == NULL) + if (drawing == NULL) return; - Vector s = graphic->getPaperSize(); - Vector pinsbase = graphic->getPaperInsertionBase(); + Vector s = drawing->getPaperSize(); + Vector pinsbase = drawing->getPaperInsertionBase(); double fx, fy; @@ -1272,14 +1272,14 @@ void GraphicView::setPenForEntity(Entity * e) { double uf = 1.0; // unit factor double wf = 1.0; // width factor - Drawing * graphic = container->getGraphic(); + Drawing * drawing = container->GetDrawing(); - if (graphic) + if (drawing) { - uf = Units::convert(1.0, RS2::Millimeter, graphic->getUnit()); + uf = Units::convert(1.0, RS2::Millimeter, drawing->getUnit()); - if ((isPrinting() || isPrintPreview()) && graphic->getPaperScale() > 1.0e-6) - wf = 1.0 / graphic->getPaperScale(); + if ((isPrinting() || isPrintPreview()) && drawing->getPaperScale() > 1.0e-6) + wf = 1.0 / drawing->getPaperScale(); } pen.setScreenWidth(toGuiDX(w / 100.0 * uf * wf)); @@ -1957,12 +1957,12 @@ void GraphicView::drawPaper() if (!container) return; - Drawing * graphic = container->getGraphic(); + Drawing * drawing = container->GetDrawing(); - if (!graphic) + if (!drawing) return; - if (graphic->getPaperScale() < 1.0e-6) + if (drawing->getPaperScale() < 1.0e-6) return; if (!painter) @@ -1971,9 +1971,9 @@ void GraphicView::drawPaper() // draw paper: painter->setPen(Pen(Qt::gray)); - Vector pinsbase = graphic->getPaperInsertionBase(); - Vector size = graphic->getPaperSize(); - double scale = graphic->getPaperScale(); + Vector pinsbase = drawing->getPaperInsertionBase(); + Vector size = drawing->getPaperSize(); + double scale = drawing->getPaperScale(); Vector v1 = toGui((Vector(0, 0) - pinsbase) / scale); Vector v2 = toGui((size - pinsbase) / scale); diff --git a/src/mainapp/graphicview.h b/src/mainapp/graphicview.h index 65e1a3d..e59d4ae 100644 --- a/src/mainapp/graphicview.h +++ b/src/mainapp/graphicview.h @@ -26,7 +26,7 @@ class GraphicView void cleanUp(); - Drawing * getGraphic(); + Drawing * GetDrawing(); void setDrawingMode(RS2::DrawingMode m); RS2::DrawingMode getDrawingMode(); void setDeleteMode(bool m); @@ -93,8 +93,8 @@ class GraphicView void killAllActions(); /** - * Must be overwritten to emulate a mouse move event with - * the last known mouse position. + * Must be overridden to emulate a mouse move event with the last known + * mouse position. * * @see mx, my */ @@ -103,13 +103,13 @@ class GraphicView void back(); void enter(); - void mousePressEvent(QMouseEvent * e); - void mouseReleaseEvent(QMouseEvent * e); - void mouseMoveEvent(QMouseEvent * e); - void mouseLeaveEvent(); - void mouseEnterEvent(); - void keyPressEvent(QKeyEvent * e); - void keyReleaseEvent(QKeyEvent * e); + void _mousePressEvent(QMouseEvent * e); + void _mouseReleaseEvent(QMouseEvent * e); + void _mouseMoveEvent(QMouseEvent * e); + void _mouseLeaveEvent(); + void _mouseEnterEvent(); + void _keyPressEvent(QKeyEvent * e); + void _keyReleaseEvent(QKeyEvent * e); void commandEvent(CommandEvent * e); void enableCoordinateInput(); void disableCoordinateInput(); diff --git a/src/mainapp/main.cpp b/src/mainapp/main.cpp index c205e29..5d57769 100644 --- a/src/mainapp/main.cpp +++ b/src/mainapp/main.cpp @@ -47,16 +47,6 @@ QSplashScreen * splash = 0; # include "camdialog.h" #endif -//#ifdef RS_CAM -//# include "xpm/intro_camexpert.xpm" -//# include "xpm/splash_camexpert.xpm" -//#else -//# include "xpm/intro_qcad.xpm" -//# ifndef QC_CUSTOM_SPLASH -//# include "xpm/splash_qcad.xpm" -//# endif -//#endif - #ifndef QC_SPLASH_TXTCOL # define QC_SPLASH_TXTCOL Qt::black #endif @@ -116,7 +106,7 @@ int main(int argc, char * argv[]) #endif settings.endGroup(); - // show initial config dialog: + // Show initial config dialog if necessary: if (unit == "Invalid") { DEBUG->print("main: show initial config dialog.."); @@ -126,8 +116,6 @@ int main(int argc, char * argv[]) "Please choose the unit you want to use for new drawings and your " "preferred language.
" "You can changes these settings later in the Options Dialog of Architektonas."); -// QPixmap pxm(":/res/intro.xpm"); -// di.setPixmap(pxm); di.setPixmap(QPixmap(":/res/intro.xpm")); if (di.exec()) @@ -143,21 +131,7 @@ int main(int argc, char * argv[]) #ifdef QSPLASHSCREEN_H DEBUG->print("main: splashscreen.."); -//# ifdef QC_CUSTOM_SPLASH -// QPixmap * pixmap = new QPixmap(qPixmapFromMimeSource(QC_CUSTOM_SPLASH)); -//# else -//// QPixmap * pixmap = new QPixmap(":/res/splash.xpm"); -// QPixmap * pixmap = new QPixmap(":/res/splash_qcad.xpm"); QPixmap * pixmap = new QPixmap(":/res/splash.png"); -//# endif - -/* - splash = new QSplashScreen(*pixmap); - splash->show(); - splash->message(app.tr("Loading.."), - Qt::AlignRight|Qt::AlignBottom, QC_SPLASH_TXTCOL); - DEBUG->print("main: splashscreen: OK"); -*/ #endif DEBUG->print("main: init fontlist.."); @@ -243,7 +217,7 @@ int main(int argc, char * argv[]) // loading files: DEBUG->print("main: loading files.."); - bool files_loaded = false; + bool filesLoaded = false; for(QStringList::Iterator it=fileList.begin(); it!=fileList.end(); ++it) { @@ -257,16 +231,11 @@ int main(int argc, char * argv[]) } #endif appWin->slotFileOpen(*it, RS2::FormatUnknown); - files_loaded = true; + filesLoaded = true; } DEBUG->print("main: loading files: OK"); -//none of this demo shit -//#ifdef RS_DEMO -// QTimer::singleShot(10 * 60 * 1000, appWin, SLOT(slotFileDemoQuit())); -//#endif - #ifdef QSPLASHSCREEN_H # ifndef QC_DELAYED_SPLASH_SCREEN if (splash) @@ -279,15 +248,13 @@ int main(int argc, char * argv[]) delete pixmap; #endif - //app.connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit())); - // renew: avoid . / , confusion on German environments //setlocale(LC_NUMERIC, "C"); setlocale(LC_ALL, "C"); DEBUG->print("main: app.exec()"); - if (!files_loaded) + if (!filesLoaded) appWin->slotFileNew(); appWin->slotRunStartScript(); diff --git a/src/mainapp/mdiwindow.cpp b/src/mainapp/mdiwindow.cpp index d20e4e7..b3d0ac4 100644 --- a/src/mainapp/mdiwindow.cpp +++ b/src/mainapp/mdiwindow.cpp @@ -30,15 +30,16 @@ int MDIWindow::idCounter = 0; * * @param doc Pointer to an existing document of NULL if a new * document shall be created for this window. - * @param parent Parent widget. Usually a workspace. + * @param parent Parent widget. Usually a workspace (QMdiArea). */ MDIWindow::MDIWindow(Document * doc, QWidget * parent, const char * name/*= NULL*/, Qt::WindowFlags wflags/*= Qt::WDestructiveClose*/): - QMdiSubWindow(parent, Qt::SubWindow), owner(false), forceClosing(false) + QMdiSubWindow(parent, Qt::SubWindow), owner(false)//, forceClosing(false) #warning "!!! wflags is ignored !!!" { +// This warning not longer occurs...! //This warning is most likely coming from the QMdiSubWindow() constructor above... -#warning "QWidget::setMinimumSize: (/QMdi::ControlLabel) Negative sizes (-1,-1) are not possible" +//#warning "QWidget::setMinimumSize: (/QMdi::ControlLabel) Negative sizes (-1,-1) are not possible" initDoc(doc); initView(); id = idCounter++; @@ -90,12 +91,10 @@ MDIWindow::~MDIWindow() */ void MDIWindow::addChildWindow(MDIWindow * w) { - DEBUG->print("RS_MDIWindow::addChildWindow()"); - - childWindows.append(w); - w->setParentWindow(this); - - DEBUG->print("children: %d", childWindows.count()); + DEBUG->print("RS_MDIWindow::addChildWindow()"); + childWindows.append(w); + w->setParentWindow(this); + DEBUG->print("children: %d", childWindows.count()); } /** @@ -105,13 +104,10 @@ void MDIWindow::addChildWindow(MDIWindow * w) */ void MDIWindow::removeChildWindow(MDIWindow * w) { - DEBUG->print("RS_MDIWindow::removeChildWindow()"); - -// bool suc = childWindows.remove(w); - bool suc = childWindows.removeOne(w); - DEBUG->print("successfully removed child window: %d", (int)suc); - - DEBUG->print("children: %d", childWindows.count()); + DEBUG->print("RS_MDIWindow::removeChildWindow()"); + bool success = childWindows.removeOne(w); + DEBUG->print("successfully removed child window: %s.", (success ? "yes" : "NO")); + DEBUG->print("# of children: %d", childWindows.count()); } /** @@ -119,11 +115,11 @@ void MDIWindow::removeChildWindow(MDIWindow * w) */ MDIWindow * MDIWindow::getPrintPreview() { - for(uint i=0; igetGraphicView()->isPrintPreview()) + if (childWindows.at(i)->getGraphicView()->isPrintPreview()) return childWindows.at(i); - } + } return NULL; } @@ -134,13 +130,13 @@ MDIWindow * MDIWindow::getPrintPreview() * @param force Disable cancel button (demo versions) * @param ask Ask user before closing. */ -bool MDIWindow::closeMDI(bool force, bool ask) +bool MDIWindow::CloseMDI(void) { - // should never happen: + // This should never happen: if (!document) return true; - bool ret = false; + bool closed = false; bool isBlock = (parentWindow != NULL); // This is a block and we don't need to ask the user for closing @@ -148,6 +144,7 @@ bool MDIWindow::closeMDI(bool force, bool ask) if (isBlock) { DEBUG->print(" closing block"); + // tell parent window we're not here anymore. if (parentWindow) { @@ -156,15 +153,14 @@ bool MDIWindow::closeMDI(bool force, bool ask) } emit(signalClosing()); - ret = true; + closed = true; } - // This is a graphic document. ask user for closing. - else if (!ask || slotFileClose(force)) + // This is a drawing document. Ask user for closing. + else if (slotFileClose()) { DEBUG->print(" closing graphic"); - // close all child windows: - bool done; + // Close all child windows: while (!childWindows.isEmpty()) { MDIWindow * child = childWindows.takeFirst(); @@ -174,15 +170,10 @@ bool MDIWindow::closeMDI(bool force, bool ask) } emit(signalClosing()); - ret = true; - } - // User decided not to close graphic document: - else - { - ret = false; + closed = true; } - return (ret || force); + return closed; } /** @@ -190,22 +181,15 @@ bool MDIWindow::closeMDI(bool force, bool ask) */ void MDIWindow::closeEvent(QCloseEvent * ce) { - DEBUG->print("MDIWindow::closeEvent begin"); + DEBUG->print("MDIWindow::closeEvent begin"); - if (closeMDI(false, !forceClosing)) - ce->accept(); - else - ce->ignore(); + (CloseMDI() ? ce->accept() : ce->ignore()); - DEBUG->print("MDIWindow::closeEvent end"); + DEBUG->print("MDIWindow::closeEvent end"); } /** - * Init the document. - * - * @param type Document type. RS:EntityGraphic or RS2::EntityBlock - * @param container Entity container to be used as document or NULL - * if a new document should be created. + * Initialize the document. */ void MDIWindow::initDoc(Document * doc) { @@ -213,7 +197,7 @@ void MDIWindow::initDoc(Document * doc) if (!doc) { - document = new Drawing(); + document = new Drawing(); // Drawing is derived from Document document->newDoc(); owner = true; } @@ -225,10 +209,11 @@ void MDIWindow::initDoc(Document * doc) } /** - * Init the view. + * Initialize the view. */ void MDIWindow::initView() { + // This is only called once: In the MDIWindow constructor. DEBUG->print("MDIWindow::initView()"); // graphicView = new QC_GraphicView(document, this); @@ -368,71 +353,63 @@ bool MDIWindow::slotFileSaveAs(bool & cancelled) /** * Requests the closing of this MDI window. - * - * @param force Force closing by disabling the cancel button (for demo versions). */ -bool MDIWindow::slotFileClose(bool force) +bool MDIWindow::slotFileClose(void) { DEBUG->print("MDIWindow::slotFileClose()"); + bool succeeded = true; + + if (document == NULL || !document->isModified()) + return succeeded; - bool succ = true; - int exit = 0; + ExitDialog dlg(this); - if (document && document->isModified()) + if (document->getFilename().isEmpty()) + dlg.setText(tr("Do you really want to discard this drawing?")); + else { - ExitDialog dlg(this); - dlg.setForce(force); + QString fn = document->getFilename(); - if (document->getFilename().isEmpty()) - dlg.setText(tr("Do you really want to close the drawing?")); - else - { - QString fn = document->getFilename(); + if (fn.length() > 50) + fn = QString("%1...%2").arg(fn.left(24)).arg(fn.right(24)); - if (fn.length() > 50) - fn = QString("%1...%2").arg(fn.left(24)).arg(fn.right(24)); + dlg.setText(tr("Do you really want to discard changes to the file\n%1?").arg(fn)); + } - dlg.setText(tr("Do you really want to close the file\n%1?").arg(fn)); - } + dlg.setTitle(tr("Close Drawing")); - dlg.setTitle(tr("Closing Drawing")); + bool again = false; - bool again; + do + { bool cancelled; + int exit = dlg.exec(); - do + switch (exit) { + case 0: // Cancel + succeeded = false; again = false; - exit = dlg.exec(); - - switch (exit) - { - case 0: // cancel - succ = false; - break; - case 1: // leave - succ = true; - break; - case 2: // save - succ = slotFileSave(cancelled); - again = !succ || cancelled; - break; - case 3: // save as - succ = slotFileSaveAs(cancelled); - again = !succ || cancelled; - break; - default: - break; - } + break; + case 1: // OK (Leave) + succeeded = true; + again = false; + break; + case 2: // Save + succeeded = slotFileSave(cancelled); + again = !succeeded || cancelled; + break; + case 3: // Save As + succeeded = slotFileSaveAs(cancelled); + again = !succeeded || cancelled; + break; + default: + break; } - while (again); - } - else - { - succ = true; } + while (again); - return succ; + return succeeded; } void MDIWindow::slotFilePrint() @@ -459,32 +436,37 @@ void MDIWindow::slotFilePrint() //statusBar()->message(tr("Ready.")); } -/** @return Pointer to graphic view */ +/** + * @return Pointer to graphic view + */ //QC_GraphicView * MDIWindow::getGraphicView() QG_GraphicView * MDIWindow::getGraphicView() { return graphicView; } -/** @return Pointer to document */ +/** + * @return Pointer to document + */ Document * MDIWindow::getDocument() { return document; } -/** @return Pointer to graphic or NULL */ -Drawing * MDIWindow::getGraphic() +/** + * @return Pointer to Drawing or NULL + */ +Drawing * MDIWindow::GetDrawing() { - return document->getGraphic(); + return document->GetDrawing(); } -/** @return Pointer to current event handler */ +/** + * @return Pointer to current event handler + */ EventHandler * MDIWindow::getEventHandler() { - if (graphicView) - return graphicView->getEventHandler(); - else - return NULL; + return (graphicView ? graphicView->getEventHandler() : NULL); } /** @@ -504,11 +486,6 @@ int MDIWindow::getId() return id; } -void MDIWindow::setForceClosing(bool on) -{ - forceClosing = on; -} - /** * Streams some info about an MDI window to stdout. */ @@ -521,7 +498,7 @@ std::ostream & operator<<(std::ostream & os, MDIWindow & w) else os << " parentWindow: NULL\n"; - for(uint i=0; igetId() << "\n"; return os; diff --git a/src/mainapp/mdiwindow.h b/src/mainapp/mdiwindow.h index 4b6943b..31c03e4 100644 --- a/src/mainapp/mdiwindow.h +++ b/src/mainapp/mdiwindow.h @@ -32,21 +32,23 @@ class MDIWindow: public QMdiSubWindow bool slotFileOpen(const QString & fileName, RS2::FormatType type); bool slotFileSave(bool & cancelled); bool slotFileSaveAs(bool & cancelled); - bool slotFileClose(bool force); - void slotFilePrint(); +//WAS: bool slotFileClose(bool force); + bool slotFileClose(void); + void slotFilePrint(void); public: QG_GraphicView * getGraphicView(); Document * getDocument(); - Drawing * getGraphic(); + Drawing * GetDrawing(); EventHandler * getEventHandler(); void addChildWindow(MDIWindow * w); void removeChildWindow(MDIWindow * w); MDIWindow * getPrintPreview(); void setParentWindow(MDIWindow * p); int getId(); - bool closeMDI(bool force, bool ask = true); - void setForceClosing(bool on); +//WAS: bool closeMDI(bool force, bool ask = true); + bool CloseMDI(void); +// void setForceClosing(bool on); friend std::ostream & operator<<(std::ostream & os, MDIWindow & w); @@ -80,7 +82,7 @@ class MDIWindow: public QMdiSubWindow /** * If flag is set, the user will not be asked about closing this file. */ - bool forceClosing; +// bool forceClosing; }; #endif diff --git a/src/widgets/actionhandler.cpp b/src/widgets/actionhandler.cpp index f44ca7a..b5a28de 100644 --- a/src/widgets/actionhandler.cpp +++ b/src/widgets/actionhandler.cpp @@ -134,10 +134,10 @@ /** * Constructor */ -ActionHandler::ActionHandler(QG_MainWindowInterface * mw) +ActionHandler::ActionHandler(QG_MainWindowInterface * mwi) { DEBUG->print("ActionHandler::ActionHandler"); - mainWindow = mw; + mainWindowIntf = mwi; snapFree = NULL; snapGrid = NULL; @@ -171,7 +171,7 @@ ActionHandler::~ActionHandler() */ void ActionHandler::killSelectActions() { - GraphicView * gv = mainWindow->getGraphicView(); + GraphicView * gv = mainWindowIntf->getGraphicView(); if (gv) gv->killSelectActions(); @@ -182,7 +182,7 @@ void ActionHandler::killSelectActions() */ ActionInterface * ActionHandler::getCurrentAction() { - GraphicView * gv = mainWindow->getGraphicView(); + GraphicView * gv = mainWindowIntf->getGraphicView(); if (gv) return gv->getCurrentAction(); @@ -194,8 +194,8 @@ ActionInterface * ActionHandler::getCurrentAction() Instead of the following giant switch statement, you could something like the following: ActionInterface * ActionHandler::setCurrentAction(ActionInterface * action) { - GraphicView * gv = mainWindow->getGraphicView(); - Document * doc = mainWindow->getDocument(); + GraphicView * gv = mainWindowIntf->getGraphicView(); + Document * doc = mainWindowIntf->getDocument(); // only global options are allowed without a document: if (gv == NULL || doc == NULL) @@ -218,7 +218,7 @@ itself would create the gv & doc. So for the EditUndo, we'd have: FunctionCreateAction(bool); FunctionCreateAction(void); -Well... The problem is the action, they're all different... +Well... The problem is the actions, they're all different... #endif /** @@ -230,15 +230,15 @@ ActionInterface * ActionHandler::setCurrentAction(RS2::ActionType id) { DEBUG->print("ActionHandler::setCurrentAction()"); - GraphicView * gv = mainWindow->getGraphicView(); - Document * doc = mainWindow->getDocument(); + GraphicView * gv = mainWindowIntf->getGraphicView(); + Document * doc = mainWindowIntf->getDocument(); ActionInterface * a = NULL; // only global options are allowed without a document: if (gv == NULL || doc == NULL) { DEBUG->print(Debug::D_WARNING, - "ActionHandler::setCurrentAction: graphic view or document is NULL"); + "ActionHandler::setCurrentAction: graphic view=%08X or document=%08X", gv, doc); return NULL; } @@ -816,6 +816,7 @@ bool ActionHandler::keycode(const QString & code) //if (!e.isAccepted()) { // keycode for new action: RS2::ActionType type = COMMANDS->keycodeToAction(code); + if (type != RS2::ActionNone) { // some actions require special handling (GUI update): @@ -868,7 +869,6 @@ bool ActionHandler::keycode(const QString & code) } return true; } - //} return false; } @@ -887,7 +887,7 @@ bool ActionHandler::command(const QString & cmd) if (c == "\n") { - GraphicView * gv = mainWindow->getGraphicView(); + GraphicView * gv = mainWindowIntf->getGraphicView(); if (gv) gv->back(); @@ -899,7 +899,7 @@ bool ActionHandler::command(const QString & cmd) // pass command on to running action: CommandEvent e(cmd); - GraphicView * gv = mainWindow->getGraphicView(); + GraphicView * gv = mainWindowIntf->getGraphicView(); if (gv) { @@ -1834,13 +1834,10 @@ void ActionHandler::slotCamReorder() #endif } +// ??? WHAT THE FUCK IS THIS SHIT ??? void ActionHandler::slotFocusNormal() { - //QG_GraphicView* gv = mainWindow->getGraphicView(); - //if (gv) { - //gv->setFocus(); - mainWindow->setFocus2(); - //} + mainWindowIntf->setFocus2(); } void ActionHandler::setActionSnapFree(QAction * a) diff --git a/src/widgets/actionhandler.h b/src/widgets/actionhandler.h index e70ecae..abce3a5 100644 --- a/src/widgets/actionhandler.h +++ b/src/widgets/actionhandler.h @@ -208,7 +208,7 @@ class ActionHandler: public QObject void setCadToolBarSnap(CadToolBarSnap * tb); private: - QG_MainWindowInterface * mainWindow; + QG_MainWindowInterface * mainWindowIntf; CadToolBarSnap * cadToolBarSnap; QAction * snapFree; diff --git a/src/widgets/layerbox.cpp b/src/widgets/layerbox.cpp index b6e865a..5326f80 100644 --- a/src/widgets/layerbox.cpp +++ b/src/widgets/layerbox.cpp @@ -20,8 +20,7 @@ #include "layerlist.h" /** - * Default Constructor. You must call init manually before using - * this class. + * Default Constructor. You must call init manually before using this class. */ LayerBox::LayerBox(QWidget * parent, const char */*name*/): QComboBox(parent) { @@ -45,10 +44,9 @@ Layer * LayerBox::getLayer() } /** - * Initialisation (called manually only once). + * Initialization (called manually only once). * - * @param layerList Layer list which provides the layer names that are - * available. + * @param layerList Layer list which provides the layer names that are available. * @param showByBlock true: Show attribute ByBlock. */ void LayerBox::init(LayerList & layerList, bool showByBlock, bool showUnchanged) @@ -58,16 +56,14 @@ void LayerBox::init(LayerList & layerList, bool showByBlock, bool showUnchanged) this->layerList = &layerList; if (showUnchanged) -// insertItem(tr("- Unchanged -")); addItem(tr("- Unchanged -")); for(uint i=0; igetName() != "ByBlock" || showByBlock)) -// insertItem(lay->getName()); - addItem(lay->getName()); + if (currentLayer != NULL && (currentLayer->getName() != "ByBlock" || showByBlock)) + addItem(currentLayer->getName()); } connect(this, SIGNAL(activated(int)), this, SLOT(slotLayerChanged(int))); diff --git a/src/widgets/qg_dialogfactory.cpp b/src/widgets/qg_dialogfactory.cpp index b0a9248..f1f7bbd 100644 --- a/src/widgets/qg_dialogfactory.cpp +++ b/src/widgets/qg_dialogfactory.cpp @@ -109,7 +109,7 @@ QG_DialogFactory::QG_DialogFactory(QWidget * parent, QToolBar * ow): selectionWidget = NULL; cadToolBar = NULL; commandWidget = NULL; - mainWindow = NULL; + mainWindowIntf = NULL; DEBUG->print("QG_DialogFactory::QG_DialogFactory: OK"); } @@ -192,9 +192,9 @@ CommandWidget * QG_DialogFactory::getCommandWidget() /** * Links the dialog factory to a main app window. */ -/*virtual*/ void QG_DialogFactory::setMainWindow(QG_MainWindowInterface * mw) +/*virtual*/ void QG_DialogFactory::setMainWindow(QG_MainWindowInterface * mwi) { - mainWindow = mw; + mainWindowIntf = mwi; } /** @@ -211,10 +211,10 @@ void QG_DialogFactory::requestWarningDialog(const QString & warning) */ GraphicView * QG_DialogFactory::requestNewDocument(const QString & fileName, Document * doc) { - if (mainWindow != NULL) + if (mainWindowIntf != NULL) { - mainWindow->createNewDocument(fileName, doc); - return mainWindow->getGraphicView(); + mainWindowIntf->createNewDocument(fileName, doc); + return mainWindowIntf->getGraphicView(); } return NULL; @@ -225,9 +225,9 @@ GraphicView * QG_DialogFactory::requestNewDocument(const QString & fileName, Doc */ void QG_DialogFactory::requestSimulationControls() { - if (mainWindow != NULL) + if (mainWindowIntf != NULL) { - mainWindow->showSimulationControls(); + mainWindowIntf->showSimulationControls(); } } @@ -288,7 +288,7 @@ Layer * QG_DialogFactory::requestLayerRemovalDialog(LayerList * layerList) } /* if (layerList==NULL) { - if (container!=NULL && container->rtti()==RS2::EntityGraphic) { + if (container!=NULL && container->rtti()==RS2::EntityDrawing) { layerList = (LayerList*)container; } else { return NULL; @@ -406,9 +406,8 @@ BlockData QG_DialogFactory::requestNewBlockDialog(BlockList * blockList) */ BlockData QG_DialogFactory::requestBlockAttributesDialog(BlockList * blockList) { - //Block* block = NULL; - BlockData ret; - ret = BlockData("", Vector(false), false); + BlockData ret("", Vector(false), false); +// ret = BlockData("", Vector(false), false); if (blockList == NULL) { @@ -416,17 +415,6 @@ BlockData QG_DialogFactory::requestBlockAttributesDialog(BlockList * blockList) "blockList is NULL"); return ret; } - /* - if (blockList==NULL) { - if (container!=NULL && container->rtti()==RS2::EntityGraphic) { - blockList = (BlockList*)container; - } else { - return NULL; - } - }*/ - - // Block for parameter livery - //block = blockList->getActive(); BlockDialog dlg(parent);//WAS:, "Rename Block"); #warning "!!! WTF !!! WHY DO WE HAVE TO PREFIX tr WITH QObject:: ???" @@ -435,13 +423,8 @@ BlockData QG_DialogFactory::requestBlockAttributesDialog(BlockList * blockList) if (dlg.exec()) { - //dlg.updateBlock(); - //block->setData(); ret = dlg.getBlockData(); } - //else { - // ret = BlockData("", Vector(false)); - //} return ret; } diff --git a/src/widgets/qg_dialogfactory.h b/src/widgets/qg_dialogfactory.h index 4203216..3b6a929 100644 --- a/src/widgets/qg_dialogfactory.h +++ b/src/widgets/qg_dialogfactory.h @@ -141,7 +141,7 @@ class QG_DialogFactory: public DialogFactoryInterface //! Pointer to the command line widget CommandWidget * commandWidget; //! Pointer to the main app window - QG_MainWindowInterface * mainWindow; + QG_MainWindowInterface * mainWindowIntf; }; #endif diff --git a/src/widgets/qg_graphicview.cpp b/src/widgets/qg_graphicview.cpp index 6b4e1fb..df1efb8 100644 --- a/src/widgets/qg_graphicview.cpp +++ b/src/widgets/qg_graphicview.cpp @@ -406,14 +406,14 @@ void QG_GraphicView::mousePressEvent(QMouseEvent * e) if (e->button() == Qt::MidButton /*|| (e->state()==Qt::LeftButton|Qt::AltButton)*/) setCurrentAction(new ActionZoomPan(*container, *this)); - GraphicView::mousePressEvent(e); + GraphicView::_mousePressEvent(e); QWidget::mousePressEvent(e); } void QG_GraphicView::mouseReleaseEvent(QMouseEvent * e) { DEBUG->print("QG_GraphicView::mouseReleaseEvent"); - GraphicView::mouseReleaseEvent(e); + GraphicView::_mouseReleaseEvent(e); //QWidget::mouseReleaseEvent(e); if (!e->isAccepted()) @@ -430,7 +430,7 @@ void QG_GraphicView::mouseReleaseEvent(QMouseEvent * e) void QG_GraphicView::mouseMoveEvent(QMouseEvent * e) { - GraphicView::mouseMoveEvent(e); + GraphicView::_mouseMoveEvent(e); QWidget::mouseMoveEvent(e); } @@ -512,13 +512,13 @@ void QG_GraphicView::tabletEvent(QTabletEvent * e) void QG_GraphicView::leaveEvent(QEvent * e) { - GraphicView::mouseLeaveEvent(); + GraphicView::_mouseLeaveEvent(); QWidget::leaveEvent(e); } void QG_GraphicView::enterEvent(QEvent * e) { - GraphicView::mouseEnterEvent(); + GraphicView::_mouseEnterEvent(); QWidget::enterEvent(e); } @@ -529,10 +529,10 @@ void QG_GraphicView::focusOutEvent(QFocusEvent * e) void QG_GraphicView::focusInEvent(QFocusEvent * e) { -//printf("-->QG_GraphicView::focusInEvent(): Start. this %s focus...\n", (hasFocus() ? "has" : "DOES NOT HAVE")); - GraphicView::mouseEnterEvent(); +printf("-->QG_GraphicView::focusInEvent(): Start. this %s focus...\n", (hasFocus() ? "has" : "DOES NOT HAVE")); + GraphicView::_mouseEnterEvent(); QWidget::focusInEvent(e); -//printf("-->QG_GraphicView::focusInEvent(): End. this %s focus...\n", (hasFocus() ? "has" : "DOES NOT HAVE")); +printf("-->QG_GraphicView::focusInEvent(): End. this %s focus...\n", (hasFocus() ? "has" : "DOES NOT HAVE")); } /** @@ -626,12 +626,12 @@ void QG_GraphicView::keyPressEvent(QKeyEvent * e) if (scroll) setCurrentAction(new ActionZoomScroll(direction, *container, *this)); - GraphicView::keyPressEvent(e); + GraphicView::_keyPressEvent(e); } void QG_GraphicView::keyReleaseEvent(QKeyEvent * e) { - GraphicView::keyReleaseEvent(e); + GraphicView::_keyReleaseEvent(e); } /** diff --git a/src/widgets/qg_graphicview.h b/src/widgets/qg_graphicview.h index 7784ea9..1f59598 100644 --- a/src/widgets/qg_graphicview.h +++ b/src/widgets/qg_graphicview.h @@ -9,13 +9,9 @@ class PaintInterface; class Preview; /** - * This is the Qt implementation of a widget which can view a - * graphic. - * - * Instances of this class can be linked to layer lists using - * addLayerListListener(). + * This is the Qt implementation of a widget which can view a drawing. */ -class QG_GraphicView: public QWidget, public GraphicView//, public Q3FilePreview +class QG_GraphicView: public QWidget, public GraphicView { Q_OBJECT diff --git a/src/widgets/qg_mainwindowinterface.h b/src/widgets/qg_mainwindowinterface.h index 9533923..a036d14 100644 --- a/src/widgets/qg_mainwindowinterface.h +++ b/src/widgets/qg_mainwindowinterface.h @@ -1,7 +1,7 @@ #ifndef QG_MAINWINDOWINTERFACE_H #define QG_MAINWINDOWINTERFACE_H -#include "mainwindowinterface.h" +#warning "!!! THIS IS CANDIDATE FOR REMOVAL !!!" class QMainWindow; class ActionHandler; @@ -9,15 +9,17 @@ class ActionHandler; /** * Interface for main application windows. */ -class QG_MainWindowInterface: public MainWindowInterface +class QG_MainWindowInterface { public: QG_MainWindowInterface() {} virtual ~QG_MainWindowInterface() {} - virtual QMainWindow * GetMainWindow() = 0; - virtual ActionHandler * getActionHandler() = 0; virtual void setFocus2() = 0; + virtual GraphicView * getGraphicView() = 0; + virtual Document * getDocument() = 0; + virtual void createNewDocument(const QString & fileName = QString::null, Document * doc = NULL) = 0; + virtual void showSimulationControls() = 0; }; #endif // QG_MAINWINDOWINTERFACE_H