]> Shamusworld >> Repos - architektonas/blob - src/actions/actiontoolregeneratedimensions.cpp
a1d9d5f1d9362d0f38923a14d6d1f8d4b5cb3e01
[architektonas] / src / actions / actiontoolregeneratedimensions.cpp
1 // actiontoolregeneratedimensions.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 // Portions copyright (C) 2001-2003 RibbonSoft
7 // Copyright (C) 2010 Underground Software
8 // See the README and GPLv2 files for licensing and warranty information
9 //
10 // JLH = James L. Hammons <jlhamm@acm.org>
11 //
12 // Who  When        What
13 // ---  ----------  -----------------------------------------------------------
14 // JLH  06/05/2010  Added this text. :-)
15 //
16
17 #include "actiontoolregeneratedimensions.h"
18
19 #include "rs_dialogfactory.h"
20 #include "rs_dimension.h"
21 #include "graphicview.h"
22 #include "rs_information.h"
23
24 ActionToolRegenerateDimensions::ActionToolRegenerateDimensions(RS_EntityContainer & container, GraphicView & graphicView):
25         ActionInterface("Tool Regen Dim", container, graphicView)
26 {
27 }
28
29 ActionToolRegenerateDimensions::~ActionToolRegenerateDimensions()
30 {
31 }
32
33 void ActionToolRegenerateDimensions::init(int status)
34 {
35         ActionInterface::init(status);
36         trigger();
37 }
38
39 void ActionToolRegenerateDimensions::trigger()
40 {
41         RS_DEBUG->print("ActionToolRegenerateDimensions::trigger()");
42
43         int num = 0;
44
45         for(RS_Entity * e = container->firstEntity(RS2::ResolveNone);
46              e != NULL; e = container->nextEntity(RS2::ResolveNone))
47         {
48                 if (RS_Information::isDimension(e->rtti()) && e->isVisible())
49                 {
50                         num++;
51
52                         if (((RS_Dimension *)e)->getLabel() == ";;")
53                                 ((RS_Dimension *)e)->setLabel("");
54
55                         ((RS_Dimension *)e)->update(true);
56                 }
57         }
58
59         if (num > 0)
60         {
61                 graphicView->redraw();
62                 RS_DIALOGFACTORY->commandMessage(tr("Regenerated %1 dimension entities").arg(num));
63         }
64         else
65                 RS_DIALOGFACTORY->commandMessage(tr("No dimension entities found"));
66
67         finish();
68 }
69
70