本文整理汇总了C++中MgShape类的典型用法代码示例。如果您正苦于以下问题:C++ MgShape类的具体用法?C++ MgShape怎么用?C++ MgShape使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MgShape类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: snap
void MgCmdManagerImpl::eraseWnd(const MgMotion* sender)
{
Box2d snap(sender->view->xform()->getWndRectM());
std::vector<int> delIds;
void *it = NULL;
MgShapes* s = sender->view->shapes();
for (MgShape* shape = s->getFirstShape(it); shape; shape = s->getNextShape(it)) {
if (shape->shape()->hitTestBox(snap)) {
delIds.push_back(shape->getID());
}
}
s->freeIterator(it);
if (!delIds.empty()
&& sender->view->shapeWillDeleted(s->findShape(delIds.front()))) {
MgShapesLock locker(MgShapesLock::Remove, sender->view);
for (std::vector<int>::iterator i = delIds.begin(); i != delIds.end(); ++i) {
MgShape* shape = s->findShape(*i);
if (shape && sender->view->removeShape(shape)) {
shape->release();
}
}
sender->view->regenAll();
}
}
示例2: limits
float MgComposite::_hitTest(const Point2d& pt, float tol, Point2d& nearpt,
int& segment, bool& inside) const
{
void* it;
float mindist = 1e10f;
Point2d tmpNear;
int tmpseg;
bool tmpIn;
Box2d limits(pt, 2 * tol, 0);
segment = 0;
for (MgShape* sp = _shapes->getFirstShape(it); sp;
sp = _shapes->getNextShape(it))
{
if (limits.isIntersect(sp->shapec()->getExtent())) {
float d = sp->shapec()->hitTest(pt, tol, tmpNear, tmpseg, tmpIn);
if (mindist > d - _MGZERO) {
mindist = d;
nearpt = tmpNear;
segment = sp->getID();
inside = tmpIn;
}
}
}
_shapes->freeIterator(it);
return mindist;
}
示例3: limits
float MgComposite::_hitTest(const Point2d& pt, float tol, MgHitResult& res) const
{
void* it;
MgHitResult tmpRes;
Box2d limits(pt, 2 * tol, 0);
res.segment = 0;
res.dist = _FLT_MAX;
for (MgShape* sp = _shapes->getFirstShape(it); sp;
sp = _shapes->getNextShape(it))
{
if (limits.isIntersect(sp->shapec()->getExtent())) {
float d = sp->shapec()->hitTest(pt, tol, tmpRes);
if (res.dist > d - _MGZERO)
{
res = tmpRes;
res.dist = d;
res.segment = sp->getID();
}
}
}
_shapes->freeIterator(it);
return res.segment != 0;
}
示例4: locker
bool MgCmdErase::touchEnded(const MgMotion* sender)
{
MgShapes* s = sender->view->shapes();
if (!m_delIds.empty()
&& sender->view->shapeWillDeleted(s->findShape(m_delIds.front()))) {
MgShapesLock locker(s, MgShapesLock::Remove);
int count = 0;
for (std::vector<int>::iterator it = m_delIds.begin(); it != m_delIds.end(); ++it) {
MgShape* shape = s->findShape(*it);
if (shape && sender->view->removeShape(shape)) {
shape->release();
count++;
}
}
if (count > 0) {
sender->view->regen();
}
}
m_delIds.clear();
m_boxsel = false;
sender->view->redraw(false);
return true;
}
示例5: size
MgShape* MgCmdManagerImpl::addImageShape(const MgMotion* sender,
const char* name, float width, float height)
{
if (!name || *name == 0 || width < 1 || height < 1)
return NULL;
Vector2d size(Vector2d(width, height) * sender->view->xform()->displayToWorld());
while (fabsf(size.x) > 200.f || fabsf(size.y) > 200.f) {
size *= 0.95f;
}
Box2d rect(sender->view->xform()->getWndRectW() + Vector2d(10.f, -10.f));
rect = Box2d(rect.leftTop(), rect.leftTop() + size);
rect *= sender->view->xform()->worldToModel();
MgShapeT<MgImageShape> shape;
MgImageShape* imagesp = (MgImageShape*)shape.shape();
shape.context()->setLineStyle(kGiLineNull); // 默认没有边框
shape.context()->setFillColor(GiColor::White()); // 设为实填充,避免在中心无法点中
imagesp->setName(name);
imagesp->setRect2P(rect.leftTop(), rect.rightBottom());
MgShapesLock locker(MgShapesLock::Add, sender->view);
if (sender->view->shapeWillAdded(&shape)) {
MgShape* newsp = sender->view->shapes()->addShape(shape);
sender->view->shapeAdded(newsp);
sender->view->setNewShapeID(newsp->getID());
sender->view->cancel(sender);
return newsp;
}
return NULL;
}
示例6: _draw
bool MgGroup::_draw(int mode, GiGraphics& gs, const GiContext& ctx, int segment) const
{
MgShape* sp = _shapes->findShape(segment);
if (sp) {
return sp->draw(mode, gs, ctx.isNullLine() ? NULL : &ctx, -1);
}
return __super::_draw(mode, gs, ctx, segment);
}
示例7: _transform
void MgComposite::_transform(const Matrix2d& mat)
{
void* it;
for (MgShape* sp = _shapes->getFirstShape(it); sp;
sp = _shapes->getNextShape(it)) {
sp->shape()->transform(mat);
}
_shapes->freeIterator(it);
}
示例8: _offset
bool MgGroup::_offset(const Vector2d& vec, int segment)
{
MgShape* sp = _shapes->findShape(segment);
if (sp && canOffsetShapeAlone(sp)) {
return sp->shape()->offset(vec, -1);
}
return __super::_offset(vec, segment);
}
示例9:
GiContext& GiCoreView::getContext(bool forChange)
{
if (!forChange) {
_contextEditing = false;
}
MgShape* shape = NULL;
impl->_cmds->getSelection(impl, 1, &shape, forChange);
_tmpContext = shape ? *shape->context() : *impl->context();
return _tmpContext;
}
示例10: _update
void MgComposite::_update()
{
void* it;
_extent.empty();
for (MgShape* sp = _shapes->getFirstShape(it); sp;
sp = _shapes->getNextShape(it)) {
sp->shape()->update();
_extent.unionWith(sp->shapec()->getExtent());
}
_shapes->freeIterator(it);
}
示例11: _draw
bool MgComposite::_draw(int mode, GiGraphics& gs, const GiContext& ctx, int) const
{
void* it;
int n = 0;
for (MgShape* sp = _shapes->getFirstShape(it); sp;
sp = _shapes->getNextShape(it)) {
n += sp->draw(mode, gs, ctx.isNullLine() ? NULL : &ctx, -1) ? 1 : 0;
}
_shapes->freeIterator(it);
return n > 0;
}
示例12: _offset
bool MgComposite::_offset(const Vector2d& vec, int)
{
void* it;
int n = 0;
for (MgShape* sp = _shapes->getFirstShape(it); sp;
sp = _shapes->getNextShape(it)) {
n += sp->shape()->offset(vec, -1) ? 1 : 0;
}
_shapes->freeIterator(it);
return n > 0;
}
示例13: limits
bool MgCommandDraw::_click(const MgMotion* sender)
{
Box2d limits(sender->pointM, mgDisplayMmToModel(10, sender), 0);
Point2d nearpt;
MgShape* shape = sender->view->shapes()->hitTest(limits, nearpt);
if (shape) {
g_newShapeID = shape->getID();
mgGetCommandManager()->setCommand(sender, "select");
}
return shape || longPress(sender);
}
示例14: hitTest
bool MgCmdErase::click(const MgMotion* sender)
{
MgShape* shape = hitTest(sender);
if (shape && sender->view->shapeWillDeleted(shape)) {
MgShapesLock locker(sender->view->shapes(), MgShapesLock::Remove);
if (sender->view->removeShape(shape)) {
shape->release();
sender->view->regen();
}
}
return true;
}
示例15: limits
bool MgCommandDraw::_click(const MgMotion* sender)
{
Box2d limits(sender->pointM, sender->displayMmToModel(10.f), 0);
MgHitResult res;
MgShape* shape = sender->view->shapes()->hitTest(limits, res);
if (shape) {
sender->view->setNewShapeID(shape->getID());
sender->toSelectCommand();
LOGD("Command (%s) cancelled after the shape #%d clicked.", getName(), shape->getID());
}
return shape || (sender->view->useFinger() && longPress(sender));
}