src/linetypes/modelobject.cpp

changeset 1236
861bf8ebb8ec
parent 1161
e6a5ff67c057
child 1251
e75cc5bff076
equal deleted inserted replaced
1235:b2e44b23b42a 1236:861bf8ebb8ec
300 return model()->getObject(lineNumber() - 1); 300 return model()->getObject(lineNumber() - 1);
301 } 301 }
302 302
303 // ============================================================================= 303 // =============================================================================
304 // 304 //
305 // Is the previous object INVERTNEXT?
306 //
307 bool LDObject::previousIsInvertnext (LDBfc*& ptr)
308 {
309 LDObject* prev = previous();
310
311 if (prev and prev->type() == LDObjectType::Bfc and static_cast<LDBfc*> (prev)->statement() == BfcStatement::InvertNext)
312 {
313 ptr = static_cast<LDBfc*> (prev);
314 return true;
315 }
316
317 return false;
318 }
319
320 // =============================================================================
321 //
322 // Moves this object using the given vertex as a movement List 305 // Moves this object using the given vertex as a movement List
323 // 306 //
324 void LDObject::move (Vertex vect) 307 void LDObject::move (Vertex vect)
325 { 308 {
326 if (hasMatrix()) 309 if (hasMatrix())
426 setTransformationMatrix (transformationMatrix() * matrixModifier); 409 setTransformationMatrix (transformationMatrix() * matrixModifier);
427 return; 410 return;
428 } 411 }
429 412
430 // Subfile is not flat. Resort to invertnext. 413 // Subfile is not flat. Resort to invertnext.
431 int idx = lineNumber(); 414 setInverted(not this->isInverted());
432
433 if (idx > 0)
434 {
435 LDBfc* bfc = dynamic_cast<LDBfc*> (previous());
436
437 if (bfc and bfc->statement() == BfcStatement::InvertNext)
438 {
439 // This is prefixed with an invertnext, thus remove it.
440 this->model()->remove(bfc);
441 return;
442 }
443 }
444
445 // Not inverted, thus prefix it with a new invertnext.
446 this->model()->emplaceAt<LDBfc>(idx, BfcStatement::InvertNext);
447 } 415 }
448 416
449 // ============================================================================= 417 // =============================================================================
450 // 418 //
451 void LDBezierCurve::invert() 419 void LDBezierCurve::invert()
735 703
736 QString LDBfc::objectListText() const 704 QString LDBfc::objectListText() const
737 { 705 {
738 return statementToString(); 706 return statementToString();
739 } 707 }
708
709 bool LDObject::isInverted() const
710 {
711 return m_hasInvertNext;
712 }
713
714 void LDObject::setInverted(bool value)
715 {
716 changeProperty(&m_hasInvertNext, value);
717 }

mercurial