Skip to content

Commit

Permalink
list plugin, correct print of color
Browse files Browse the repository at this point in the history
  • Loading branch information
Rallaz committed Jul 3, 2015
1 parent 7e8696e commit d1f8da7
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 5 deletions.
17 changes: 17 additions & 0 deletions librecad/src/main/doc_plugin_interface.cpp
Expand Up @@ -119,6 +119,19 @@ enum RS2::LineType convLTW::str2lt(QString s){
enum RS2::LineWidth convLTW::str2lw(QString w){
return lWidth.key(w, RS2::WidthDefault);
}
QString convLTW::intColor2str(int col){
switch (col) {
case -1:
return "BYLAYER";
break;
case -2:
return "BYBLOCK";
break;
default:
return QString::number(col >> 16) + ", " + QString::number((col >> 8)& 0xFF) + ", " + QString::number(col & 0xFF);
break;
}
}


convLTW Converter;
Expand Down Expand Up @@ -724,6 +737,10 @@ void Plugin_Entity::scale(QPointF center, QPointF factor){
this->entity = ne;
}

QString Plugin_Entity::intColor2str(int color){
return Converter.intColor2str(color);
}

Doc_plugin_interface::Doc_plugin_interface(RS_Document *d, RS_GraphicView* gv, QWidget* parent){
doc =d;
docGr =doc->getGraphic();
Expand Down
2 changes: 2 additions & 0 deletions librecad/src/main/doc_plugin_interface.h
Expand Up @@ -39,6 +39,7 @@ class convLTW
convLTW();
QString lt2str(enum RS2::LineType lt);
QString lw2str(enum RS2::LineWidth lw);
QString intColor2str(int col);
enum RS2::LineType str2lt(QString s);
enum RS2::LineWidth str2lw(QString w);
private:
Expand All @@ -62,6 +63,7 @@ class Plugin_Entity
virtual void move(QPointF offset);
virtual void rotate(QPointF center, double angle);
virtual void scale(QPointF center, QPointF factor);
virtual QString intColor2str(int color);
private:
RS_Entity* entity;
bool hasContainer;
Expand Down
5 changes: 5 additions & 0 deletions librecad/src/plugins/document_interface.h
Expand Up @@ -254,6 +254,11 @@ class Plug_Entity
*/
virtual void scale(QPointF center, QPointF factor) = 0;

//! Utility: Get color as string.
/*!
* \param color color as integer to convert as string.
*/
virtual QString intColor2str(int color) = 0;
};

//! Interface for comunicate plugins.
Expand Down
5 changes: 3 additions & 2 deletions plugins/importshp/importshp.h
Expand Up @@ -49,14 +49,15 @@ class AttribData
public:
AttribData(){
layer = "0";
color = Qt::black;
color = -1; //-1 == BYLAYER
lineType = "BYLAYER";
width = "BYLAYER";
}
QString layer;
QString lineType;
QString width;
QColor color;
int color;
// QColor color;
};

/***********/
Expand Down
6 changes: 3 additions & 3 deletions plugins/list/list.cpp
Expand Up @@ -12,7 +12,7 @@


#include <QTextEdit>
#include <QColor>
//#include <QColor>
#include <QDialogButtonBox>
#include <QVBoxLayout>
#include <cmath>
Expand Down Expand Up @@ -71,8 +71,8 @@ QString LC_List::getStrData(Plug_Entity *ent) {
//common entity data
ent->getData(&data);
strData = strCommon.arg(tr("Layer")).arg(data.value(DPI::LAYER).toString());
QColor color = data.value(DPI::COLOR).value<QColor>();
strData.append( strCommon.arg(tr("Color")).arg(color.name()));
int col = data.value(DPI::COLOR).toInt();
strData.append( strCommon.arg(tr("Color")).arg( ent->intColor2str(col) ));
strData.append( strCommon.arg(tr("Line type")).arg(data.value(DPI::LTYPE).toString()));
strData.append( strCommon.arg(tr("Line thickness")).arg(data.value(DPI::LWIDTH).toString()));
strData.append( strCommon.arg(tr("ID")).arg(data.value(DPI::EID).toLongLong()));
Expand Down

0 comments on commit d1f8da7

Please sign in to comment.