Commit c6ab4d59 authored by Arnaud Durand's avatar Arnaud Durand

BUG: event tabchanged triggered on windows deactivate drawing image

parent 92a43130
......@@ -2,6 +2,8 @@
bool IO::readTML(Scene* scene_, View* view_, QString filename_)
{
QDir dir = QDir(filename_);
tinyxml2::XMLDocument* xmlDoc = new tinyxml2::XMLDocument();
if(xmlDoc->LoadFile(filename_.toStdString().c_str())==false)
......@@ -21,6 +23,8 @@ bool IO::readTML(Scene* scene_, View* view_, QString filename_)
bool IO::saveTML(Scene* scene_, View* view_, QString filename_)
{
QDir dir = QDir(filename_);
QList<QGraphicsItem*> listItems = scene_->items();
tinyxml2::XMLDocument* xmlDoc = new tinyxml2::XMLDocument();
......@@ -82,10 +86,10 @@ bool IO::saveTML(Scene* scene_, View* view_, QString filename_)
{
// If the shape is not part of a block, burn it. All those which are part of a block are burned through the writeTMLBlock method
if(shape->getType()==1 and (dynamic_cast<BlockItem*>(item))->QGraphicsItemGroup::parentItem()==0)
IO::writeTMLBlock(listItems, item, xmlDoc, elementShapes);
IO::writeTMLBlock(dir, listItems, item, xmlDoc, elementShapes);
// If standard feature
else if(shape->getType()!=1 and shape->parentItem() == 0)
IO::writeTMLFeature(item, xmlDoc, elementShapes);
IO::writeTMLFeature(dir, item, xmlDoc, elementShapes);
}
}
......@@ -98,7 +102,7 @@ bool IO::saveTML(Scene* scene_, View* view_, QString filename_)
return false;
}
void IO::writeTMLBlock(QList<QGraphicsItem*>& listItems_, QGraphicsItem* item_, tinyxml2::XMLDocument* xmlDoc_, tinyxml2::XMLElement* elementShapes_)
void IO::writeTMLBlock(QDir dir_, QList<QGraphicsItem*>& listItems_, QGraphicsItem* item_, tinyxml2::XMLDocument* xmlDoc_, tinyxml2::XMLElement* elementShapes_)
{
// Block header
tinyxml2::XMLElement *elementBlock;
......@@ -120,13 +124,13 @@ void IO::writeTMLBlock(QList<QGraphicsItem*>& listItems_, QGraphicsItem* item_,
if((dynamic_cast<ShapeItem*>(childItem))->getType()==1)
{
listItems_.removeAll(childItem);
IO::writeTMLBlock(listItems_, childItem, xmlDoc_, elementBlock);
IO::writeTMLBlock(dir_, listItems_, childItem, xmlDoc_, elementBlock);
}
// If normal feature
else
{
listItems_.removeAll(childItem);
IO::writeTMLFeature(childItem, xmlDoc_, elementBlock);
IO::writeTMLFeature(dir_, childItem, xmlDoc_, elementBlock);
}
}
......@@ -137,7 +141,7 @@ void IO::writeTMLBlock(QList<QGraphicsItem*>& listItems_, QGraphicsItem* item_,
elementBlock->InsertEndChild(elementNode);
}
void IO::writeTMLFeature(QGraphicsItem* item_, tinyxml2::XMLDocument* xmlDoc_, tinyxml2::XMLElement* elementShapes_)
void IO::writeTMLFeature(QDir dir_, QGraphicsItem* item_, tinyxml2::XMLDocument* xmlDoc_, tinyxml2::XMLElement* elementShapes_)
{
ShapeItem* shape = dynamic_cast<ShapeItem*>(item_);
......@@ -158,7 +162,7 @@ void IO::writeTMLFeature(QGraphicsItem* item_, tinyxml2::XMLDocument* xmlDoc_, t
ImageItem* image = dynamic_cast<ImageItem*>(shape);
tinyxml2::XMLElement *elementImage = xmlDoc_->NewElement("image");
elementImage->SetAttribute("filename", image->getFilename().toStdString().c_str());
elementImage->SetAttribute("filename", dir_.relativeFilePath(image->getFilename()).toStdString().c_str());
elementImage->SetAttribute("scale", image->ShapeItem::scale());
elementImage->SetAttribute("rotation", image->ShapeItem::rotation());
elementShape->InsertEndChild(elementImage);
......
......@@ -14,8 +14,8 @@ namespace IO
bool saveTML(Scene*, View*, QString);
bool readTML(Scene*, View*, QString);
void writeTMLFeature(QGraphicsItem*, tinyxml2::XMLDocument*, tinyxml2::XMLElement*);
void writeTMLBlock(QList<QGraphicsItem*>&, QGraphicsItem*, tinyxml2::XMLDocument*, tinyxml2::XMLElement*);
void writeTMLFeature(QDir, QGraphicsItem*, tinyxml2::XMLDocument*, tinyxml2::XMLElement*);
void writeTMLBlock(QDir, QList<QGraphicsItem*>&, QGraphicsItem*, tinyxml2::XMLDocument*, tinyxml2::XMLElement*);
}
#endif
......@@ -670,9 +670,6 @@ void Scene::setSceneText(bool status_)
void Scene::setSceneImage(bool status_)
{
clearSelection();
disableDrawingAll();
if(status_==false)
{
m_parentWindow->setImageButton(false);
......@@ -1144,6 +1141,11 @@ void Scene::initRectConstruction()
m_drawingState = 1;
}
enum drawingFunction::state Scene::getActiveFunction() const
{
return m_activeFunction;
}
Scene::~Scene()
{
foreach(Layer* layer_, m_layerList)
......
......@@ -50,6 +50,7 @@ class Scene : public QGraphicsScene
void changeLayerSelectedItems(QString);
void deleteItemsLayer(int);
enum drawingFunction::state getActiveFunction() const;
bool isDrawingActive();
void disableDrawingAll();
......
......@@ -284,8 +284,13 @@ void Window::slot_subWindowActivated()
{
if(QMdiSubWindow *mySubWindow = m_centralArea->activeSubWindow())
{
m_scene->disableDrawingAll();
m_scene->clearSelection();
// To avoid disabling the drawing while selecting an image to insert
if(m_scene->getActiveFunction() != drawingFunction::drawImage)
{
m_scene->disableDrawingAll();
m_scene->clearSelection();
}
m_view = qobject_cast<View *>(mySubWindow->widget());
m_scene = m_view->scene();
m_layerList = m_scene->getListLayers();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment