]> Shamusworld >> Repos - architektonas/blob - src/actions/actiontoolregeneratedimensions.cpp
0494e0695f51fe54543858828639d28aa005f1fb
[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_debug.h"
20 #include "rs_dialogfactory.h"
21 #include "rs_dimension.h"
22 #include "graphicview.h"
23 #include "rs_information.h"
24
25 ActionToolRegenerateDimensions::ActionToolRegenerateDimensions(RS_EntityContainer & container, GraphicView & graphicView):
26         ActionInterface("Tool Regen Dim", container, graphicView)
27 {
28 }
29
30 ActionToolRegenerateDimensions::~ActionToolRegenerateDimensions()
31 {
32 }
33
34 void ActionToolRegenerateDimensions::init(int status)
35 {
36         ActionInterface::init(status);
37         trigger();
38 }
39
40 void ActionToolRegenerateDimensions::trigger()
41 {
42         RS_DEBUG->print("ActionToolRegenerateDimensions::trigger()");
43
44         int num = 0;
45
46         for(RS_Entity * e = container->firstEntity(RS2::ResolveNone);
47              e != NULL; e = container->nextEntity(RS2::ResolveNone))
48         {
49                 if (RS_Information::isDimension(e->rtti()) && e->isVisible())
50                 {
51                         num++;
52
53                         if (((RS_Dimension *)e)->getLabel() == ";;")
54                                 ((RS_Dimension *)e)->setLabel("");
55
56                         ((RS_Dimension *)e)->update(true);
57                 }
58         }
59
60         if (num > 0)
61         {
62                 graphicView->redraw();
63                 RS_DIALOGFACTORY->commandMessage(tr("Regenerated %1 dimension entities").arg(num));
64         }
65         else
66                 RS_DIALOGFACTORY->commandMessage(tr("No dimension entities found"));
67
68         finish();
69 }
70
71