Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
1,227 additions
and
435 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
MTextOperations = { | ||
name = "MTextOperations", | ||
command_line = "MTEXT", | ||
context_transitions = { | ||
enterTextValue = {"enterInsertionPoint", "enterHeight", "enterAngle"}, | ||
enterInsertionPoint = {"enterTextValue", "enterHeight", "enterAngle"}, | ||
enterHeight = {"enterTextValue", "enterInsertionPoint", "enterAngle"}, | ||
enterAngle = {"enterTextValue", "enterInsertionPoint", "enterHeight"} | ||
} | ||
} | ||
MTextOperations.__index = MTextOperations | ||
|
||
setmetatable(MTextOperations, { | ||
__index = CreateOperations, | ||
__call = function (o, ...) | ||
local self = setmetatable({}, o) | ||
self:_init(...) | ||
return self | ||
end, | ||
}) | ||
|
||
function MTextOperations:_init() | ||
CreateOperations._init(self, lc.builder.MTextBuilder, "enterTextValue") | ||
message("Enter mtext value") | ||
self.builder:setTextValue("MText") | ||
mainWindow:cliCommand():commandActive(true) | ||
end | ||
|
||
function MTextOperations:enterTextValue(eventName, data) | ||
if(eventName == "mouseMove") then | ||
self.builder:setInsertionPoint(data["position"]) | ||
elseif(eventName == "text") then | ||
self.builder:setTextValue(data["text"]) | ||
self.textValue = data["text"] | ||
self:determineNextStep() | ||
end | ||
end | ||
|
||
function MTextOperations:enterInsertionPoint(eventName, data) | ||
if(eventName == "mouseMove") then | ||
self.builder:setInsertionPoint(data["position"]) | ||
elseif(eventName == "point") then | ||
self.builder:setInsertionPoint(data["position"]) | ||
if self.byTextDialog ~= nil and self.byTextDialog then | ||
self:createEntity() | ||
else | ||
self.insertionPoint = data["position"] | ||
self:determineNextStep() | ||
end | ||
end | ||
end | ||
|
||
function MTextOperations:enterHeight(eventName, data) | ||
if(eventName == "mouseMove") then | ||
local dist = self.builder:insertionPoint():distanceTo(data["position"]) | ||
self.builder:setHeight(dist) | ||
elseif(eventName == "point") then | ||
local dist = self.builder:insertionPoint():distanceTo(data["position"]) | ||
self.builder:setHeight(dist) | ||
self.height = dist | ||
self:determineNextStep() | ||
elseif(eventName == "number") then | ||
self.builder:setHeight(data["number"]) | ||
self.height = data["number"] | ||
self:determineNextStep() | ||
end | ||
end | ||
|
||
function MTextOperations:enterAngle(eventName, data) | ||
if(eventName == "mouseMove") then | ||
local ang = self.builder:insertionPoint():distanceTo(data["position"]) * 0.05 | ||
self.builder:setAngle(ang) | ||
elseif(eventName == "point") then | ||
local ang = self.builder:insertionPoint():distanceTo(data["position"]) * 0.05 | ||
self.builder:setAngle(ang) | ||
self.angle = ang | ||
self:determineNextStep() | ||
elseif(eventName == "number") then | ||
self.builder:setAngle(data["number"] * 3.1416/180) | ||
self.angle = self.builder:angle() | ||
self:determineNextStep() | ||
end | ||
end | ||
|
||
function MTextOperations:copyEntity(textEntity) | ||
self.builder:copy(textEntity) | ||
self.byTextDialog = true | ||
self.step = "enterInsertionPoint" | ||
message("Enter insertion point") | ||
end | ||
|
||
function MTextOperations:determineNextStep() | ||
if(self.textValue == nil) then | ||
message("Enter text value") | ||
self.step = "enterTextValue" | ||
elseif(self.insertionPoint == nil) then | ||
message("Enter insertion point") | ||
self.step = "enterInsertionPoint" | ||
elseif(self.height == nil) then | ||
message("Enter height of text") | ||
self.step = "enterHeight" | ||
elseif(self.angle == nil) then | ||
message("Enter angle of text (in degrees)") | ||
self.step = "enterAngle" | ||
else | ||
message("Done") | ||
self:createEntity() | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#include "mtext.h" | ||
#include <cad/primitive/mtext.h> | ||
|
||
using namespace lc::builder; | ||
|
||
MTextBuilder::MTextBuilder() | ||
: | ||
_underlined(false), | ||
_strikethrough(false), | ||
_bold(false), | ||
_italic(false) | ||
{ | ||
} | ||
|
||
MTextBuilder* MTextBuilder::setUnderlined(bool underline) { | ||
_underlined = underline; | ||
return this; | ||
} | ||
|
||
bool MTextBuilder::underlined() const { | ||
return _underlined; | ||
} | ||
|
||
MTextBuilder* MTextBuilder::setStrikethrough(bool strikethrough) { | ||
_strikethrough = strikethrough; | ||
return this; | ||
} | ||
|
||
bool MTextBuilder::strikethrough() const { | ||
return _strikethrough; | ||
} | ||
|
||
MTextBuilder* MTextBuilder::setBold(bool bold) { | ||
_bold = bold; | ||
return this; | ||
} | ||
|
||
bool MTextBuilder::bold() const { | ||
return _bold; | ||
} | ||
|
||
MTextBuilder* MTextBuilder::setItalic(bool italic) { | ||
_italic = italic; | ||
return this; | ||
} | ||
|
||
bool MTextBuilder::italic() const { | ||
return _italic; | ||
} | ||
|
||
lc::entity::MText_CSPtr MTextBuilder::build() { | ||
checkValues(true); | ||
return entity::MText_CSPtr(new entity::MText(*this)); | ||
} | ||
|
||
void MTextBuilder::copy(lc::entity::MText_CSPtr entity) { | ||
CADEntityBuilder::copy(entity); | ||
|
||
setInsertionPoint(entity->insertion_point()); | ||
setTextValue(entity->text_value()); | ||
setTextFont(entity->style()); | ||
setHeight(entity->height()); | ||
setAngle(entity->angle()); | ||
setDrawingDirection(entity->textgeneration()); | ||
setHorizontalAlign(entity->halign()); | ||
setVerticalAlign(entity->valign()); | ||
setUnderlined(entity->underlined()); | ||
setStrikethrough(entity->strikethrough()); | ||
setBold(entity->bold()); | ||
setItalic(entity->italic()); | ||
} |
Oops, something went wrong.