2024-02-06 06:19:53 +00:00
|
|
|
|
#include "mygraphicsscene.h"
|
|
|
|
|
|
|
|
|
|
MyGraphicsScene::MyGraphicsScene()
|
|
|
|
|
{
|
|
|
|
|
m_myGraphicsItem= new MyGraphicsItem();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MyGraphicsScene::~MyGraphicsScene()
|
|
|
|
|
{
|
|
|
|
|
if(m_myGraphicsItem != NULL)
|
|
|
|
|
{
|
|
|
|
|
delete m_myGraphicsItem;
|
|
|
|
|
m_myGraphicsItem = NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MyGraphicsScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent)
|
|
|
|
|
{
|
|
|
|
|
return QGraphicsScene::mousePressEvent(mouseEvent);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MyGraphicsScene::mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent)
|
|
|
|
|
{
|
|
|
|
|
return QGraphicsScene::mouseMoveEvent(mouseEvent);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MyGraphicsScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent)
|
|
|
|
|
{
|
|
|
|
|
return QGraphicsScene::mouseReleaseEvent(mouseEvent);
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-08 08:33:05 +00:00
|
|
|
|
void MyGraphicsScene::addItemToScene()
|
2024-02-06 06:19:53 +00:00
|
|
|
|
{
|
|
|
|
|
//绘制留边
|
|
|
|
|
this->setSceneRect(0,0,m_myGraphicsItem->boundingRect().width()+DRAWMARGINS,m_myGraphicsItem->boundingRect().height()+DRAWMARGINS);
|
|
|
|
|
//如果scene未超过graphicsView的范围,图形就是居中显示的
|
|
|
|
|
this->addItem(m_myGraphicsItem);
|
|
|
|
|
m_myGraphicsItem->moveBy(DRAWMARGINS/2.0,DRAWMARGINS/2.0);//item居中显示
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MyGraphicsScene::cleanScene()
|
|
|
|
|
{
|
|
|
|
|
if(m_myGraphicsItem != NULL)
|
|
|
|
|
{
|
|
|
|
|
this->removeItem(m_myGraphicsItem);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-15 08:49:50 +00:00
|
|
|
|
CreatPictureStr MyGraphicsScene::getPictureByDat(Marker marker,int paperWidth,int butSpace,int rightSpace,int penWidth)
|
2024-02-06 06:19:53 +00:00
|
|
|
|
{
|
2024-03-15 08:49:50 +00:00
|
|
|
|
CreatPictureStr picStr;
|
2024-02-06 06:19:53 +00:00
|
|
|
|
if(m_myGraphicsItem != NULL)
|
|
|
|
|
{
|
2024-03-15 08:49:50 +00:00
|
|
|
|
picStr = m_myGraphicsItem->getPictureByDat(marker,paperWidth,butSpace,rightSpace,penWidth);
|
2024-02-06 06:19:53 +00:00
|
|
|
|
}
|
2024-03-15 08:49:50 +00:00
|
|
|
|
return picStr;
|
2024-02-06 06:19:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-03-15 08:49:50 +00:00
|
|
|
|
CreatPictureStr MyGraphicsScene::getPictureByBmp(QPixmap pixmap,int paperWidth,int butSpace,int rightSpace,int penWidth)
|
2024-03-08 08:33:05 +00:00
|
|
|
|
{
|
2024-03-15 08:49:50 +00:00
|
|
|
|
CreatPictureStr picStr;
|
2024-03-08 08:33:05 +00:00
|
|
|
|
if(m_myGraphicsItem != NULL)
|
|
|
|
|
{
|
2024-03-15 08:49:50 +00:00
|
|
|
|
picStr = m_myGraphicsItem->getPictureByBmp(pixmap,paperWidth,butSpace,rightSpace,penWidth);
|
2024-03-08 08:33:05 +00:00
|
|
|
|
}
|
2024-03-15 08:49:50 +00:00
|
|
|
|
return picStr;
|
2024-03-08 08:33:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MyGraphicsScene::swithSceneByPic(QPicture pic)
|
2024-02-06 06:19:53 +00:00
|
|
|
|
{
|
|
|
|
|
if(m_myGraphicsItem != NULL)
|
|
|
|
|
{
|
2024-03-08 08:33:05 +00:00
|
|
|
|
this->clear();
|
2024-02-06 06:19:53 +00:00
|
|
|
|
m_myGraphicsItem->setPicture(pic);
|
|
|
|
|
this->addItem(m_myGraphicsItem);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-15 08:49:50 +00:00
|
|
|
|
void MyGraphicsScene::reflushBlockScene(QPoint p)
|
2024-02-06 06:19:53 +00:00
|
|
|
|
{
|
|
|
|
|
if(m_myGraphicsItem != NULL)
|
|
|
|
|
{
|
|
|
|
|
m_myGraphicsItem->reflushBlockPos(p);
|
|
|
|
|
}
|
|
|
|
|
}
|