Added image objects to xml creator and parser.
This commit is contained in:
@@ -505,7 +505,8 @@ void ObjectEditor::onImageFileButtonClicked()
|
|||||||
|
|
||||||
void ObjectEditor::onImageKeySelected( QString key )
|
void ObjectEditor::onImageKeySelected( QString key )
|
||||||
{
|
{
|
||||||
qDebug() << "Key = " << key;
|
mUndoRedoModel->checkpoint( tr("Set image") );
|
||||||
|
mObject->setFilenameNode( TextNode( true, key ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -142,6 +142,10 @@ XmlLabelCreator::addObjectsToNode( QDomElement &parent, const QList<LabelModelOb
|
|||||||
{
|
{
|
||||||
createObjectLineNode( parent, lineObject );
|
createObjectLineNode( parent, lineObject );
|
||||||
}
|
}
|
||||||
|
else if ( LabelModelImageObject* imageObject = dynamic_cast<LabelModelImageObject*>(object) )
|
||||||
|
{
|
||||||
|
createObjectImageNode( parent, imageObject );
|
||||||
|
}
|
||||||
else if ( LabelModelTextObject* textObject = dynamic_cast<LabelModelTextObject*>(object) )
|
else if ( LabelModelTextObject* textObject = dynamic_cast<LabelModelTextObject*>(object) )
|
||||||
{
|
{
|
||||||
createObjectTextNode( parent, textObject );
|
createObjectTextNode( parent, textObject );
|
||||||
@@ -280,7 +284,34 @@ XmlLabelCreator::createObjectLineNode( QDomElement &parent, const LabelModelLine
|
|||||||
void
|
void
|
||||||
XmlLabelCreator::createObjectImageNode( QDomElement &parent, const LabelModelImageObject* object )
|
XmlLabelCreator::createObjectImageNode( QDomElement &parent, const LabelModelImageObject* object )
|
||||||
{
|
{
|
||||||
// TODO
|
QDomDocument doc = parent.ownerDocument();
|
||||||
|
QDomElement node = doc.createElement( "Object-image" );
|
||||||
|
parent.appendChild( node );
|
||||||
|
|
||||||
|
/* position attrs */
|
||||||
|
glabels::XmlUtil::setLengthAttr( node, "x", object->x0() );
|
||||||
|
glabels::XmlUtil::setLengthAttr( node, "y", object->y0() );
|
||||||
|
|
||||||
|
/* size attrs */
|
||||||
|
glabels::XmlUtil::setLengthAttr( node, "w", object->w() );
|
||||||
|
glabels::XmlUtil::setLengthAttr( node, "h", object->h() );
|
||||||
|
|
||||||
|
/* file attrs */
|
||||||
|
glabels::XmlUtil::setLengthAttr( node, "line_width", object->lineWidth() );
|
||||||
|
if ( object->filenameNode().isField() )
|
||||||
|
{
|
||||||
|
glabels::XmlUtil::setStringAttr( node, "src_field", object->filenameNode().data() );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
glabels::XmlUtil::setStringAttr( node, "src", object->filenameNode().data() );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* affine attrs */
|
||||||
|
createAffineAttrs( node, object );
|
||||||
|
|
||||||
|
/* shadow attrs */
|
||||||
|
createShadowAttrs( node, object );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -25,9 +25,9 @@
|
|||||||
#include "LabelModelBoxObject.h"
|
#include "LabelModelBoxObject.h"
|
||||||
#include "LabelModelEllipseObject.h"
|
#include "LabelModelEllipseObject.h"
|
||||||
#include "LabelModelLineObject.h"
|
#include "LabelModelLineObject.h"
|
||||||
|
#include "LabelModelImageObject.h"
|
||||||
#include "LabelModelTextObject.h"
|
#include "LabelModelTextObject.h"
|
||||||
//#include "LabelObjectImage.h"
|
//#include "LabelModelBarcodeObject.h"
|
||||||
//#include "LabelObjectBarcode.h"
|
|
||||||
#include "EnumUtil.h"
|
#include "EnumUtil.h"
|
||||||
#include "Merge/Factory.h"
|
#include "Merge/Factory.h"
|
||||||
#include "libglabels/XmlTemplateParser.h"
|
#include "libglabels/XmlTemplateParser.h"
|
||||||
@@ -284,11 +284,11 @@ XmlLabelParser::parseObjects( const QDomElement &node )
|
|||||||
{
|
{
|
||||||
list.append( parseObjectTextNode( child.toElement() ) );
|
list.append( parseObjectTextNode( child.toElement() ) );
|
||||||
}
|
}
|
||||||
#if 0
|
|
||||||
else if ( tagName == "Object-image" )
|
else if ( tagName == "Object-image" )
|
||||||
{
|
{
|
||||||
list.append( parseObjectImageNode( child.toElement() ) );
|
list.append( parseObjectImageNode( child.toElement() ) );
|
||||||
}
|
}
|
||||||
|
#if 0
|
||||||
else if ( tagName == "Object-barcode" )
|
else if ( tagName == "Object-barcode" )
|
||||||
{
|
{
|
||||||
list.append( parseObjectBarcodeNode( child.toElement() ) );
|
list.append( parseObjectBarcodeNode( child.toElement() ) );
|
||||||
@@ -445,7 +445,35 @@ XmlLabelParser::parseObjectLineNode( const QDomElement &node )
|
|||||||
LabelModelImageObject*
|
LabelModelImageObject*
|
||||||
XmlLabelParser::parseObjectImageNode( const QDomElement &node )
|
XmlLabelParser::parseObjectImageNode( const QDomElement &node )
|
||||||
{
|
{
|
||||||
return 0;
|
using namespace glabels;
|
||||||
|
|
||||||
|
LabelModelImageObject* object = new LabelModelImageObject();
|
||||||
|
|
||||||
|
|
||||||
|
/* position attrs */
|
||||||
|
object->setX0( XmlUtil::getLengthAttr( node, "x", 0.0 ) );
|
||||||
|
object->setY0( XmlUtil::getLengthAttr( node, "y", 0.0 ) );
|
||||||
|
|
||||||
|
/* size attrs */
|
||||||
|
object->setW( XmlUtil::getLengthAttr( node, "w", 0 ) );
|
||||||
|
object->setH( XmlUtil::getLengthAttr( node, "h", 0 ) );
|
||||||
|
|
||||||
|
/* file attrs */
|
||||||
|
{
|
||||||
|
QString key = XmlUtil::getStringAttr( node, "src_field", "" );
|
||||||
|
bool field_flag = !key.isEmpty();
|
||||||
|
QString filename = XmlUtil::getStringAttr( node, "src", "" );
|
||||||
|
|
||||||
|
object->setFilenameNode( TextNode( field_flag, field_flag ? key : filename ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
/* affine attrs */
|
||||||
|
parseAffineAttrs( node, object );
|
||||||
|
|
||||||
|
/* shadow attrs */
|
||||||
|
parseShadowAttrs( node, object );
|
||||||
|
|
||||||
|
return object;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -541,10 +569,10 @@ XmlLabelParser::parseAffineAttrs( const QDomElement &node, LabelModelObject* obj
|
|||||||
|
|
||||||
double a[6];
|
double a[6];
|
||||||
|
|
||||||
a[0] = XmlUtil::getDoubleAttr( node, "a0", 0.0 );
|
a[0] = XmlUtil::getDoubleAttr( node, "a0", 1.0 );
|
||||||
a[1] = XmlUtil::getDoubleAttr( node, "a1", 0.0 );
|
a[1] = XmlUtil::getDoubleAttr( node, "a1", 0.0 );
|
||||||
a[2] = XmlUtil::getDoubleAttr( node, "a2", 0.0 );
|
a[2] = XmlUtil::getDoubleAttr( node, "a2", 0.0 );
|
||||||
a[3] = XmlUtil::getDoubleAttr( node, "a3", 0.0 );
|
a[3] = XmlUtil::getDoubleAttr( node, "a3", 1.0 );
|
||||||
a[4] = XmlUtil::getDoubleAttr( node, "a4", 0.0 );
|
a[4] = XmlUtil::getDoubleAttr( node, "a4", 0.0 );
|
||||||
a[5] = XmlUtil::getDoubleAttr( node, "a5", 0.0 );
|
a[5] = XmlUtil::getDoubleAttr( node, "a5", 0.0 );
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user