|
@@ -12,6 +12,7 @@ MaterialBoxGraphicsView::MaterialBoxGraphicsView(QGraphicsScene* scene, QWidget*
|
|
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
|
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
|
setVerticalScrollBar(nullptr);
|
|
setVerticalScrollBar(nullptr);
|
|
setDragMode(QGraphicsView::NoDrag);
|
|
setDragMode(QGraphicsView::NoDrag);
|
|
|
|
+
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
@@ -22,7 +23,7 @@ void MaterialBoxGraphicsView::mousePressEvent(QMouseEvent* event){
|
|
clearSeleted();
|
|
clearSeleted();
|
|
selectedLeftItem = dynamic_cast<MaterialBoxDie*>(item);
|
|
selectedLeftItem = dynamic_cast<MaterialBoxDie*>(item);
|
|
selectedLeftItem->setLeftSelected(true);
|
|
selectedLeftItem->setLeftSelected(true);
|
|
- qDebug() << "current row" << selectedLeftItem->getRow();
|
|
|
|
|
|
+
|
|
}else{
|
|
}else{
|
|
clearSeleted();
|
|
clearSeleted();
|
|
return;
|
|
return;
|
|
@@ -36,8 +37,9 @@ void MaterialBoxGraphicsView::mousePressEvent(QMouseEvent* event){
|
|
clearSeleted();
|
|
clearSeleted();
|
|
selectedRightItem = dynamic_cast<MaterialBoxDie*>(item);
|
|
selectedRightItem = dynamic_cast<MaterialBoxDie*>(item);
|
|
selectedRightItem->setRightSelected(true);
|
|
selectedRightItem->setRightSelected(true);
|
|
- qDebug()<<selectedRightItem->getRow();
|
|
|
|
- emit layerRightClicked(selectedRightItem->getRow()+1);
|
|
|
|
|
|
+ qDebug()<<selectedRightItem->getCurrentLayer();
|
|
|
|
+ m_pCViewInterface->GetViewMatrix()->MoveMaterialBoxToiLayers(selectedRightItem->getCurrentLayer());
|
|
|
|
+
|
|
|
|
|
|
}else{
|
|
}else{
|
|
return;
|
|
return;
|
|
@@ -45,6 +47,9 @@ void MaterialBoxGraphicsView::mousePressEvent(QMouseEvent* event){
|
|
}
|
|
}
|
|
QGraphicsView::mousePressEvent(event);
|
|
QGraphicsView::mousePressEvent(event);
|
|
}
|
|
}
|
|
|
|
+void MaterialBoxGraphicsView::setCViewInterface(ns_module::CViewInterface* CViewInterface) {
|
|
|
|
+ m_pCViewInterface = CViewInterface;
|
|
|
|
+}
|
|
void MaterialBoxGraphicsView::mouseReleaseEvent(QMouseEvent* event){
|
|
void MaterialBoxGraphicsView::mouseReleaseEvent(QMouseEvent* event){
|
|
if (event->button() == Qt::LeftButton) {
|
|
if (event->button() == Qt::LeftButton) {
|
|
setCursor(Qt::ArrowCursor); // 松开时恢复为箭头
|
|
setCursor(Qt::ArrowCursor); // 松开时恢复为箭头
|
|
@@ -76,8 +81,8 @@ void BackgroundRect::paint(QPainter *painter, const QStyleOptionGraphicsItem *op
|
|
painter->drawRect(m_containerWidthdp, m_containerHeightdp, m_containerWidth, m_containerHeight);
|
|
painter->drawRect(m_containerWidthdp, m_containerHeightdp, m_containerWidth, m_containerHeight);
|
|
}
|
|
}
|
|
|
|
|
|
-MaterialBoxDie::MaterialBoxDie(int row, int col, int status, qreal weight,qreal height, QGraphicsItem* parent)
|
|
|
|
- : QGraphicsRectItem(parent), row(row), col(col), status(status){
|
|
|
|
|
|
+MaterialBoxDie::MaterialBoxDie(int currentLayer, int status, qreal weight,qreal height, QGraphicsItem* parent)
|
|
|
|
+ : QGraphicsRectItem(parent), m_ncurrentLayer(currentLayer), status(status){
|
|
setRect(0, 0, weight, height); // 设置单元格大小
|
|
setRect(0, 0, weight, height); // 设置单元格大小
|
|
setBrush(getColorByStatus(status));
|
|
setBrush(getColorByStatus(status));
|
|
|
|
|
|
@@ -111,6 +116,6 @@ QColor MaterialBoxDie::getColorByStatus(int status){
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-int MaterialBoxDie::getRow(){
|
|
|
|
- return row;
|
|
|
|
|
|
+int MaterialBoxDie::getCurrentLayer(){
|
|
|
|
+ return m_ncurrentLayer;
|
|
}
|
|
}
|