void ViewBase::addDropShadowEffect(QWidget *widget) { auto dropShadow = new QGraphicsDropShadowEffect(widget); dropShadow->setOffset(0, 0); dropShadow->setBlurRadius(5); dropShadow->setColor(QColor(Qt::black)); widget->setGraphicsEffect(dropShadow); }
START_NAMESPACE_PATCHCANVAS CanvasBoxShadow::CanvasBoxShadow(QObject* parent) : QGraphicsDropShadowEffect(parent) { m_fakeParent = 0; setBlurRadius(20); setColor(canvas.theme->box_shadow); setOffset(0, 0); }
void QmitkOverlay::AddDropShadow(QWidget *widget) { if (m_Widget) { auto effect = new QGraphicsDropShadowEffect(widget); effect->setOffset(QPointF(1.0, 1.0)); effect->setBlurRadius(0); effect->setColor(Qt::black); widget->setGraphicsEffect(effect); } }
ClockFace::ClockFace(QGraphicsItem *parent): QGraphicsObject(parent) { scale = 100; foregroundColor = QColor("#dddddd"); shadowColor = QColor("#888888"); auto ef = new QGraphicsDropShadowEffect; ef->setXOffset(.5); ef->setYOffset(.5); ef->setBlurRadius(5); ef->setColor(shadowColor); setGraphicsEffect(ef); startTimer(10000); }
void Image::parseAttr(std::vector<std::string>* keys, std::vector<std::string>* values) { Widget::parseAttr(keys, values); for (auto i = 0; i < keys->size(); ++i) { const auto& _key = keys->at(i); const auto& _value = values->at(i); if (_key == "source" || _key == "src") { setSource(_value); } else if (_key == "texturerect" || _key == "rect") { auto _rect = ParamUtil::readRect(_value); m_renderer->setTextureRect(_rect); } else if (_key == "repeattype") { RepeatType _repeatType = RepeatType::SCALE; if (_value == "pattern") _repeatType = RepeatType::PATTERN; setRepeatType(_repeatType); } else if (_key == "filter") { FilterType _filter = FilterType::NONE; if (_value == "gray") { _filter = FilterType::GRAY; } else if (_value == "blur") { _filter = FilterType::BLUR; } setFilter(_filter); } else if (_key == "graypercent") { setGrayPercent(tina::ParamUtil::readFloat(_value)); } else if (_key == "blurradius") { setBlurRadius(tina::ParamUtil::readFloat(_value)); } else if (_key == "blursamplenum") { setBlurSampleNum(tina::ParamUtil::readFloat(_value)); } } }
int QGraphicsDropShadowEffect::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QGraphicsEffect::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 10) qt_static_metacall(this, _c, _id, _a); _id -= 10; } #ifndef QT_NO_PROPERTIES else if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< QPointF*>(_v) = offset(); break; case 1: *reinterpret_cast< qreal*>(_v) = xOffset(); break; case 2: *reinterpret_cast< qreal*>(_v) = yOffset(); break; case 3: *reinterpret_cast< qreal*>(_v) = blurRadius(); break; case 4: *reinterpret_cast< QColor*>(_v) = color(); break; } _id -= 5; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 0: setOffset(*reinterpret_cast< QPointF*>(_v)); break; case 1: setXOffset(*reinterpret_cast< qreal*>(_v)); break; case 2: setYOffset(*reinterpret_cast< qreal*>(_v)); break; case 3: setBlurRadius(*reinterpret_cast< qreal*>(_v)); break; case 4: setColor(*reinterpret_cast< QColor*>(_v)); break; } _id -= 5; } else if (_c == QMetaObject::ResetProperty) { _id -= 5; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 5; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 5; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 5; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 5; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 5; } #endif // QT_NO_PROPERTIES return _id; }
int QGraphicsBlurEffect::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QGraphicsEffect::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 4) qt_static_metacall(this, _c, _id, _a); _id -= 4; } #ifndef QT_NO_PROPERTIES else if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< qreal*>(_v) = blurRadius(); break; case 1: *reinterpret_cast<int*>(_v) = QFlag(blurHints()); break; } _id -= 2; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 0: setBlurRadius(*reinterpret_cast< qreal*>(_v)); break; case 1: setBlurHints(QFlag(*reinterpret_cast<int*>(_v))); break; } _id -= 2; } else if (_c == QMetaObject::ResetProperty) { _id -= 2; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 2; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 2; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 2; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 2; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 2; } #endif // QT_NO_PROPERTIES return _id; }
Widget::Widget(QWidget *parent, Qt::WFlags flags) : QWidget(parent, flags), getter(this) { this->setWindowFlags(Qt::FramelessWindowHint | Qt::CustomizeWindowHint); setFocusPolicy(Qt::NoFocus); this->setGeometry(0,0,QApplication::desktop()->width(),QApplication::desktop()->height()); connect(&getter, SIGNAL(imageUpdated()),SLOT(imageUpdated())); foreground = new QImage(width(), height(), QImage::Format_ARGB32); foreground->fill(foregroundColor); auto effect = new QGraphicsBlurEffect; effect->setBlurRadius(4); setGraphicsEffect(effect); checker.move(this->geometry().center()-checker.rect().center()); checker.show(); }
bool HoverShadowFilter::eventFilter(QObject *obj, QEvent *event) { switch (event->type()) { case QEvent::Enter: { auto w = qobject_cast<QWidget *>(obj); auto shadow = new QGraphicsDropShadowEffect(w); shadow->setBlurRadius(8); shadow->setOffset(0, 0); shadow->setColor(Qt::white); w->setGraphicsEffect(shadow); w->setCursor(QCursor(Qt::PointingHandCursor)); return QObject::eventFilter(obj, event); } case QEvent::Leave: { auto w = qobject_cast<QWidget *>(obj); w->graphicsEffect()->deleteLater(); w->setGraphicsEffect(nullptr); w->unsetCursor(); return QObject::eventFilter(obj, event); } default: return QObject::eventFilter(obj, event); } }
void BlurEffect::adjustForItem() { qreal y = m_baseLine - item->pos().y(); qreal radius = qBound(qreal(0.0), y / 32, qreal(16.0)); setBlurRadius(radius); }
void AutoBlend::init() { // Add widget auto toolsWidgetContainer = new QWidget(); widget = new Ui::AutoBlendWidget(); widget->setupUi(toolsWidgetContainer); widgetProxy = new QGraphicsProxyWidget(this); widgetProxy->setWidget(toolsWidgetContainer); // Place at bottom left corner auto delta = widgetProxy->sceneBoundingRect().bottomLeft() - scene()->views().front()->rect().bottomLeft(); widgetProxy->moveBy(-delta.x(), -delta.y()); // Fill categories box { for(auto cat : document->categories.keys()){ widget->categoriesBox->insertItem(widget->categoriesBox->count(), cat); } int idx = widget->categoriesBox->findText(document->categoryOf(document->firstModelName())); widget->categoriesBox->setCurrentIndex(idx); } // Create gallery of shapes gallery = new Gallery(this, QRectF(0,0,this->bounds.width(), 220)); // Create container that holds results results = new Gallery(this, QRectF(0,0, this->bounds.width(), bounds.height() - gallery->boundingRect().height()), QRectF(0,0,256,256), true); results->moveBy(0, gallery->boundingRect().height()); // Gallery on top of results gallery->setZValue(results->zValue() + 10); auto dropShadow = new QGraphicsDropShadowEffect(); dropShadow->setOffset(0, 5); dropShadow->setColor(QColor(0, 0, 0, 150)); dropShadow->setBlurRadius(10); gallery->setGraphicsEffect(dropShadow); // Connect UI with actions { connect(widget->categoriesBox, &QComboBox::currentTextChanged, [&](QString text){ document->currentCategory = text; }); connect(widget->analyzeButton, &QPushButton::pressed, [&](){ document->computePairwise(widget->categoriesBox->currentText()); }); // Default view angle { // Camera target and initial position auto camera = new Eigen::Camera(); auto frame = camera->frame(); frame.position = Eigen::Vector3f(-1, 0, 0.5); camera->setTarget(Eigen::Vector3f(0, 0, 0.5)); camera->setFrame(frame); int deltaZoom = document->extent().length() * 1.0; // Default view angle double theta1 = acos(-1) * 0.75; double theta2 = acos(-1) * 0.10; camera->rotateAroundTarget(Eigen::Quaternionf(Eigen::AngleAxisf(theta1, Eigen::Vector3f::UnitY()))); camera->zoom(-(4+deltaZoom)); camera->rotateAroundTarget(Eigen::Quaternionf(Eigen::AngleAxisf(theta2, Eigen::Vector3f::UnitX()))); auto cp = camera->position(); cameraPos = QVector3D(cp[0], cp[1], cp[2]); // Camera settings camera->setViewport(128, 128); Eigen::Matrix4f p = camera->projectionMatrix(); Eigen::Matrix4f v = camera->viewMatrix().matrix(); p.transposeInPlace(); v.transposeInPlace(); cameraMatrix = QMatrix4x4(p.data()) * QMatrix4x4(v.data()); } connect(document, &Document::categoryAnalysisDone, [=](){ if (gallery == nullptr) return; // Fill gallery gallery->clearThumbnails(); auto catModels = document->categories[document->currentCategory].toStringList(); for (auto targetName : catModels) { auto targetModel = document->cacheModel(targetName); auto t = gallery->addTextItem(targetName); QVariantMap data = t->data; data["targetName"].setValue(targetName); t->setData(data); t->setCamera(cameraPos, cameraMatrix); t->setFlag(QGraphicsItem::ItemIsSelectable); // Add parts of target shape for (auto n : targetModel->nodes){ t->addAuxMesh(toBasicMesh(targetModel->getMesh(n->id), n->vis_property["color"].value<QColor>())); } scene()->update(t->sceneBoundingRect()); } scene()->update(this->sceneBoundingRect()); QTimer::singleShot(500, [=]{ gallery->update(); }); }); // Do blend connect(widget->blendButton, SIGNAL(pressed()), SLOT(doBlend())); } }