[TD]combine @wmayer and edi271 changes re command extensions
This commit is contained in:
@@ -74,37 +74,61 @@ using namespace Gui;
|
||||
using namespace TechDraw;
|
||||
using namespace TechDrawGui;
|
||||
|
||||
enum class EdgeStyle {
|
||||
solid = 1,
|
||||
dashed = 2,
|
||||
dotted = 3,
|
||||
dashdotted = 4
|
||||
};
|
||||
|
||||
enum class EdgeWidth {
|
||||
small = 1,
|
||||
middle = 2,
|
||||
thick = 3
|
||||
};
|
||||
|
||||
enum class EdgeColor {
|
||||
black = 1,
|
||||
grey = 2,
|
||||
red = 3,
|
||||
green = 4,
|
||||
blue = 5,
|
||||
magenta = 6,
|
||||
cyan = 7,
|
||||
yellow = 8
|
||||
};
|
||||
|
||||
//===========================================================================
|
||||
// managing global line attributes
|
||||
//===========================================================================
|
||||
|
||||
LineAttributes::LineAttributes(void)
|
||||
lineAttributes::lineAttributes(void)
|
||||
{
|
||||
style = dotted;
|
||||
width = middle;
|
||||
color = black;
|
||||
style = int(EdgeStyle::dotted);
|
||||
width = int(EdgeWidth::middle);
|
||||
color = int(EdgeColor::black);
|
||||
}
|
||||
|
||||
void LineAttributes::setStyle(edgeStyle newStyle)
|
||||
void lineAttributes::setStyle(int newStyle)
|
||||
{
|
||||
style = newStyle;
|
||||
}
|
||||
|
||||
void LineAttributes::setWidth(edgeWidth newWidth)
|
||||
void lineAttributes::setWidth(int newWidth)
|
||||
{
|
||||
width = newWidth;
|
||||
}
|
||||
|
||||
float LineAttributes::getWidthValue(void)
|
||||
float lineAttributes::getWidthValue(void)
|
||||
{
|
||||
switch(width){
|
||||
case small:
|
||||
switch(EdgeWidth(width)) {
|
||||
case EdgeWidth::small:
|
||||
return 0.18f;
|
||||
break;
|
||||
case middle:
|
||||
case EdgeWidth::middle:
|
||||
return 0.35f;
|
||||
break;
|
||||
case thick:
|
||||
case EdgeWidth::thick:
|
||||
return 0.5f;
|
||||
break;
|
||||
default:
|
||||
@@ -112,36 +136,36 @@ float LineAttributes::getWidthValue(void)
|
||||
}
|
||||
}
|
||||
|
||||
void LineAttributes::setColor(edgeColor newColor)
|
||||
void lineAttributes::setColor(int newColor)
|
||||
{
|
||||
color = newColor;
|
||||
}
|
||||
|
||||
App::Color LineAttributes::getColorValue(void)
|
||||
App::Color lineAttributes::getColorValue(void)
|
||||
{
|
||||
switch(color){
|
||||
case black:
|
||||
switch(EdgeColor(color)) {
|
||||
case EdgeColor::black:
|
||||
return App::Color(0.0,0.0,0.0);
|
||||
break;
|
||||
case grey:
|
||||
case EdgeColor::grey:
|
||||
return App::Color(0.7,0.7,0.7);
|
||||
break;
|
||||
case red:
|
||||
case EdgeColor::red:
|
||||
return App::Color(1.0,0.0,0.0);
|
||||
break;
|
||||
case green:
|
||||
case EdgeColor::green:
|
||||
return App::Color(0.0,1.0,0.0);
|
||||
break;
|
||||
case blue:
|
||||
case EdgeColor::blue:
|
||||
return App::Color(0.0,0.0,1.0);
|
||||
break;
|
||||
case magenta:
|
||||
case EdgeColor::magenta:
|
||||
return App::Color(1.0,0.0,1.0);
|
||||
break;
|
||||
case cyan:
|
||||
case EdgeColor::cyan:
|
||||
return App::Color(0.0,1.0,1.0);
|
||||
break;
|
||||
case yellow:
|
||||
case EdgeColor::yellow:
|
||||
return App::Color(1.0,1.0,0.0);
|
||||
break;
|
||||
default:
|
||||
@@ -169,10 +193,9 @@ dimAttributes activeDimAttributes; // container holding dimension attributes
|
||||
// TaskSelectLineAttributes
|
||||
//===========================================================================
|
||||
|
||||
TaskSelectLineAttributes::TaskSelectLineAttributes(LineAttributes * ptActiveAttributes) :
|
||||
ui(new Ui_TaskSelectLineAttributes),
|
||||
activeAttributes(ptActiveAttributes)
|
||||
|
||||
TaskSelectLineAttributes::TaskSelectLineAttributes(lineAttributes * ptActiveAttributes) :
|
||||
activeAttributes(ptActiveAttributes),
|
||||
ui(new Ui_TaskSelectLineAttributes)
|
||||
{
|
||||
|
||||
ui->setupUi(this);
|
||||
@@ -202,64 +225,64 @@ void TaskSelectLineAttributes::changeEvent(QEvent *e)
|
||||
|
||||
void TaskSelectLineAttributes::setUiEdit()
|
||||
{
|
||||
setWindowTitle(QObject::tr("Select Line Attributes"));
|
||||
LineAttributes::edgeStyle lineStyle = activeAttributes->getStyle();
|
||||
switch(lineStyle){
|
||||
case LineAttributes::solid:
|
||||
setWindowTitle(tr("Select line attributes"));
|
||||
int lineStyle = activeAttributes->getStyle();
|
||||
switch(EdgeStyle(lineStyle)) {
|
||||
case EdgeStyle::solid:
|
||||
ui->rbSolid->setChecked(true);
|
||||
break;
|
||||
case LineAttributes::dashed:
|
||||
case EdgeStyle::dashed:
|
||||
ui->rbDashed->setChecked(true);
|
||||
break;
|
||||
case LineAttributes::dotted:
|
||||
case EdgeStyle::dotted:
|
||||
ui->rbDotted->setChecked(true);
|
||||
break;
|
||||
case LineAttributes::dashdotted:
|
||||
case EdgeStyle::dashdotted:
|
||||
ui->rbDashDotted->setChecked(true);
|
||||
break;
|
||||
default:
|
||||
ui->rbDashDotted->setChecked(true);
|
||||
}
|
||||
|
||||
LineAttributes::edgeWidth lineWidth = activeAttributes->getWidth();
|
||||
switch(lineWidth){
|
||||
case LineAttributes::small:
|
||||
int lineWidth = activeAttributes->getWidth();
|
||||
switch(EdgeWidth(lineWidth)) {
|
||||
case EdgeWidth::small:
|
||||
ui->rbThin->setChecked(true);
|
||||
break;
|
||||
case LineAttributes::middle:
|
||||
case EdgeWidth::middle:
|
||||
ui->rbMiddle->setChecked(true);
|
||||
break;
|
||||
case LineAttributes::thick:
|
||||
case EdgeWidth::thick:
|
||||
ui->rbThick->setChecked(true);
|
||||
break;
|
||||
default:
|
||||
ui->rbMiddle->setChecked(true);
|
||||
}
|
||||
|
||||
LineAttributes::edgeColor lineColor = activeAttributes->getColor();
|
||||
switch(lineColor){
|
||||
case LineAttributes::black:
|
||||
int lineColor = activeAttributes->getColor();
|
||||
switch(EdgeColor(lineColor)) {
|
||||
case EdgeColor::black:
|
||||
ui->rbBlack->setChecked(true);
|
||||
break;
|
||||
case LineAttributes::grey:
|
||||
case EdgeColor::grey:
|
||||
ui->rbGrey->setChecked(true);
|
||||
break;
|
||||
case LineAttributes::red:
|
||||
case EdgeColor::red:
|
||||
ui->rbRed->setChecked(true);
|
||||
break;
|
||||
case LineAttributes::green:
|
||||
case EdgeColor::green:
|
||||
ui->rbGreen->setChecked(true);
|
||||
break;
|
||||
case LineAttributes::blue:
|
||||
case EdgeColor::blue:
|
||||
ui->rbBlue->setChecked(true);
|
||||
break;
|
||||
case LineAttributes::magenta:
|
||||
case EdgeColor::magenta:
|
||||
ui->rbMagenta->setChecked(true);
|
||||
break;
|
||||
case LineAttributes::cyan:
|
||||
case EdgeColor::cyan:
|
||||
ui->rbCyan->setChecked(true);
|
||||
break;
|
||||
case LineAttributes::yellow:
|
||||
case EdgeColor::yellow:
|
||||
ui->rbYellow->setChecked(true);
|
||||
break;
|
||||
default:
|
||||
@@ -274,60 +297,60 @@ void TaskSelectLineAttributes::setUiEdit()
|
||||
bool TaskSelectLineAttributes::accept()
|
||||
{
|
||||
if (ui->rbSolid->isChecked()){
|
||||
activeAttributes->setStyle(LineAttributes::solid);
|
||||
activeAttributes->setStyle(int(EdgeStyle::solid));
|
||||
}
|
||||
else if (ui->rbDashed->isChecked()){
|
||||
activeAttributes->setStyle(LineAttributes::dashed);
|
||||
activeAttributes->setStyle(int(EdgeStyle::dashed));
|
||||
}
|
||||
else if (ui->rbDotted->isChecked()){
|
||||
activeAttributes->setStyle(LineAttributes::dotted);
|
||||
activeAttributes->setStyle(int(EdgeStyle::dotted));
|
||||
}
|
||||
else if (ui->rbDashDotted->isChecked()){
|
||||
activeAttributes->setStyle(LineAttributes::dashdotted);
|
||||
activeAttributes->setStyle(int(EdgeStyle::dashdotted));
|
||||
}
|
||||
else {
|
||||
activeAttributes->setStyle(LineAttributes::dashdotted);
|
||||
activeAttributes->setStyle(int(EdgeStyle::dashdotted));
|
||||
}
|
||||
|
||||
if (ui->rbThin->isChecked()){
|
||||
activeAttributes->setWidth(LineAttributes::small);
|
||||
activeAttributes->setWidth(int(EdgeWidth::small));
|
||||
}
|
||||
else if (ui->rbMiddle->isChecked()){
|
||||
activeAttributes->setWidth(LineAttributes::middle);
|
||||
activeAttributes->setWidth(int(EdgeWidth::middle));
|
||||
}
|
||||
else if (ui->rbThick->isChecked()){
|
||||
activeAttributes->setWidth(LineAttributes::thick);
|
||||
activeAttributes->setWidth(int(EdgeWidth::thick));
|
||||
}
|
||||
else {
|
||||
activeAttributes->setWidth(LineAttributes::middle);
|
||||
activeAttributes->setWidth(int(EdgeWidth::middle));
|
||||
}
|
||||
|
||||
if (ui->rbBlack->isChecked()){
|
||||
activeAttributes->setColor(LineAttributes::black);
|
||||
activeAttributes->setColor(int(EdgeColor::black));
|
||||
}
|
||||
else if (ui->rbGrey->isChecked()){
|
||||
activeAttributes->setColor(LineAttributes::grey);
|
||||
activeAttributes->setColor(int(EdgeColor::grey));
|
||||
}
|
||||
else if (ui->rbRed->isChecked()){
|
||||
activeAttributes->setColor(LineAttributes::red);
|
||||
activeAttributes->setColor(int(EdgeColor::red));
|
||||
}
|
||||
else if (ui->rbGreen->isChecked()){
|
||||
activeAttributes->setColor(LineAttributes::green);
|
||||
activeAttributes->setColor(int(EdgeColor::green));
|
||||
}
|
||||
else if (ui->rbBlue->isChecked()){
|
||||
activeAttributes->setColor(LineAttributes::blue);
|
||||
activeAttributes->setColor(int(EdgeColor::blue));
|
||||
}
|
||||
else if (ui->rbMagenta->isChecked()){
|
||||
activeAttributes->setColor(LineAttributes::magenta);
|
||||
activeAttributes->setColor(int(EdgeColor::magenta));
|
||||
}
|
||||
else if (ui->rbCyan->isChecked()){
|
||||
activeAttributes->setColor(LineAttributes::cyan);
|
||||
activeAttributes->setColor(int(EdgeColor::cyan));
|
||||
}
|
||||
else if (ui->rbYellow->isChecked()){
|
||||
activeAttributes->setColor(LineAttributes::yellow);
|
||||
activeAttributes->setColor(int(EdgeColor::yellow));
|
||||
}
|
||||
else {
|
||||
activeAttributes->setColor(LineAttributes::black);
|
||||
activeAttributes->setColor(int(EdgeColor::black));
|
||||
}
|
||||
|
||||
double cascadeSpacing = ui->sbSpacing->value();
|
||||
@@ -338,16 +361,14 @@ bool TaskSelectLineAttributes::accept()
|
||||
|
||||
bool TaskSelectLineAttributes::reject()
|
||||
{
|
||||
//there's nothing to do.
|
||||
Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.resetEdit()");
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
// TaskDlgSelectLineAttributes
|
||||
//===========================================================================
|
||||
|
||||
TaskDlgSelectLineAttributes::TaskDlgSelectLineAttributes(LineAttributes * ptActiveAttributes)
|
||||
TaskDlgSelectLineAttributes::TaskDlgSelectLineAttributes(lineAttributes * ptActiveAttributes)
|
||||
: TaskDialog()
|
||||
{
|
||||
widget = new TaskSelectLineAttributes(ptActiveAttributes);
|
||||
@@ -388,4 +409,4 @@ bool TaskDlgSelectLineAttributes::reject()
|
||||
}
|
||||
|
||||
|
||||
#include <Mod/TechDraw/Gui/moc_TaskSelectLineAttributes.cpp>
|
||||
#include <Mod/TechDraw/Gui/moc_TaskSelectLineAttributes.cpp>
|
||||
|
||||
Reference in New Issue
Block a user