Skip to content

Commit

Permalink
Merge branch 'drawEngine'
Browse files Browse the repository at this point in the history
  • Loading branch information
xinhecuican committed Jan 15, 2024
2 parents 07ec262 + 48081be commit b097afc
Show file tree
Hide file tree
Showing 212 changed files with 6,322 additions and 8,175 deletions.
31 changes: 5 additions & 26 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,11 @@ assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.
**版本**

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
- 操作系统版本:
- 程序版本:

**Expected behavior**
A clear and concise description of what you expected to happen.
**问题**

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

**Additional context**
Add any other context about the problem here.
简要描述你的操作过程,最好可以提供日志文件。日志文件在Data/Temp/log.txt
10 changes: 0 additions & 10 deletions .github/ISSUE_TEMPLATE/custom.md

This file was deleted.

12 changes: 4 additions & 8 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,10 @@ assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**描述你想增加或实现的功能**

**Describe the solution you'd like**
A clear and concise description of what you want to happen.
...

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**描述目前可能的思路**

**Additional context**
Add any other context or screenshots about the feature request here.
...
8 changes: 4 additions & 4 deletions Base/WindowBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
#define WINDOW_BASE_H
#include<QMainWindow>
#include<QDebug>
#include "Helper/Reflect.h"
#include "Helper/mstring.h"
#include "Manager/uimanager.h"
#include "Manager/KeyManager.h"
#include "../Helper/Reflect.h"
#include "../Helper/mstring.h"
#include "../Manager/uimanager.h"
#include "../Manager/KeyManager.h"

class WindowBase : public QMainWindow {
public:
Expand Down
3 changes: 1 addition & 2 deletions Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ PROJECT_NAME = "简截"
# could be handy for archiving the generated documentation or if some version
# control system is used.

PROJECT_NUMBER = 0.7.5
# With the PROJECT_LOGO tag one can specify a logo or an icon that is included
PROJECT_NUMBER = 0.8.0# With the PROJECT_LOGO tag one can specify a logo or an icon that is included
# in the documentation. The maximum height of the logo should not exceed 55
# pixels and the maximum width should not exceed 200 pixels. Doxygen will copy
# the logo to the output directory.
Expand Down
213 changes: 213 additions & 0 deletions GraphicsScene/Container/blurlayercontainer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
#include "blurlayercontainer.h"
#include <QSpinBox>
#include "../paintarea.h"
#include "../../Helper/mstring.h"
#include "../../Helper/imagehelper.h"
#include <QButtonGroup>
#include <QDebug>
#include <QStandardItemModel>

BlurLayerContainer::BlurLayerContainer(PaintArea* area) :
LayerContainer(area),
type(0),
windowSize(10),
valid(false)
{
blurLayer = new BlurLayer("blur", area, area->getRootLayer());
blurLayer->setEnable(false);
grabcutLayer = new GrabcutLayer("grabcut", area, area->getRootLayer());
maskColorLayer = new MaskColorLayer("maskColor", area, area->getRootLayer());
colorPicker = new ColorPicker(area, maskColorLayer);
colorPicker->hide();
area->addLayer(blurLayer);
area->addLayer(grabcutLayer);
area->addLayer(maskColorLayer);
area->registerMouseMoveHook([=](QPointF pos){
if(type == 2 && valid){
colorPicker->setPosition(pos);
}
});
area->registerMousePressHook([=](QPointF pos){
if(type == 2 && valid){
addColor(area->getImage().pixel(pos.x(), pos.y()));
}
});
maskColorCombo = NULL;
}

QWidget* BlurLayerContainer::onValid(QWidget *widgetParent) {
valid = true;
area->setEnable(false, blurLayer->type());
if(type == 1){
grabcutLayer->setEnableShow();
grabcutLayer->setFocus();
}
else if(type == 2){
colorPicker->show();
}
if(!initWidget(widgetParent)){
QButtonGroup* group = new QButtonGroup(widgetParent);
group->setExclusive(true);
QToolButton* mosaicButton = new QToolButton(widgetParent);
mosaicButton->setToolTip(MString::search("{capture_mosaic}马赛克"));
mosaicButton->setIcon(ImageHelper::getIcon("blur"));
mosaicButton->setIconSize(QSize(DEFAULT_ICON_SIZE, DEFAULT_ICON_SIZE));
mosaicButton->setCheckable(true);
mosaicButton->setChecked(true);
group->addButton(mosaicButton, 0);
QToolButton* grabcutButton = new QToolButton(widgetParent);
grabcutButton->setToolTip(MString::search("{QbgMYc4u4H}透明"));
grabcutButton->setIcon(ImageHelper::getIcon("mosaic"));
grabcutButton->setIconSize(QSize(DEFAULT_ICON_SIZE, DEFAULT_ICON_SIZE));
grabcutButton->setCheckable(true);
group->addButton(grabcutButton, 1);
QToolButton* colorMaskButton = new QToolButton(widgetParent);
colorMaskButton->setIcon(ImageHelper::getIcon("color_mask"));
colorMaskButton->setIconSize(QSize(DEFAULT_ICON_SIZE, DEFAULT_ICON_SIZE));
colorMaskButton->setCheckable(true);
group->addButton(colorMaskButton, 2);

QSpinBox* mosaicSize = new QSpinBox(widgetParent);
mosaicSize->setRange(2, 30);
mosaicSize->setValue(4);
mosaicSize->setSingleStep(2);
mosaicSize->setAccelerated(true);
mosaicSize->setWrapping(true);
mosaicSize->setKeyboardTracking(true);
connect(mosaicSize, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, [=](int value) {
windowSize = value;
});

helpButton = new QToolButton(widgetParent);
helpButton->setIcon(ImageHelper::getIcon("help"));
helpButton->setToolTip(MString::search("{9VxwER0qFT}左键选择保留区域") +
"\n" +
MString::search("{6IqemrYceD}右键选择要删除的颜色"));
helpButton->hide();

maskColorCombo = new QComboBox(widgetParent);
maskColorCombo->setEditable(false);
maskColorCombo->setAutoFillBackground(true);
connect(maskColorCombo, static_cast<void (QComboBox::*)(const QString &text)>(&QComboBox::currentIndexChanged),
this, [=](const QString &text){
int splitter1 = text.indexOf(',');
int splitter2 = text.indexOf(',', splitter1+1);
int red = text.mid(0, splitter1).toInt();
int green = text.mid(splitter1+1, splitter2-splitter1-1).toInt();
int blue = text.mid(splitter2+1).toInt();
maskColorCombo->setStyleSheet(QString("background-color: rgb(%1,%2,%3)").arg(red).arg(green).arg(blue));
});
maskColorCombo->hide();
removeButton = new QToolButton(widgetParent);
removeButton->setIcon(ImageHelper::getIcon("delete"));
connect(removeButton, &QToolButton::clicked, this, [=](){
if(maskColorCombo->count()<=0){
return;
}
int index = maskColorCombo->currentIndex();
maskColorCombo->removeItem(index);
maskColorLayer->removeMaskColor(index);
});
removeButton->hide();

addWidget(mosaicButton);
addWidget(grabcutButton);
addWidget(colorMaskButton);
addWidget(mosaicSize);
addWidget(helpButton);
addWidget(maskColorCombo);
addWidget(removeButton);
connect(group, static_cast<void (QButtonGroup::*)(int)>(&QButtonGroup::buttonClicked),
this, [=](int id) {
type = id;
mosaicSize->hide();
colorPicker->hide();
helpButton->hide();
maskColorCombo->hide();
removeButton->hide();
if(type == 0){
mosaicSize->show();
}
else if(type == 1){
grabcutLayer->setFocus();
grabcutLayer->setEnableShow();
helpButton->show();
}
else{
maskColorCombo->show();
removeButton->show();
colorPicker->show();
}
widgetParent->adjustSize();
});
}
return widget;
}

void BlurLayerContainer::onInvalid(){
valid = false;
colorPicker->hide();
}

void BlurLayerContainer::layerMousePressEvent(QGraphicsSceneMouseEvent *event) {
if(type == 0){
blurLayer->setParameter("windowSize", windowSize);
blurLayer->addPoint(event->scenePos().toPoint());
}
else if(type == 1){
background = event->button() == Qt::RightButton;
grabcutLayer->addPoint(event->scenePos(), background, false);
}
}

void BlurLayerContainer::layerMouseMoveEvent(QGraphicsSceneMouseEvent *event) {
if(type == 0){
blurLayer->addPoint(event->scenePos().toPoint());
}
else if(type == 1){
grabcutLayer->addPoint(event->scenePos(), background, false);
}
}

void BlurLayerContainer::layerMouseReleaseEvent(QGraphicsSceneMouseEvent *event) {
if(type == 0){
blurLayer->addPoint(event->scenePos().toPoint());
}
else if(type == 1){
grabcutLayer->addPoint(event->scenePos(), background, true);
}
}

int BlurLayerContainer::getCurrentType(){
return type;
}

void BlurLayerContainer::addColor(QColor color){
maskColorCombo->addItem(QString::number(color.red())+","+QString::number(color.green())
+","+QString::number(color.blue()));
QStandardItemModel* model = qobject_cast<QStandardItemModel*>(maskColorCombo->model());
model->item(maskColorCombo->count()-1)->setBackground(color);
int red, green, blue;
color.getRgb(&red, &green, &blue);
red = red + (red - 127) * 0.5;
red = (red < 0x00) ? 0xff+red : (red > 0xff) ? red-0xff : red;
green = green + (green - 127) * 0.5;
green = (green < 0x00) ? 0xff+green : (green > 0xff) ? green - 0xff : green;
blue = blue + (blue - 127) * 0.5;
blue = (blue < 0x00) ? 0xff+blue : (blue > 0xff) ? blue - 0xff : blue;
model->item(maskColorCombo->count()-1)->setForeground(QColor(red, green, blue));
maskColorCombo->setCurrentIndex(maskColorCombo->count()-1);
maskColorLayer->addMaskColor(color);
widget->parentWidget()->adjustSize();
}

void BlurLayerContainer::reset(){
if(maskColorCombo != NULL){
colorPicker->hide();
helpButton->hide();
maskColorCombo->hide();
removeButton->hide();
maskColorCombo->clear();
type = 0;
}
}
39 changes: 39 additions & 0 deletions GraphicsScene/Container/blurlayercontainer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#ifndef BLURLAYERCONTAINER_H
#define BLURLAYERCONTAINER_H
#include "layercontainer.h"
#include "../Layer/blurlayer.h"
#include "../Layer/grabcutlayer.h"
#include "../Layer/maskcolorlayer.h"
#include <QComboBox>
#include "../Widgets/colorpicker.h"

class BlurLayerContainer : public LayerContainer
{
public:
BlurLayerContainer(PaintArea* area);
void layerMousePressEvent(QGraphicsSceneMouseEvent *event) override;
void layerMouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
void layerMouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;
QWidget * onValid(QWidget *widgetParent) override;
void onInvalid() override;
int getCurrentType();
void reset() override;

private:
void addColor(QColor color);

private:
BlurLayer* blurLayer;
GrabcutLayer* grabcutLayer;
MaskColorLayer* maskColorLayer;
int type;
int windowSize;
bool background;
QComboBox* maskColorCombo;
ColorPicker* colorPicker;
bool valid;
QToolButton* helpButton;
QToolButton* removeButton;
};

#endif // BLURLAYERCONTAINER_H
Loading

0 comments on commit b097afc

Please sign in to comment.