]> Shamusworld >> Repos - architektonas/blob - src/actions/rs_actionlayersedit.cpp
Refactoring: Moved RS_GraphicView to GraphicView.
[architektonas] / src / actions / rs_actionlayersedit.cpp
1 // rs_actionlayersedit.cpp
2 //
3 // Part of the Architektonas Project
4 // Originally part of QCad Community Edition by Andrew Mustun
5 // Extensively rewritten and refactored by James L. Hammons
6 // (C) 2010 Underground Software
7 //
8 // JLH = James L. Hammons <jlhamm@acm.org>
9 //
10 // Who  When        What
11 // ---  ----------  -----------------------------------------------------------
12 // JLH  06/04/2010  Added this text. :-)
13 //
14
15 #include "rs_actionlayersedit.h"
16
17 #include "rs_dialogfactory.h"
18 #include "graphicview.h"
19 #include "drawing.h"
20
21 RS_ActionLayersEdit::RS_ActionLayersEdit(RS_EntityContainer & container, GraphicView & graphicView):
22         RS_ActionInterface("Edit Layer", container, graphicView)
23 {
24 }
25
26 RS_ActionLayersEdit::~RS_ActionLayersEdit()
27 {
28 }
29
30 void RS_ActionLayersEdit::trigger()
31 {
32         RS_DEBUG->print("RS_ActionLayersEdit::trigger");
33         RS_Layer * layer = NULL;
34
35         if (graphic != NULL)
36         {
37                 layer = RS_DIALOGFACTORY->requestEditLayerDialog(graphic->getLayerList());
38
39                 if (layer != NULL)
40                 {
41                         graphic->editLayer(graphic->getActiveLayer(), *layer);
42
43                         // update updateable entities on the layer that has changed
44                         for (RS_Entity * e = graphic->firstEntity(RS2::ResolveNone);
45                              e != NULL; e = graphic->nextEntity(RS2::ResolveNone))
46                         {
47                                 RS_Layer * l = e->getLayer();
48
49                                 if (l != NULL && l->getName() == layer->getName())
50                                         e->update();
51                         }
52                 }
53         }
54
55         finish();
56         graphicView->redraw();
57 }
58
59 void RS_ActionLayersEdit::init(int status)
60 {
61         RS_ActionInterface::init(status);
62         trigger();
63 }
64
65 // EOF