X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fforms%2Fcadtoolbarsnap.cpp;h=833bd42dd26ea3c34ee2360507b610e534991921;hb=d774c2655ba2c3657a565f325411144452392277;hp=9acce483b7b1008a3b5dc385a53c639e2aad8204;hpb=658ad9ec22e868cc5f575e6c4f3d38c153f6af51;p=architektonas diff --git a/src/forms/cadtoolbarsnap.cpp b/src/forms/cadtoolbarsnap.cpp index 9acce48..833bd42 100644 --- a/src/forms/cadtoolbarsnap.cpp +++ b/src/forms/cadtoolbarsnap.cpp @@ -15,279 +15,36 @@ #include "cadtoolbarsnap.h" #include "cadtoolbar.h" -#include "qg_actionhandler.h" -#include "rs_debug.h" +#include "createqtactions.h" -CadToolBarSnap::CadToolBarSnap(QWidget * parent/*= 0*/, Qt::WindowFlags flags/*= 0*/): - QWidget(parent, flags), actionHandler(NULL), cadToolBar(NULL) +CadToolBarSnap::CadToolBarSnap(CadToolBar * parent, Qt::WindowFlags flags/*= 0*/): + QWidget((QWidget *)parent, flags) { - ui.setupUi(this); -} - -CadToolBarSnap::~CadToolBarSnap() -{ -} - -//void CadToolBarSnap::mousePressEvent(QMouseEvent* e) { -// if (e->button()==RightButton && cadToolBar!=NULL) { -//cadToolBar->back(); -// e->accept(); -// } -//} - -void CadToolBarSnap::contextMenuEvent(QContextMenuEvent * e) -{ - e->accept(); -} - -void CadToolBarSnap::setCadToolBar(CadToolBar * tb) -{ - cadToolBar = tb; - - if (tb!=NULL) - { - actionHandler = tb->getActionHandler(); - actionHandler->setCadToolBarSnap(this); - } - else - RS_DEBUG->print(RS_Debug::D_ERROR, "CadToolBarSnap::setCadToolBar(): No valid toolbar set."); -} - -void CadToolBarSnap::snapFree() -{ - if (actionHandler!=NULL) - { - disableSnaps(); - ui.bFree->setChecked(true); - actionHandler->slotSnapFree(); - } -} - -void CadToolBarSnap::snapGrid() -{ - if (actionHandler!=NULL) - { - actionHandler->slotSnapGrid(); - disableSnaps(); - ui.bGrid->setChecked(true); - } -} - -void CadToolBarSnap::snapEndpoint() { - if (actionHandler!=NULL) { - actionHandler->slotSnapEndpoint(); - disableSnaps(); - ui.bEndpoint->setChecked(true); - } -} - -void CadToolBarSnap::snapOnEntity() { - if (actionHandler!=NULL) { - actionHandler->slotSnapOnEntity(); - disableSnaps(); - ui.bOnEntity->setChecked(true); - } -} - -void CadToolBarSnap::snapCenter() { - if (actionHandler!=NULL) { - actionHandler->slotSnapCenter(); - disableSnaps(); - ui.bCenter->setChecked(true); - } -} - -void CadToolBarSnap::snapMiddle() { - if (actionHandler!=NULL) { - actionHandler->slotSnapMiddle(); - disableSnaps(); - ui.bMiddle->setChecked(true); - } -} - -void CadToolBarSnap::snapDist() { - if (actionHandler!=NULL) { - actionHandler->slotSnapDist(); - disableSnaps(); - ui.bDist->setChecked(true); - } -} - -void CadToolBarSnap::snapIntersection() { - if (actionHandler!=NULL) { - actionHandler->slotSnapIntersection(); - disableSnaps(); - ui.bIntersection->setChecked(true); - } -} - -void CadToolBarSnap::snapIntersectionManual() -{ - if (actionHandler!=NULL) - { - actionHandler->slotSnapIntersectionManual(); - //disableSnaps(); - //bIntersectionManual->setChecked(true); - } -} - -void CadToolBarSnap::restrictNothing() -{ - if (actionHandler!=NULL) - { - actionHandler->slotRestrictNothing(); - disableRestrictions(); - ui.bResNothing->setChecked(true); - } -} + QGridLayout * gridLayout = new QGridLayout(this); + gridLayout->setSpacing(0); + gridLayout->setContentsMargins(0, 0, 0, 0); -void CadToolBarSnap::restrictOrthogonal() -{ - if (actionHandler!=NULL) - { - actionHandler->slotRestrictOrthogonal(); - disableRestrictions(); - ui.bResOrthogonal->setChecked(true); - } -} - -void CadToolBarSnap::restrictHorizontal() -{ - if (actionHandler!=NULL) - { - actionHandler->slotRestrictHorizontal(); - disableRestrictions(); - ui.bResHorizontal->setChecked(true); - } -} - -void CadToolBarSnap::restrictVertical() -{ - if (actionHandler!=NULL) - { - actionHandler->slotRestrictVertical(); - disableRestrictions(); - ui.bResVertical->setChecked(true); - } -} - -void CadToolBarSnap::disableSnaps() -{ - if (ui.bFree->isChecked()) - ui.bFree->setChecked(false); + gridLayout->addWidget(parent->CreateBackButton(this), 0, 0, 1, 2); - if (ui.bGrid->isChecked()) - ui.bGrid->setChecked(false); + gridLayout->addWidget(parent->CreateToolButton(actionSnapFree), 1, 0, 1, 1); + gridLayout->addWidget(parent->CreateToolButton(actionSnapGrid), 1, 1, 1, 1); + gridLayout->addWidget(parent->CreateToolButton(actionSnapEndpoint), 2, 0, 1, 1); + gridLayout->addWidget(parent->CreateToolButton(actionSnapOnEntity), 2, 1, 1, 1); + gridLayout->addWidget(parent->CreateToolButton(actionSnapCenter), 3, 0, 1, 1); + gridLayout->addWidget(parent->CreateToolButton(actionSnapMiddle), 3, 1, 1, 1); + gridLayout->addWidget(parent->CreateToolButton(actionSnapDist), 4, 0, 1, 1); + gridLayout->addWidget(parent->CreateToolButton(actionSnapIntersection), 4, 1, 1, 1); + gridLayout->addWidget(parent->CreateToolButton(actionSnapIntersectionManual), 5, 0, 1, 1); - if (ui.bEndpoint->isChecked()) - ui.bEndpoint->setChecked(false); + gridLayout->addWidget(parent->CreateToolButton(actionRestrictNothing), 7, 0, 1, 1); + gridLayout->addWidget(parent->CreateToolButton(actionRestrictOrthogonal), 7, 1, 1, 1); + gridLayout->addWidget(parent->CreateToolButton(actionRestrictHorizontal), 8, 0, 1, 1); + gridLayout->addWidget(parent->CreateToolButton(actionRestrictVertical), 8, 1, 1, 1); - if (ui.bOnEntity->isChecked()) - ui.bOnEntity->setChecked(false); - - if (ui.bCenter->isChecked()) - ui.bCenter->setChecked(false); - - if (ui.bMiddle->isChecked()) - ui.bMiddle->setChecked(false); - - if (ui.bDist->isChecked()) - ui.bDist->setChecked(false); - - if (ui.bIntersection->isChecked()) - ui.bIntersection->setChecked(false); - - if (ui.bIntersectionManual->isChecked()) - ui.bIntersectionManual->setChecked(false); + gridLayout->addWidget(parent->CreateToolButton(actionSetRelativeZero), 10, 0, 1, 1); + gridLayout->addWidget(parent->CreateToolButton(actionLockRelativeZero), 10, 1, 1, 1); } -void CadToolBarSnap::disableRestrictions() -{ - if (ui.bResNothing->isChecked()) - ui.bResNothing->setChecked(false); - - if (ui.bResOrthogonal->isChecked()) - ui.bResOrthogonal->setChecked(false); - - if (ui.bResHorizontal->isChecked()) - ui.bResHorizontal->setChecked(false); - - if (ui.bResVertical->isChecked()) - ui.bResVertical->setChecked(false); -} - -void CadToolBarSnap::setSnapMode(int sm) -{ - switch (sm) - { - case RS2::SnapFree: - ui.bFree->setChecked(true); - break; - case RS2::SnapEndpoint: - ui.bEndpoint->setChecked(true); - break; - case RS2::SnapGrid: - ui.bGrid->setChecked(true); - break; - case RS2::SnapOnEntity: - ui.bOnEntity->setChecked(true); - break; - case RS2::SnapCenter: - ui.bCenter->setChecked(true); - break; - case RS2::SnapMiddle: - ui.bMiddle->setChecked(true); - break; - case RS2::SnapDist: - ui.bDist->setChecked(true); - break; - case RS2::SnapIntersection: - ui.bIntersection->setChecked(true); - break; - default: - break; - } -} - -void CadToolBarSnap::setSnapRestriction(int sr) -{ - switch (sr) - { - default: - case RS2::RestrictNothing: - ui.bResNothing->setChecked(true); - break; - case RS2::RestrictOrthogonal: - ui.bResOrthogonal->setChecked(true); - break; - case RS2::RestrictHorizontal: - ui.bResHorizontal->setChecked(true); - break; - case RS2::RestrictVertical: - ui.bResVertical->setChecked(true); - break; - } -} - -void CadToolBarSnap::setRelativeZero() -{ - if (cadToolBar!=NULL && actionHandler!=NULL) - actionHandler->slotSetRelativeZero(); -} - -void CadToolBarSnap::lockRelativeZero(bool on) -{ - if (cadToolBar!=NULL && actionHandler!=NULL) - actionHandler->slotLockRelativeZero(on); -} - -void CadToolBarSnap::setLockRelativeZero(bool on) -{ - ui.bLockRelZero->setChecked(on); -} - -void CadToolBarSnap::back() +CadToolBarSnap::~CadToolBarSnap() { - if (cadToolBar != NULL) - cadToolBar->back(); }