bool insertRectangles(tree_struct* t, rectangle2DList_struct* l) { listCell2D_struct*lc=l->first; bool rr=true; while(lc) { bool r=insertRectangle(t->root, &lc->data, t->width, t->height, 0, 0, area2D(lc->data)); NOGBA("r : %d",(int)r); if(r) { lc->data.real->lmPos.x=lc->data.position.x; lc->data.real->lmPos.y=lc->data.position.y; lc->data.real->rot=lc->data.rot; NOGBA("pos %p %d %d %d %d (%d)",lc->data.real,lc->data.real->lmPos.x,lc->data.real->lmPos.y,lc->data.size.x,lc->data.size.y,lc->data.rot); }else rr=false; lc=lc->next; } return rr; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // DccCanvasWidget // DccCanvasWidget::DccCanvasWidget(QWidget * par) : QWidget(par,"canvas_widget") { m_pCanvas = new QCanvas(this); //#warning "Make this size as parameter of Dcc ?" m_pCanvas->resize(648,480); m_pMenuBar = new QMenuBar(this); m_pSplitter = new QSplitter(QSplitter::Horizontal,this); m_pCanvasView = new KviCanvasView(m_pCanvas,this,m_pSplitter); m_pStatusLabel = new QLabel(this); m_pPropertiesWidget = new KviCanvasItemPropertiesWidget(m_pSplitter); QValueList<int> l; l.append(80); l.append(20); m_pSplitter->setSizes(l); connect(m_pPropertiesWidget,SIGNAL(propertyChanged(const QString &,const QVariant &)),m_pCanvasView,SLOT(propertyChanged(const QString &,const QVariant &))); QMenu * add = new QMenu(m_pMenuBar); QMenu * shapes = new QMenu(add); QMenu * polygons = new QMenu(add); QMenu * items = new QMenu(add); shapes->addAction(__tr2qs_ctx("&Line","dcc"),m_pCanvasView,SLOT(insertLine())); shapes->addAction(__tr2qs_ctx("&Rectangle","dcc"),m_pCanvasView,SLOT(insertRectangle())); shapes->addAction(__tr2qs_ctx("&Ellipse","dcc"),m_pCanvasView,SLOT(insertEllipse())); shapes->addAction(__tr2qs_ctx("&Pie","dcc"),m_pCanvasView,SLOT(insertPie())); shapes->addAction(__tr2qs_ctx("&Chord","dcc"),m_pCanvasView,SLOT(insertChord())); items->addAction(__tr2qs_ctx("&Rich text (html)","dcc"),m_pCanvasView,SLOT(insertRichText())); polygons->addAction(__tr2qs_ctx("&Triangle","dcc"),m_pCanvasView,SLOT(insertPolygonTriangle())); polygons->addAction(__tr2qs_ctx("&Rectangle","dcc"),m_pCanvasView,SLOT(insertPolygonRectangle())); polygons->addAction(__tr2qs_ctx("&Pentagon","dcc"),m_pCanvasView,SLOT(insertPolygonPentagon())); polygons->addAction(__tr2qs_ctx("&Hexagon","dcc"),m_pCanvasView,SLOT(insertPolygonHexagon())); add->addAction(__tr2qs_ctx("&Shape","dcc"),shapes); add->addAction(__tr2qs_ctx("&Item","dcc"),items); add->addAction(__tr2qs_ctx("&Polygons","dcc"),polygons); m_pMenuBar->addAction(__tr2qs_ctx("&Insert","dcc"),add); }
bool insertRectangle(treeNode_struct* tn, rectangle2D_struct* rec, short w, short h, short x, short y, int a) { bool r; if(a>w*h)return false; // NOGBA("%d %d %d %d",x,y,w,h); switch(tn->type) { case EMPTY: if((rec->size.x<=w && rec->size.y<=h) || (rec->size.y<=w && rec->size.x<=h)) { // NOGBA("empty"); if(!(rec->size.x<=w && rec->size.y<=h)) { //SUPERROTATIOOOON int z=rec->size.x; rec->size.x=rec->size.y; rec->size.y=z; rec->rot=true; }else rec->rot=false; if(rec->size.x>=rec->size.y) { tn->type=VERTICAL; tn->data=rec->size.x; tn->son[0]=createNode(); tn->son[0]->type=HORIZONTAL; tn->son[0]->data=rec->size.y; tn->son[0]->son[0]=createNode(); tn->son[0]->son[0]->type=RECTANGLE; tn->son[0]->son[1]=createNode(); tn->son[1]=createNode(); }else{ tn->type=HORIZONTAL; tn->data=rec->size.y; tn->son[0]=createNode(); tn->son[0]->type=VERTICAL; tn->son[0]->data=rec->size.x; tn->son[0]->son[0]=createNode(); tn->son[0]->son[0]->type=RECTANGLE; tn->son[0]->son[1]=createNode(); tn->son[1]=createNode(); } rec->position.x=x; rec->position.y=y; return true; } break; case VERTICAL: // NOGBA("vertical %d", tn->data); r=insertRectangle(tn->son[0], rec, tn->data, h, x, y, a); if(!r)r=insertRectangle(tn->son[1], rec, w-tn->data, h, x+tn->data, y, a); return r; break; case HORIZONTAL: // NOGBA("horizontal %d", tn->data); r=insertRectangle(tn->son[0], rec, w, tn->data, x, y, a); if(!r)r=insertRectangle(tn->son[1], rec, w, h-tn->data, x, y+tn->data, a); return r; break; case RECTANGLE: // NOGBA("rectangle"); return false; break; } return false; }
void GraphicUI::createActions() { CreateAct = new QAction(QIcon("images/create.png"), tr("&Create a mind map"), this); connect(CreateAct, SIGNAL(triggered()), this, SLOT(create())); OpenAct = new QAction(QIcon("images/open.png"), tr("&Open a mind map"), this); OpenAct->setStatusTip(tr("Open an existing file")); connect(OpenAct, SIGNAL(triggered()), this, SLOT(open())); SaveAct = new QAction(QIcon("images/save.png"), tr("&Save a mind map"), this); connect(SaveAct, SIGNAL(triggered()), this, SLOT(save())); ExitAct = new QAction(QIcon("images/exit.png"), tr("&Exit"), this); ExitAct->setStatusTip(tr("Exit the application")); connect(ExitAct, SIGNAL(triggered()), this, SLOT(close())); EditAct = new QAction(QIcon("images/edit.png"), tr("&Edit"), this); connect(EditAct, SIGNAL(triggered()), this, SLOT(edit())); DeleteAct = new QAction(QIcon("images/delete.png"), tr("&Delete"), this); connect(DeleteAct, SIGNAL(triggered()), this, SLOT(deleteNode())); InsertAChildAct = new QAction(QIcon("images/child.png"), tr("&Insert a child"), this); connect(InsertAChildAct, SIGNAL(triggered()), this, SLOT(insertChild())); InsertASiblingAct = new QAction(QIcon("images/silbing.png"), tr("&Insert a silbing"), this); connect(InsertASiblingAct, SIGNAL(triggered()), this, SLOT(insertSilbing())); InsertAParentAct = new QAction(QIcon("images/parent.png"), tr("&Insert a parent"), this); connect(InsertAParentAct, SIGNAL(triggered()), this, SLOT(insertParent())); AboutAct = new QAction(QIcon("images/about.png"), tr("&About"), this); connect(AboutAct, SIGNAL(triggered()), this, SLOT(about())); CutAct = new QAction(QIcon("images/cut.png"), tr("&Cut"), this); connect(CutAct, SIGNAL(triggered()), this, SLOT(cut())); CopyAct = new QAction(QIcon("images/copy.png"), tr("&Copy"), this); connect(CopyAct, SIGNAL(triggered()), this, SLOT(copy())); PasteAct = new QAction(QIcon("images/paste.png"), tr("&Paste"), this); connect(PasteAct, SIGNAL(triggered()), this, SLOT(paste())); RedoAct = new QAction(QIcon("images/redo.png"), tr("&Redo"), this); connect(RedoAct, SIGNAL(triggered()), this, SLOT(redo())); UndoAct = new QAction(QIcon("images/undo.png"), tr("&Undo"), this); connect(UndoAct, SIGNAL(triggered()), this, SLOT(undo())); InsertARectangleAct = new QAction(QIcon("images/rectangle.png"), tr("&Insert a rectangle"), this); connect(InsertARectangleAct, SIGNAL(triggered()), this, SLOT(insertRectangle())); InsertACircleAct = new QAction(QIcon("images/circle.png"), tr("&Insert a circle"), this); connect(InsertACircleAct, SIGNAL(triggered()), this, SLOT(insertCircle())); InsertATriangleAct = new QAction(QIcon("images/triangle.png"), tr("&Insert a triangle"), this); connect(InsertATriangleAct, SIGNAL(triggered()), this, SLOT(insertTriangle())); UpAct = new QAction(QIcon("images/up.png"), tr("&Up"), this); connect(UpAct, SIGNAL(triggered()), this, SLOT(up())); DownAct = new QAction(QIcon("images/down.png"), tr("&Down"), this); connect(DownAct, SIGNAL(triggered()), this, SLOT(down())); ExpandAct = new QAction(QIcon("images/expand.png"), tr("&Expand"), this); connect(ExpandAct, SIGNAL(triggered()), this, SLOT(expand())); CollapseAct = new QAction(QIcon("images/collapse.png"), tr("&Collapse"), this); connect(CollapseAct, SIGNAL(triggered()), this, SLOT(collapse())); ExpandOneAct = new QAction(QIcon("images/expand2.png"), tr("&Expand"), this); connect(ExpandOneAct, SIGNAL(triggered()), this, SLOT(expandOne())); CollapseOneAct = new QAction(QIcon("images/collapse2.png"), tr("&Collapse"), this); connect(CollapseOneAct, SIGNAL(triggered()), this, SLOT(collapseOne())); ClearAct = new QAction(QIcon("images/clear.png"), tr("&Clear"), this); connect(ClearAct, SIGNAL(triggered()), this, SLOT(clear())); initialAction(); GraphicAction.push_back(DeleteAct); GraphicAction.push_back(InsertAChildAct); GraphicAction.push_back(InsertASiblingAct); GraphicAction.push_back(InsertAParentAct); GraphicAction.push_back(EditAct); GraphicAction.push_back(CutAct); GraphicAction.push_back(CopyAct); GraphicAction.push_back(PasteAct); GraphicAction.push_back(RedoAct); GraphicAction.push_back(UndoAct); GraphicAction.push_back(InsertARectangleAct); GraphicAction.push_back(InsertACircleAct); GraphicAction.push_back(InsertATriangleAct); GraphicAction.push_back(UpAct); GraphicAction.push_back(DownAct); GraphicAction.push_back(ExpandAct); GraphicAction.push_back(CollapseAct); GraphicAction.push_back(ExpandOneAct); GraphicAction.push_back(CollapseOneAct); GraphicAction.push_back(ClearAct); Gui_presentation->setGraphicAction(GraphicAction); }