void InstrumentWindowMaskTab::init() { connect(m_instrumentDisplay->getSurface(),SIGNAL(shapeCreated()),this,SLOT(shapeCreated())); connect(m_instrumentDisplay->getSurface(),SIGNAL(shapeSelected()),this,SLOT(shapeSelected())); connect(m_instrumentDisplay->getSurface(),SIGNAL(shapesDeselected()),this,SLOT(shapesDeselected())); connect(m_instrumentDisplay->getSurface(),SIGNAL(shapeChanged()),this,SLOT(shapeChanged())); }
/** * Initialize the tab when new projection surface is created. */ void InstrumentWindowMaskTab::initSurface() { connect(m_instrWindow->getSurface().get(),SIGNAL(shapeCreated()),this,SLOT(shapeCreated())); connect(m_instrWindow->getSurface().get(),SIGNAL(shapeSelected()),this,SLOT(shapeSelected())); connect(m_instrWindow->getSurface().get(),SIGNAL(shapesDeselected()),this,SLOT(shapesDeselected())); connect(m_instrWindow->getSurface().get(),SIGNAL(shapeChanged()),this,SLOT(shapeChanged())); connect(m_instrWindow->getSurface().get(),SIGNAL(shapesCleared()),this,SLOT(shapesCleared())); enableApplyButtons(); }
Window::Window() { m_shouldDisplayFeather = true; std::cout<<"Initializing Mallard main window "; glWidget = new GLWidget; m_tools = new ToolBox; m_barbEdit = new BarbEdit(this); m_renderEdit = new RenderEdit(this); glWidget->setInteractContext(m_tools); m_brushControl = new BrushControl(glWidget->brush(), this); m_featherEdit = new FeatherEdit(this); FeatherExample::FeatherLibrary = glWidget; m_timeControl = new TimeControl(this); glWidget->setPlayback(m_timeControl); m_sceneEdit = new SceneEdit(glWidget, this); addToolBar(m_tools); setCentralWidget(glWidget); setWorkTitle(tr("untitled")); createActions(); createMenus(); connect(m_tools, SIGNAL(contextChanged(int)), this, SLOT(receiveToolContext(int))); connect(m_tools, SIGNAL(contextChanged(int)), m_brushControl, SLOT(receiveToolContext(int))); connect(m_tools, SIGNAL(actionTriggered(int)), this, SLOT(receiveToolAction(int))); connect(m_tools, SIGNAL(stateChanged(int)), this, SLOT(receiveToolState(int))); connect(m_brushControl, SIGNAL(brushChanged()), glWidget, SLOT(receiveBrushChanged())); connect(m_brushControl, SIGNAL(paintModeChanged(int)), glWidget, SLOT(receivePaintMode(int))); connect(glWidget, SIGNAL(sceneNameChanged(QString)), this, SLOT(setWorkTitle(QString))); connect(glWidget, SIGNAL(sendMessage(QString)), this, SLOT(showMessage(QString))); connect(m_featherEdit, SIGNAL(textureLoaded(QString)), glWidget, SLOT(receiveFeatherEditBackground(QString))); connect(m_featherEdit, SIGNAL(featherAdded()), glWidget, SLOT(receiveFeatherAdded())); connect(glWidget, SIGNAL(sendFeatherEditBackground(QString)), m_featherEdit, SLOT(receiveTexture(QString))); connect(m_timeControl, SIGNAL(currentFrameChanged(int)), glWidget, SLOT(updateOnFrame(int))); connect(m_featherEdit->uvView(), SIGNAL(selectionChanged()), m_barbEdit->barbControl(), SLOT(receiveSelectionChanged())); connect(glWidget, SIGNAL(featherSelectionChanged()), m_barbEdit->barbControl(), SLOT(receiveSelectionChanged())); connect(m_featherEdit->uvView(), SIGNAL(shapeChanged()), m_barbEdit->barbView(), SLOT(receiveShapeChanged())); connect(glWidget, SIGNAL(renderResChanged(QSize)), m_renderEdit, SLOT(resizeRenderView(QSize))); connect(glWidget, SIGNAL(renderEngineChanged(QString)), m_renderEdit, SLOT(setRenderEngine(QString))); connect(glWidget, SIGNAL(renderStarted(QString)), m_renderEdit, SLOT(startRender(QString))); connect(m_renderEdit, SIGNAL(cancelRender()), glWidget, SLOT(receiveCancelRender())); connect(m_barbEdit->barbControl(), SIGNAL(shapeChanged()), glWidget, SLOT(receiveBarbChanged())); connect(glWidget, SIGNAL(sceneOpened()), m_sceneEdit, SLOT(reloadScene())); connect(m_sceneEdit->model(), SIGNAL(cameraChanged()), glWidget, SLOT(receiveCameraChanged())); std::cout<<"Ready\n"; statusBar()->showMessage(tr("Ready")); }
void canvasView::paintEvent(QPaintEvent *event) { Q_UNUSED(event); QPainter* painter = new QPainter(this); painter->fillRect(0,0,width, height, QBrush(Qt::white,Qt::SolidPattern)); model->draw(painter,highlight); mightSnap(painter); if(state == START){ if(shape == LINE) painter->drawLine(start,end); else if(shape == CIRCLE) painter->drawEllipse(start,QLineF(start,end).length(),QLineF(start,end).length()); } else if(state == DONE){ if(shape == LINE){ painter->drawLine(start,end); model->add(shape,start,end); } else if(shape == CIRCLE){ painter->drawEllipse(start,QLineF(start,end).length(),QLineF(start,end).length()); model->add(shape,start,end); } state = IDLE; highlight = snap = display = false; shape = UNDEFINED; emit shapeChanged(shape); update(); } }
void canvasView::keyPressEvent(QKeyEvent *event) { if(event->key() == Qt::Key_X){ if(state==IDLE){ state = READY; shape = LINE; highlight = display = true; start = mapFromGlobal(QCursor::pos()); } } else if(event->key() == Qt::Key_C){ if(state==IDLE){ state = READY; shape = CIRCLE; highlight = display =true; start = mapFromGlobal(QCursor::pos()); } } else if(event->key() == Qt::Key_Escape){ state = IDLE; highlight = snap = display = false; snapDesc1 = snapDesc2 = "NA"; shape = UNDEFINED; } emit shapeChanged(this->shape); emit messageChanged(display,toString(start),"...",shape); update(); }
void MlUVView::clientMouseInput(QMouseEvent *) { if(!FeatherLibrary) return; const Ray * ray = getIncidentRay(); Vector2F p(ray->m_origin.x, ray->m_origin.y); Vector2F d = updateTracking(p); if(interactMode() == ToolContext::MoveInUV) { FeatherLibrary->selectedFeatherExample()->translateUV(d); } else if(interactMode() == ToolContext::MoveVertexInUV) { if(m_selectedVert) { if(m_moveYOnly) { *m_selectedVert += d.y; m_selectVertWP.y += d.y; } else { m_selectedVert[0] += d.x; m_selectedVert[1] += d.y; m_selectVertWP += d; } FeatherLibrary->selectedFeatherExample()->computeTexcoord(); } } emit shapeChanged(); }
void Selection::translate(const QPoint &offset) { if(offset.x() == 0 && offset.y() == 0) return; m_shape.translate(offset); emit shapeChanged(m_shape); }
void Box2DItem::setShape(const Quasi::BodyShape &shape) { if (m_shape != shape) { m_shape = shape; emit shapeChanged(); // XXX needs additional treatment? } }
inline void halfExtentZ(float halfExtentZ) { const bool needsUpdate = fabsf(halfExtentZ - _halfExtentZ) > 1e-6f; _halfExtentZ = halfExtentZ; if (needsUpdate) shapeChanged()->execute(shared_from_this()); }
void Selection::resetShape() { const QPointF center = m_shape.boundingRect().center(); m_shape.clear(); for(const QPointF &p : m_originalShape) m_shape << p + center; emit shapeChanged(m_shape); }
inline void margin(float margin) { const bool needsUpdate = fabsf(margin - _margin) > 1e-6f; _margin = margin; if (needsUpdate) shapeChanged()->execute(shared_from_this()); }
void Selection::addPointToShape(const QPointF &point) { if(m_closedPolygon) { qWarning("Selection::addPointToShape: shape is closed!"); } else { m_shape << point; emit shapeChanged(m_shape); } }
void MlUVView::changeSelectedFeatherType() { if(!FeatherLibrary) return; MlFeather * f = FeatherLibrary->selectedFeatherExample(); if(!f) return; f->setType(f->type() + 1); emit shapeChanged(); update(); }
void MlUVView::loadImageBackground(const std::string & name) { if(!MlFeather::ColorTextureFile.open(name)) return; MlFeather::ColorTextureFile.verbose(); makeCurrent(); m_texId = getDrawer()->loadTexture(m_texId, &MlFeather::ColorTextureFile); doneCurrent(); update(); emit shapeChanged(); }
void MlUVView::changeSelectedFeatherNSegment(int d) { if(!FeatherLibrary) return; MlFeather * f = FeatherLibrary->selectedFeatherExample(); if(!f) return; int nseg = f->numSegment() + d; if(nseg < 4 || nseg > 32) return; f->changeNumSegment(d); emit shapeChanged(); }
void Selection::scale(qreal x, qreal y) { if(x==1.0 && y==1.0) return; QPointF center = m_shape.boundingRect().center(); for(QPointF &p : m_shape) { QPointF sp = (p - center); sp.rx() *= x; sp.ry() *= y; p = sp + center; } emit shapeChanged(m_shape); }
bool PhysicsWidget::setCurrentNode(QXmlTreeNode *node) { // First remove all current constraints, the other values aren't that important to reset... while(m_constraintContainer->count() != 0) { QLayoutItem* childItem = m_constraintContainer->takeAt(0); if (childItem->widget() != 0) delete childItem->widget(); delete childItem; } if (node && (node->xmlNode().tagName() == "BulletPhysics" || node->xmlNode().tagName() == "Physics")) { m_currentNode = 0; m_mass->setValue(node->xmlNode().attribute("mass","0.0").toFloat()); m_width->setValue(node->xmlNode().attribute("x", "1").toFloat()); m_height->setValue(node->xmlNode().attribute("y","1").toFloat()); m_depth->setValue(node->xmlNode().attribute("z", "1").toFloat()); m_radius->setValue(node->xmlNode().attribute("radius", "1").toFloat()); m_cylRadius->setValue(node->xmlNode().attribute("radius", "1").toFloat()); m_cylHeight->setValue(node->xmlNode().attribute("height", "1").toFloat()); int index = m_shape->findText(node->xmlNode().attribute("shape")); m_shape->setCurrentIndex(index); m_restitution->setValue(node->xmlNode().attribute("restitution", "0").toFloat()); m_friction->setValue(node->xmlNode().attribute("friction", "0.5").toFloat()); m_rollingFriction->setValue(node->xmlNode().attribute("rollingFriction", "0").toFloat()); m_kinematic->setChecked( node->xmlNode().attribute("kinematic", "0").compare("true",Qt::CaseInsensitive) == 0 || node->xmlNode().attribute("kinematic", "0").compare("1",Qt::CaseInsensitive) == 0); m_noContactResponse->setChecked( node->xmlNode().attribute("noContactResponse", "0").compare("true",Qt::CaseInsensitive) == 0 || node->xmlNode().attribute("noContactResponse", "0").compare("1",Qt::CaseInsensitive) == 0); m_offsetX->setValue(node->xmlNode().attribute("offsetX","0").toFloat()); m_offsetY->setValue(node->xmlNode().attribute("offsetY","0").toFloat()); m_offsetZ->setValue(node->xmlNode().attribute("offsetZ","0").toFloat()); m_currentNode = node; shapeChanged(index); for (int i = 0; i < node->xmlNode().childNodes().count(); ++i) { QDomNode constNode = node->xmlNode().childNodes().at(i); if (constNode.isElement() && constNode.nodeName().compare("Constraint") == 0) { PhysicConstraintWidget* wdg = new PhysicConstraintWidget(constNode.toElement(), this); connect(wdg, SIGNAL(modified(bool)), this, SLOT(updatePhysics())); connect(wdg, SIGNAL(deleting(PhysicConstraintWidget*)), this, SLOT(deleteConstraint(PhysicConstraintWidget*))); m_constraintContainer->addWidget(wdg); } }
void Selection::adjust(int dx1, int dy1, int dx2, int dy2) { const QRectF bounds = m_shape.boundingRect(); const qreal sx = (bounds.width() - dx1 + dx2) / bounds.width(); const qreal sy = (bounds.height() - dy1 + dy2) / bounds.height(); for(int i=0; i<m_shape.size(); ++i) { m_shape[i] = QPointF( bounds.x() + (m_shape[i].x() - bounds.x()) * sx + dx1, bounds.y() + (m_shape[i].y() - bounds.y()) * sy + dy1 ); } emit shapeChanged(m_shape); }
Window::Window(QWidget *parent) : QWidget(parent) { shapeComboBox = new QComboBox; shapeComboBox->addItem(tr("Cuadrado"), Canvas::Cuadrado); shapeComboBox->addItem(tr("Polygono"), Canvas::Polygono); shapeComboBox->addItem(tr("Arco"), Canvas::Arco); shapeComboBox->addItem(tr("Cubo"), Canvas::Cubo); shapeComboBox->addItem(tr("Prisma Triangular"), Canvas::Piramide); shapeComboBox->addItem(tr("Prisma Rectangular"), Canvas::Prisma); shapeComboBox->addItem(tr("Cono"), Canvas::Cono); canvas = new Canvas; shapeLabel = new QLabel(tr("&Forma:")); shapeLabel->setBuddy(shapeComboBox); transformCB = new QComboBox; transformCB->addItem(tr("Transladar"), Canvas::Translacion); transformCB->addItem(tr("Rotar"), Canvas::Rotacion); transformCB->addItem(tr("ZoomIn"), Canvas::Escalar); transformCB->addItem(tr("ZoomOut"), Canvas::Achicar); transformLabel = new QLabel(tr("&Transformacion:")); transformLabel->setBuddy(transformCB); connect(shapeComboBox, SIGNAL(activated(int)), this, SLOT(shapeChanged())); connect(transformCB, SIGNAL(activated(int)), this, SLOT(shapeTransformed())); QGridLayout *mainLayout = new QGridLayout; mainLayout->setColumnStretch(0, 1); mainLayout->setColumnStretch(0, 3); mainLayout->addWidget(canvas, 0, 0, 1, 4); mainLayout->setRowMinimumHeight(1,6); mainLayout->addWidget(shapeLabel, 2, 1, Qt::AlignRight); mainLayout->addWidget(shapeComboBox, 1, 2); mainLayout->addWidget(transformCB, 3,2); setLayout(mainLayout); shapeChanged(); setWindowTitle(tr("Tarea 5: Dibujos")); }
void PropertiesPalette_Group::handleNewShape(int frameType, int count, qreal *points) { if (!m_ScMW || m_ScMW->scriptIsRunning()) return; if ((m_haveDoc) && (m_haveItem)) { if ((m_item->itemType() == PageItem::PolyLine) || (m_item->itemType() == PageItem::PathText)) return; m_doc->item_setFrameShape(m_item, frameType, count, points); //ScribusDoc::changed() is called in item_setFrameShape() //Hope this is enough //emit DocChanged(); emit shapeChanged(frameType); } }
int Window::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QWidget::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: shapeChanged(); break; case 1: penChanged(); break; case 2: brushChanged(); break; case 3: fontChanged(); break; default: ; } _id -= 4; } return _id; }
void Selection::rotate(float angle) { if(qAbs(angle) < 0.0001) return; const QPointF origin = m_shape.boundingRect().center(); QTransform t; t.translate(origin.x(), origin.y()); t.rotateRadians(angle); for(int i=0; i<m_shape.size(); ++i) { QPointF p = m_shape[i] - origin; m_shape[i] = t.map(p); } emit shapeChanged(m_shape); }
void Fixture::setShapeItem(QQuickItem *shapeItem) { if (m_shapeItem == shapeItem) return; if (m_shapeItem) m_shapeItem->disconnect(); m_shapeItem = shapeItem; if (Shape *shape = dynamic_cast<Shape*>(m_shapeItem)) { connect(shape, SIGNAL(shapeUpdated()), this, SLOT(onShapeUpdated())); } emit shapeChanged(); }
MainWindow::MainWindow(QWidget *parent) : QWidget(parent) { setWindowTitle("QtDraw | Cheick Berthe"); m_Canvas = new canvasView(this); m_Menu = new menuView(this); m_Message = new messageView(this); m_Canvas->setFocus(); QHBoxLayout* hLayout = new QHBoxLayout; QVBoxLayout* vLayout = new QVBoxLayout; hLayout->addWidget(m_Canvas); hLayout->addWidget(m_Menu); vLayout->addWidget(m_Message); //vLayout->addSpacing(3); vLayout->addLayout(hLayout); this->setLayout(vLayout); QObject::connect(m_Canvas, SIGNAL(shapeChanged(Shapetype)),m_Menu,SLOT(setShape(Shapetype))); QObject::connect(m_Canvas,SIGNAL(messageChanged(bool,QString,QString,Shapetype)),m_Message,SLOT(setMessage(bool,QString,QString,Shapetype))); }
void BezierCubicItem::controlPointMoved(int index) { // solid move if (index == 0 || index == 2) { QLineF l = index == 0 ? m_l1->line() : m_l2->line(); if (!l.isNull()) m_cps[index + 1]->setPos(m_cps[index]->pos() + QPointF(l.dx(), l.dy())); } // update line if (index < 2) m_l1->setLine(QLineF(m_cps[0]->pos(), m_cps[1]->pos())); else m_l2->setLine(QLineF(m_cps[2]->pos(), m_cps[3]->pos())); // update path QPainterPath path(m_cps[0]->pos()); path.cubicTo(m_cps[1]->pos(), m_cps[3]->pos(), m_cps[2]->pos()); m_path->setPath(path); emit shapeChanged(path); }
Window::Window() { renderArea = new RenderArea; // making renderArea point to a new location shapeComboBox = new QComboBox; // making the pointer shapeComboBox pointing to a ComboBox shapeComboBox->addItem(tr("Remove"), RenderArea::Remove); // adding items to the comboBox shapeComboBox->addItem(tr("Insert"), RenderArea::Insert); // adding items to the comboBox shapeComboBox->addItem(tr("Search"), RenderArea::Search); // adding items to the comboBox shapeComboBox->addItem(tr("Find_Minimum"), RenderArea::Find_Minimum);// adding items to the comboBox shapeComboBox->addItem(tr("Find_Maximum"), RenderArea::Find_Maximum);// adding items to the comboBox shapeLabel = new QLabel(tr("&Operation:")); // making shapeLabel point to a QLabel storing "Operation" (& in front of O means a shortcut "Alt+O") shapeLabel->setBuddy(shapeComboBox); // associating the label with the comboBox Box = new QSpinBox; // creating a new QSpinBox which would be used to input text Box->setRange(INT_MIN, INT_MAX); BoxLabel = new QLabel(tr("&Text:")); // making BoxLabel point to a QLabel storing "Text" BoxLabel->setBuddy(Box); // associating the label with the spinbox connect(shapeComboBox, SIGNAL(activated(int) ),this, SLOT( shapeChanged() ) );// connecting the "stack" button connect(Box, SIGNAL(valueChanged(int) ),this, SLOT( a() ) ) ; // connecting the "text" button QGridLayout *mainLayout = new QGridLayout; mainLayout->setColumnStretch(0, 1); // set the stretch factor of the specified column to the second argument mainLayout->setColumnStretch(3, 1); mainLayout->addWidget(renderArea, 0, 0, 1, 4); // adds widget to the grid mainLayout->setRowMinimumHeight(1, 6); mainLayout->addWidget(shapeLabel, 2, 1, Qt::AlignRight); // the arguments are widget *,row no.,column no.,alignment mainLayout->addWidget(shapeComboBox, 2, 2); mainLayout->addWidget(BoxLabel, 7, 1, Qt::AlignRight); mainLayout->addWidget(Box, 7, 2); setLayout(mainLayout); shapeChanged(); // calling these functions to set the shape,pen and brush of the renderArea class penChanged(); fontChanged(); setWindowTitle(tr("Binary Search Tree")); // setting the title of the window }
void Selection::setShape(const QPolygonF &shape) { m_shape = shape; emit shapeChanged(shape); }
Draw::Draw() : QWidget() { setWindowTitle(tr("Basic Drawing")); m_renderArea = new DrawArea; shapeComboBox = new QComboBox; shapeComboBox->addItem(tr("Polygon"), DrawArea::Polygon); shapeComboBox->addItem(tr("Rectangle"), DrawArea::Rect); shapeComboBox->addItem(tr("Rounded Rectangle"), DrawArea::RoundedRect); shapeComboBox->addItem(tr("Ellipse"), DrawArea::Ellipse); shapeComboBox->addItem(tr("Pie"), DrawArea::Pie); shapeComboBox->addItem(tr("Chord"), DrawArea::Chord); shapeComboBox->addItem(tr("Path"), DrawArea::Path); shapeComboBox->addItem(tr("Line"), DrawArea::Line); shapeComboBox->addItem(tr("Polyline"), DrawArea::Polyline); shapeComboBox->addItem(tr("Arc"), DrawArea::Arc); shapeComboBox->addItem(tr("Points"), DrawArea::Points); shapeComboBox->addItem(tr("Text"), DrawArea::Text); shapeLabel = new QLabel(tr("&Shape:")); shapeLabel->setBuddy(shapeComboBox); penWidthSpinBox = new QSpinBox; penWidthSpinBox->setRange(0, 20); penWidthSpinBox->setSpecialValueText(tr("0 (cosmetic pen)")); penWidthLabel = new QLabel(tr("Pen &Width:")); penWidthLabel->setBuddy(penWidthSpinBox); penStyleComboBox = new QComboBox; penStyleComboBox->addItem(tr("Solid"), Qt::SolidLine); penStyleComboBox->addItem(tr("Dash"), Qt::DashLine); penStyleComboBox->addItem(tr("Dot"), Qt::DotLine); penStyleComboBox->addItem(tr("Dash Dot"), Qt::DashDotLine); penStyleComboBox->addItem(tr("Dash Dot Dot"), Qt::DashDotDotLine); penStyleComboBox->addItem(tr("None"), Qt::NoPen); penStyleLabel = new QLabel(tr("&Pen Style:")); penStyleLabel->setBuddy(penStyleComboBox); penCapComboBox = new QComboBox; penCapComboBox->addItem(tr("Flat"), Qt::FlatCap); penCapComboBox->addItem(tr("Square"), Qt::SquareCap); penCapComboBox->addItem(tr("Round"), Qt::RoundCap); penCapLabel = new QLabel(tr("Pen &Cap:")); penCapLabel->setBuddy(penCapComboBox); penJoinComboBox = new QComboBox; penJoinComboBox->addItem(tr("Miter"), Qt::MiterJoin); penJoinComboBox->addItem(tr("Bevel"), Qt::BevelJoin); penJoinComboBox->addItem(tr("Round"), Qt::RoundJoin); penJoinLabel = new QLabel(tr("Pen &Join:")); penJoinLabel->setBuddy(penJoinComboBox); brushStyleComboBox = new QComboBox; brushStyleComboBox->addItem(tr("Linear Gradient"), Qt::LinearGradientPattern); brushStyleComboBox->addItem(tr("Radial Gradient"), Qt::RadialGradientPattern); brushStyleComboBox->addItem(tr("Conical Gradient"), Qt::ConicalGradientPattern); brushStyleComboBox->addItem(tr("Texture"), Qt::TexturePattern); brushStyleComboBox->addItem(tr("Solid"), Qt::SolidPattern); brushStyleComboBox->addItem(tr("Horizontal"), Qt::HorPattern); brushStyleComboBox->addItem(tr("Vertical"), Qt::VerPattern); brushStyleComboBox->addItem(tr("Cross"), Qt::CrossPattern); brushStyleComboBox->addItem(tr("Backward Diagonal"), Qt::BDiagPattern); brushStyleComboBox->addItem(tr("Forward Diagonal"), Qt::FDiagPattern); brushStyleComboBox->addItem(tr("Diagonal Cross"), Qt::DiagCrossPattern); brushStyleComboBox->addItem(tr("Dense 1"), Qt::Dense1Pattern); brushStyleComboBox->addItem(tr("Dense 2"), Qt::Dense2Pattern); brushStyleComboBox->addItem(tr("Dense 3"), Qt::Dense3Pattern); brushStyleComboBox->addItem(tr("Dense 4"), Qt::Dense4Pattern); brushStyleComboBox->addItem(tr("Dense 5"), Qt::Dense5Pattern); brushStyleComboBox->addItem(tr("Dense 6"), Qt::Dense6Pattern); brushStyleComboBox->addItem(tr("Dense 7"), Qt::Dense7Pattern); brushStyleComboBox->addItem(tr("None"), Qt::NoBrush); brushStyleLabel = new QLabel(tr("&Brush:")); brushStyleLabel->setBuddy(brushStyleComboBox); otherOptionsLabel = new QLabel(tr("Options:")); antialiasingCheckBox = new QCheckBox(tr("&Antialiasing")); transformationsCheckBox = new QCheckBox(tr("&Transformations")); // QGridLayout *mainLayout = new QGridLayout; mainLayout->setColumnStretch(5, 1); mainLayout->setHorizontalSpacing(10); mainLayout->setVerticalSpacing(10); mainLayout->addWidget(m_renderArea, 0, 0, 1, 6); mainLayout->addWidget(shapeLabel, 2, 0); mainLayout->addWidget(shapeComboBox, 2, 1); mainLayout->addWidget(penWidthLabel, 3, 0); mainLayout->addWidget(penWidthSpinBox, 3, 1); mainLayout->addWidget(penStyleLabel, 4, 0); mainLayout->addWidget(penStyleComboBox, 4, 1); mainLayout->addWidget(penJoinLabel, 2, 3); mainLayout->addWidget(penJoinComboBox, 2, 4); mainLayout->addWidget(penCapLabel, 3, 3); mainLayout->addWidget(penCapComboBox, 3, 4); mainLayout->addWidget(brushStyleLabel, 4, 3); mainLayout->addWidget(brushStyleComboBox,4, 4); mainLayout->addWidget(otherOptionsLabel, 5, 0); mainLayout->addWidget(antialiasingCheckBox, 5, 1); mainLayout->addWidget(transformationsCheckBox, 5, 4); setLayout(mainLayout); // signals connect(shapeComboBox, SIGNAL(activated(int)), this, SLOT(shapeChanged())); connect(penWidthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(penChanged())); connect(penStyleComboBox, SIGNAL(activated(int)), this, SLOT(penChanged())); connect(penCapComboBox, SIGNAL(activated(int)), this, SLOT(penChanged())); connect(penJoinComboBox, SIGNAL(activated(int)), this, SLOT(penChanged())); connect(brushStyleComboBox, SIGNAL(activated(int)), this, SLOT(brushChanged())); connect(antialiasingCheckBox, SIGNAL(toggled(bool)), m_renderArea, SLOT(setAntialiased(bool))); connect(transformationsCheckBox, SIGNAL(toggled(bool)), m_renderArea, SLOT(setTransformed(bool))); shapeChanged(); penChanged(); brushChanged(); antialiasingCheckBox->setChecked(true); }
//! [1] Window::Window() { renderArea = new RenderArea; shapeComboBox = new QComboBox; shapeComboBox->addItem(tr("Polygon"), RenderArea::Polygon); shapeComboBox->addItem(tr("Rectangle"), RenderArea::Rect); shapeComboBox->addItem(tr("Rounded Rectangle"), RenderArea::RoundedRect); shapeComboBox->addItem(tr("Ellipse"), RenderArea::Ellipse); shapeComboBox->addItem(tr("Pie"), RenderArea::Pie); shapeComboBox->addItem(tr("Chord"), RenderArea::Chord); shapeComboBox->addItem(tr("Path"), RenderArea::Path); shapeComboBox->addItem(tr("Line"), RenderArea::Line); shapeComboBox->addItem(tr("Polyline"), RenderArea::Polyline); shapeComboBox->addItem(tr("Arc"), RenderArea::Arc); shapeComboBox->addItem(tr("Points"), RenderArea::Points); shapeComboBox->addItem(tr("Text"), RenderArea::Text); shapeComboBox->addItem(tr("Pixmap"), RenderArea::Pixmap); shapeLabel = new QLabel(tr("&Shape:")); shapeLabel->setBuddy(shapeComboBox); //! [1] //! [2] penWidthSpinBox = new QSpinBox; penWidthSpinBox->setRange(0, 20); #if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5) || defined(Q_WS_SIMULATOR) penWidthSpinBox->setSpecialValueText(tr("0")); #else penWidthSpinBox->setSpecialValueText(tr("0 (cosmetic pen)")); #endif penWidthLabel = new QLabel(tr("Pen &Width:")); penWidthLabel->setBuddy(penWidthSpinBox); //! [2] //! [3] penStyleComboBox = new QComboBox; penStyleComboBox->addItem(tr("Solid"), Qt::SolidLine); penStyleComboBox->addItem(tr("Dash"), Qt::DashLine); penStyleComboBox->addItem(tr("Dot"), Qt::DotLine); penStyleComboBox->addItem(tr("Dash Dot"), Qt::DashDotLine); penStyleComboBox->addItem(tr("Dash Dot Dot"), Qt::DashDotDotLine); penStyleComboBox->addItem(tr("None"), Qt::NoPen); penStyleLabel = new QLabel(tr("&Pen Style:")); penStyleLabel->setBuddy(penStyleComboBox); penCapComboBox = new QComboBox; penCapComboBox->addItem(tr("Flat"), Qt::FlatCap); penCapComboBox->addItem(tr("Square"), Qt::SquareCap); penCapComboBox->addItem(tr("Round"), Qt::RoundCap); penCapLabel = new QLabel(tr("Pen &Cap:")); penCapLabel->setBuddy(penCapComboBox); penJoinComboBox = new QComboBox; penJoinComboBox->addItem(tr("Miter"), Qt::MiterJoin); penJoinComboBox->addItem(tr("Bevel"), Qt::BevelJoin); penJoinComboBox->addItem(tr("Round"), Qt::RoundJoin); penJoinLabel = new QLabel(tr("Pen &Join:")); penJoinLabel->setBuddy(penJoinComboBox); //! [3] //! [4] brushStyleComboBox = new QComboBox; brushStyleComboBox->addItem(tr("Linear Gradient"), Qt::LinearGradientPattern); brushStyleComboBox->addItem(tr("Radial Gradient"), Qt::RadialGradientPattern); brushStyleComboBox->addItem(tr("Conical Gradient"), Qt::ConicalGradientPattern); brushStyleComboBox->addItem(tr("Texture"), Qt::TexturePattern); brushStyleComboBox->addItem(tr("Solid"), Qt::SolidPattern); brushStyleComboBox->addItem(tr("Horizontal"), Qt::HorPattern); brushStyleComboBox->addItem(tr("Vertical"), Qt::VerPattern); brushStyleComboBox->addItem(tr("Cross"), Qt::CrossPattern); brushStyleComboBox->addItem(tr("Backward Diagonal"), Qt::BDiagPattern); brushStyleComboBox->addItem(tr("Forward Diagonal"), Qt::FDiagPattern); brushStyleComboBox->addItem(tr("Diagonal Cross"), Qt::DiagCrossPattern); brushStyleComboBox->addItem(tr("Dense 1"), Qt::Dense1Pattern); brushStyleComboBox->addItem(tr("Dense 2"), Qt::Dense2Pattern); brushStyleComboBox->addItem(tr("Dense 3"), Qt::Dense3Pattern); brushStyleComboBox->addItem(tr("Dense 4"), Qt::Dense4Pattern); brushStyleComboBox->addItem(tr("Dense 5"), Qt::Dense5Pattern); brushStyleComboBox->addItem(tr("Dense 6"), Qt::Dense6Pattern); brushStyleComboBox->addItem(tr("Dense 7"), Qt::Dense7Pattern); brushStyleComboBox->addItem(tr("None"), Qt::NoBrush); brushStyleLabel = new QLabel(tr("&Brush:")); brushStyleLabel->setBuddy(brushStyleComboBox); //! [4] //! [5] otherOptionsLabel = new QLabel(tr("Options:")); //! [5] //! [6] antialiasingCheckBox = new QCheckBox(tr("&Antialiasing")); //! [6] //! [7] transformationsCheckBox = new QCheckBox(tr("&Transformations")); //! [7] //! [8] connect(shapeComboBox, SIGNAL(activated(int)), this, SLOT(shapeChanged())); connect(penWidthSpinBox, SIGNAL(valueChanged(int)), this, SLOT(penChanged())); connect(penStyleComboBox, SIGNAL(activated(int)), this, SLOT(penChanged())); connect(penCapComboBox, SIGNAL(activated(int)), this, SLOT(penChanged())); connect(penJoinComboBox, SIGNAL(activated(int)), this, SLOT(penChanged())); connect(brushStyleComboBox, SIGNAL(activated(int)), this, SLOT(brushChanged())); connect(antialiasingCheckBox, SIGNAL(toggled(bool)), renderArea, SLOT(setAntialiased(bool))); connect(transformationsCheckBox, SIGNAL(toggled(bool)), renderArea, SLOT(setTransformed(bool))); //! [8] //! [9] QGridLayout *mainLayout = new QGridLayout; //! [9] //! [10] #if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5) || defined(Q_WS_SIMULATOR) mainLayout->setSizeConstraint(QLayout::SetNoConstraint); #endif mainLayout->setColumnStretch(0, 1); mainLayout->setColumnStretch(3, 1); mainLayout->addWidget(renderArea, 0, 0, 1, 4); mainLayout->addWidget(shapeLabel, 2, 0, Qt::AlignRight); mainLayout->addWidget(shapeComboBox, 2, 1); mainLayout->addWidget(penWidthLabel, 3, 0, Qt::AlignRight); mainLayout->addWidget(penWidthSpinBox, 3, 1); mainLayout->addWidget(penStyleLabel, 4, 0, Qt::AlignRight); mainLayout->addWidget(penStyleComboBox, 4, 1); mainLayout->addWidget(penCapLabel, 3, 2, Qt::AlignRight); mainLayout->addWidget(penCapComboBox, 3, 3); mainLayout->addWidget(penJoinLabel, 2, 2, Qt::AlignRight); mainLayout->addWidget(penJoinComboBox, 2, 3); mainLayout->addWidget(brushStyleLabel, 4, 2, Qt::AlignRight); mainLayout->addWidget(brushStyleComboBox, 4, 3); mainLayout->addWidget(otherOptionsLabel, 5, 0, Qt::AlignRight); mainLayout->addWidget(antialiasingCheckBox, 5, 1, 1, 1, Qt::AlignRight); mainLayout->addWidget(transformationsCheckBox, 5, 2, 1, 2, Qt::AlignRight); setLayout(mainLayout); shapeChanged(); penChanged(); brushChanged(); antialiasingCheckBox->setChecked(true); setWindowTitle(tr("Basic Drawing")); }
void Clef::setShape(ClefShape shape) { if (d->shape == shape) return; d->shape = shape; emit shapeChanged(shape); }