Skip to content

Commit

Permalink
restore layer print property and implement separate construction laye…
Browse files Browse the repository at this point in the history
…r property
  • Loading branch information
lordofbikes committed Jan 12, 2015
1 parent eb5ba33 commit eee4fdc
Show file tree
Hide file tree
Showing 27 changed files with 320 additions and 74 deletions.
4 changes: 4 additions & 0 deletions libraries/libdxfrw/src/drw_objects.cpp
@@ -1,6 +1,7 @@
/******************************************************************************
** libDXFrw - Library to read/write DXF files (ascii & binary) **
** **
** Copyright (C) 2015 A. Stebich (librecad@mail.lordofbikes.de) **
** Copyright (C) 2011 Rallaz, rallazz@gmail.com **
** **
** This library is free software, licensed under the terms of the GNU **
Expand Down Expand Up @@ -330,6 +331,9 @@ void DRW_Layer::parseCode(int code, dxfReader *reader){
case 420:
color24 = reader->getInt32();
break;
case 999:
comment = reader->getUtf8String();
break;
default:
DRW_TableEntry::parseCode(code, reader);
break;
Expand Down
3 changes: 3 additions & 0 deletions libraries/libdxfrw/src/drw_objects.h
@@ -1,6 +1,7 @@
/******************************************************************************
** libDXFrw - Library to read/write DXF files (ascii & binary) **
** **
** Copyright (C) 2015 A. Stebich (librecad@mail.lordofbikes.de) **
** Copyright (C) 2011 Rallaz, rallazz@gmail.com **
** **
** This library is free software, licensed under the terms of the GNU **
Expand Down Expand Up @@ -220,6 +221,7 @@ class DRW_Layer : public DRW_TableEntry {
plotF = true; // default TRUE (plot yes)
lWeight = DRW_LW_Conv::widthDefault; // default BYDEFAULT (dxf -3, dwg 31)
color24 = -1; //default -1 not set
comment = "";
}

void parseCode(int code, dxfReader *reader);
Expand All @@ -232,6 +234,7 @@ class DRW_Layer : public DRW_TableEntry {
enum DRW_LW_Conv::lineWidth lWeight; /*!< layer lineweight, code 370 */
std::string handlePlotS; /*!< Hard-pointer ID/handle of plotstyle, code 390 */
std::string handlePlotM; /*!< Hard-pointer ID/handle of materialstyle, code 347 */
UTF8STRING comment; /*!< Comment, code 999 */
};

//! Class to handle text style entries
Expand Down
4 changes: 4 additions & 0 deletions libraries/libdxfrw/src/libdxfrw.cpp
@@ -1,6 +1,7 @@
/******************************************************************************
** libDXFrw - Library to read/write DXF files (ascii & binary) **
** **
** Copyright (C) 2015 A. Stebich (librecad@mail.lordofbikes.de) **
** Copyright (C) 2011 Rallaz, rallazz@gmail.com **
** **
** This library is free software, licensed under the terms of the GNU **
Expand Down Expand Up @@ -245,6 +246,9 @@ bool dxfRW::writeLayer(DRW_Layer *ent){
} else
writer->writeUtf8Caps(6, ent->lineType);
// writer->writeString(347, "10012");
if( ! ent->comment.empty()) {
writer->writeUtf8String( 999, ent->comment);
}
return true;
}

Expand Down
Binary file added librecad/res/ui/construction.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions librecad/res/ui/ui.qrc
Expand Up @@ -20,6 +20,7 @@
<file>color11.png</file>
<file>color14.png</file>
<file>colorxx.png</file>
<file>construction.png</file>
<file>cur_cad_bmp.png</file>
<file>cur_del_bmp.png</file>
<file>cur_glass_bmp.png</file>
Expand Down
86 changes: 86 additions & 0 deletions librecad/src/actions/lc_actionlayerstoggleconstruction.cpp
@@ -0,0 +1,86 @@
/****************************************************************************
**
* Toggle whether a layer is a construction layer or not
* construction layers doesn't appear on printout,
* and have straight lines of infinite length
Copyright (C) 2015 Armin Stebich (librecad@mail.lordofbikes.de)
Copyright (C) 2011 Dongxu Li (dongxuli2011@gmail.com)
Copyright (C) 2011 R. van Twisk (librecad@rvt.dds.nl)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**********************************************************************/


#include "lc_actionlayerstoggleconstruction.h"

#include <QAction>
#include "rs_dialogfactory.h"
#include "rs_graphicview.h"
#include "rs_graphic.h"
#include "rs_layer.h"

/**
* whether a layer is a construction layer or not
* construction layers doesn't appear on printout,
* and have straight lines of infinite length
*
* @author Armin Stebich
*/
LC_ActionLayersToggleConstruction::LC_ActionLayersToggleConstruction(
RS_EntityContainer& container,
RS_GraphicView& graphicView)
:RS_ActionInterface("Toggle Construction Layer",
container, graphicView) {}


QAction* LC_ActionLayersToggleConstruction::createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/) {
QAction* action = new QAction(tr("Toggle &Construction Layer"), NULL);
action->setIcon(QIcon(":/ui/construction.png"));
return action;
}


void LC_ActionLayersToggleConstruction::trigger() {
RS_DEBUG->print("toggle layer construction");
if (graphic!=NULL) {
RS_Layer* layer = graphic->getActiveLayer();
if (layer!=NULL) {
graphic->toggleLayerConstruction( layer);

// deselect entities on locked layer:
for (RS_Entity* e=container->firstEntity(); e!=NULL;
e=container->nextEntity()) {
if (e!=NULL && e->isVisible() && e->getLayer()==layer) {
if (graphicView!=NULL) {
graphicView->deleteEntity(e);
}
if (graphicView!=NULL) {
graphicView->drawEntity(e);
}
}
}
}
}
finish(false);
}


void LC_ActionLayersToggleConstruction::init(int status) {
RS_ActionInterface::init(status);
trigger();
}

// EOF
53 changes: 53 additions & 0 deletions librecad/src/actions/lc_actionlayerstoggleconstruction.h
@@ -0,0 +1,53 @@
/****************************************************************************
**
* Toggle whether a layer should appear on print (a construction layer doesn't appear on
printout, and have straight lines of infinite length)
Copyright (C) 2015 A. Stebich (librecad@mail.lordofbikes.de)
Copyright (C) 2011 Dongxu Li (dongxuli2011@gmail.com)
Copyright (C) 2011 R. van Twisk (librecad@rvt.dds.nl)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**********************************************************************/


#ifndef LC_ACTIONLAYERSTOGGLECONSTRUCTION_H
#define LC_ACTIONLAYERSTOGGLECONSTRUCTION_H

#include "rs_actioninterface.h"


/**
* whether a layer is a construction layer or not
* construction layers doesn't appear on printout,
* and have straight lines of infinite length
*
* @author Armin Stebich
*/
class LC_ActionLayersToggleConstruction : public RS_ActionInterface {
Q_OBJECT
public:
LC_ActionLayersToggleConstruction(RS_EntityContainer& container,
RS_GraphicView& graphicView);
~LC_ActionLayersToggleConstruction() {}

static QAction* createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/);

virtual void init(int status=0);
virtual void trigger();

};

#endif
1 change: 1 addition & 0 deletions librecad/src/lib/engine/rs.h
Expand Up @@ -377,6 +377,7 @@ class RS2 {
ActionLayersToggleView,
ActionLayersToggleLock,
ActionLayersTogglePrint,
ActionLayersToggleConstruction,

ActionBlocksDefreezeAll,
ActionBlocksFreezeAll,
Expand Down
11 changes: 9 additions & 2 deletions librecad/src/lib/engine/rs_entity.cpp
Expand Up @@ -2,6 +2,7 @@
**
** This file is part of the LibreCAD project, a 2D CAD program
**
** Copyright (C) 2015 A. Stebich (librecad@mail.lordofbikes.de)
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
**
Expand Down Expand Up @@ -899,17 +900,23 @@ QList<QString> RS_Entity::getAllKeys() {
}

//! constructionLayer contains entities of infinite length, constructionLayer doesn't show up in print
bool RS_Entity::isConstructionLayer(bool typeCheck) const {
bool RS_Entity::isConstruction(bool typeCheck) const {
if( typeCheck
&& getParent() != NULL
&& RS2::EntityLine != rtti() ){
// do not expand entities on construction layers, except lines
return false;
}
if(layer != NULL) return layer->isConstructionLayer();
if(layer != NULL) return layer->isConstruction();
return false;
}

//! whether printing is enabled or disabled for the entity's layer
bool RS_Entity::isPrint(void) const {
if(nullptr != layer) return layer->isPrint();
return true;
}

bool RS_Entity::trimmable() const
{
switch(rtti()){
Expand Down
5 changes: 4 additions & 1 deletion librecad/src/lib/engine/rs_entity.h
Expand Up @@ -2,6 +2,7 @@
**
** This file is part of the LibreCAD project, a 2D CAD program
**
** Copyright (C) 2015 A. Stebich (librecad@mail.lordofbikes.de)
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
**
Expand Down Expand Up @@ -564,7 +565,9 @@ class RS_Entity : public RS_Undoable {
virtual void calculateBorders() = 0;
/** whether the entity is on a constructionLayer */
//! constructionLayer contains entities of infinite length, constructionLayer doesn't show up in print
bool isConstructionLayer(bool typeCheck = false) const; // ignore certain entity types for constructionLayer check
bool isConstruction(bool typeCheck = false) const; // ignore certain entity types for constructionLayer check
//! whether printing is enabled or disabled for the entity's layer
bool isPrint(void) const;
/** return the equation of the entity
for quadratic,
Expand Down
4 changes: 4 additions & 0 deletions librecad/src/lib/engine/rs_graphic.h
Expand Up @@ -2,6 +2,7 @@
**
** This file is part of the LibreCAD project, a 2D CAD program
**
** Copyright (C) 2015 A. Stebich (librecad@mail.lordofbikes.de)
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
**
Expand Down Expand Up @@ -114,6 +115,9 @@ class RS_Graphic : public RS_Document {
void toggleLayerPrint(RS_Layer* layer) {
layerList.togglePrint(layer);
}
void toggleLayerConstruction(RS_Layer* layer) {
layerList.toggleConstruction(layer);
}
void freezeAllLayers(bool freeze) {
layerList.freezeAll(freeze);
}
Expand Down
8 changes: 5 additions & 3 deletions librecad/src/lib/engine/rs_layer.cpp
Expand Up @@ -2,6 +2,7 @@
**
** This file is part of the LibreCAD project, a 2D CAD program
**
** Copyright (C) 2015 A. Stebich (librecad@mail.lordofbikes.de)
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
**
Expand Down Expand Up @@ -38,7 +39,8 @@ RS_Layer::RS_Layer(const QString& name) {
data.pen.setColor(Qt::black);
data.frozen = false;
data.locked = false;
data.constructionLayer = false;
data.print = true;
data.construction = false;
}


Expand All @@ -48,8 +50,8 @@ RS_Layer::RS_Layer(const QString& name) {
std::ostream& operator << (std::ostream& os, const RS_Layer& l) {
os << " name: " << l.getName().toLatin1().data()
<< " pen: " << l.getPen()
<< " frozen: " << (int)l.isFrozen()
<< " address: " << &l
<< " frozen: " << (int)l.isFrozen()
<< " address: " << &l
<< std::endl;
return os;
}
Expand Down

0 comments on commit eee4fdc

Please sign in to comment.