Example #1
0
void MyEvtHandler::OnDragRight(bool WXUNUSED(draw), double x, double y, int WXUNUSED(keys), int attachment)
{
  // Force attachment to be zero for now
  attachment = 0;

  wxClientDC dc(GetShape()->GetCanvas());
  GetShape()->GetCanvas()->PrepareDC(dc);

  wxPen dottedPen(*wxBLACK, 1, wxDOT);
  dc.SetLogicalFunction(OGLRBLF);
  dc.SetPen(dottedPen);
  double xp, yp;
  GetShape()->GetAttachmentPosition(attachment, &xp, &yp);
  dc.DrawLine((long) xp, (long) yp, (long) x, (long) y);
}
Example #2
0
// Returns true if the unichar sets are equal between the shapes.
bool ShapeTable::EqualUnichars(int shape_id1, int shape_id2) const {
  const Shape& shape1 = GetShape(shape_id1);
  const Shape& shape2 = GetShape(shape_id2);
  for (int c1 = 0; c1 < shape1.size(); ++c1) {
    int unichar_id1 = shape1[c1].unichar_id;
    if (!shape2.ContainsUnichar(unichar_id1))
      return false;
  }
  for (int c2 = 0; c2 < shape2.size(); ++c2) {
    int unichar_id2 = shape2[c2].unichar_id;
    if (!shape1.ContainsUnichar(unichar_id2))
      return false;
  }
  return true;
}
/*
 * Function BuildPadShapePolygon
 * Build the Corner list of the polygonal shape,
 * depending on shape, extra size (clearance ...) pad and orientation
 * Note: for Round and oval pads this function is equivalent to
 * TransformShapeWithClearanceToPolygon, but not for other shapes
 */
void D_PAD::BuildPadShapePolygon( SHAPE_POLY_SET& aCornerBuffer,
                                  wxSize aInflateValue, int aSegmentsPerCircle,
                                  double aCorrectionFactor ) const
{
    wxPoint corners[4];
    wxPoint PadShapePos = ShapePos();         /* Note: for pad having a shape offset,
                                                     * the pad position is NOT the shape position */
    switch( GetShape() )
    {
    case PAD_SHAPE_CIRCLE:
    case PAD_SHAPE_OVAL:
        TransformShapeWithClearanceToPolygon( aCornerBuffer, aInflateValue.x,
                                              aSegmentsPerCircle, aCorrectionFactor );
        break;

    case PAD_SHAPE_TRAPEZOID:
    case PAD_SHAPE_RECT:
        aCornerBuffer.NewOutline();

        BuildPadPolygon( corners, aInflateValue, m_Orient );
        for( int ii = 0; ii < 4; ii++ )
        {
            corners[ii] += PadShapePos;          // Shift origin to position
            aCornerBuffer.Append( corners[ii].x, corners[ii].y );
        }

        break;
    }
}
void LRSeparateComplex::FixPosWithShape(sm::vec2& pos, const std::string& filepath) const
{
	std::string path = filepath.substr(0, filepath.find_last_of('.')) + "_shape.json";
	std::string shape_path = m_dir + "\\" + m_point_dir + "\\" + path;
	if (!ee::FileHelper::IsFileExist(shape_path)) {
		return;
	}

	auto sym = ee::SymbolMgr::Instance()->FetchSymbol(shape_path);
	auto shape_symbol = std::dynamic_pointer_cast<eshape::Symbol>(sym);
	if (!shape_symbol) {
		throw ee::Exception("shape file err:%s", filepath);
	}
	
	auto shape = shape_symbol->GetShape();
	if (!shape) {
		throw ee::Exception("shape file empty:%s", filepath);
	}

	if (auto point = std::dynamic_pointer_cast<eshape::PointShape>(shape)) {
		pos += point->GetPos();
	} else {
		throw ee::Exception("shape file is not point:%s", filepath);
	}
}
LAYER_MSK TRACK::GetLayerMask() const
{
    if( Type() == PCB_VIA_T )
    {
        int via_type = GetShape();

        if( via_type == VIA_THROUGH )
            return ALL_CU_LAYERS;

        // VIA_BLIND_BURIED or VIA_MICRVIA:

        LAYER_NUM bottom_layer, top_layer;

        // LayerPair() knows how layers are stored
        ( (SEGVIA*) this )->LayerPair( &top_layer, &bottom_layer );

        LAYER_MSK layermask = NO_LAYERS;

        while( bottom_layer <= top_layer )
        {
            layermask |= ::GetLayerMask( bottom_layer );
            ++bottom_layer;
        }

        return layermask;
    }
    else
    {
        return ::GetLayerMask( m_Layer );
    }
}
Example #6
0
void MyEvtHandler::OnEndDragRight(double x, double y, int WXUNUSED(keys), int WXUNUSED(attachment))
{
  GetShape()->GetCanvas()->ReleaseMouse();
  MyCanvas *canvas = (MyCanvas *)GetShape()->GetCanvas();

  // Check if we're on an object
  int new_attachment;
  wxShape *otherShape = canvas->FindFirstSensitiveShape(x, y, &new_attachment, OP_DRAG_RIGHT);

  if (otherShape && !otherShape->IsKindOf(CLASSINFO(wxLineShape)))
  {
    canvas->view->GetDocument()->GetCommandProcessor()->Submit(
      new DiagramCommand(_T("wxLineShape"), OGLEDIT_ADD_LINE, (DiagramDocument *)canvas->view->GetDocument(), CLASSINFO(wxLineShape),
      0.0, 0.0, false, NULL, GetShape(), otherShape));
  }
}
int D_PAD::boundingRadius() const
{
    int x, y;
    int radius;

    switch( GetShape() )
    {
    case PAD_SHAPE_CIRCLE:
        radius = m_Size.x / 2;
        break;

    case PAD_SHAPE_OVAL:
        radius = std::max( m_Size.x, m_Size.y ) / 2;
        break;

    case PAD_SHAPE_RECT:
        radius = 1 + KiROUND( EuclideanNorm( m_Size ) / 2 );
        break;

    case PAD_SHAPE_TRAPEZOID:
        x = m_Size.x + std::abs( m_DeltaSize.y );   // Remember: m_DeltaSize.y is the m_Size.x change
        y = m_Size.y + std::abs( m_DeltaSize.x );   // Remember: m_DeltaSize.x is the m_Size.y change
        radius = 1 + KiROUND( hypot( x, y ) / 2 );
        break;

    default:
        radius = 0;
    }

    return radius;
}
Example #8
0
void FollowHub::Update()
{
    _timer++;
    if ( _timer > ( _powerA ? TIMER / 2 : TIMER ) ) {
        _timer = 0;
        _count++;
        if ( IsOnScreen() ) {
            if ( _powerB )
                Spawn( new Chaser( GetPosition() ) );
            else
                Spawn( new Follow( GetPosition() ) );
            PlaySoundRandom( Lib::SOUND_ENEMY_SPAWN );
        }
    }

    if ( GetPosition()._x < 0 )
        _dir.Set( 1, 0 );
    else if ( GetPosition()._x > Lib::WIDTH )
        _dir.Set( -1, 0 );
    else if ( GetPosition()._y < 0 )
        _dir.Set( 0, 1 );
    else if ( GetPosition()._y > Lib::HEIGHT )
        _dir.Set( 0, -1 );
    else if ( _count > 3 ) {
        _dir.Rotate( -M_PI / M_TWO );
        _count = 0;
    }

    fixed s = _powerA ? M_PT_ZERO_ONE * 5 + M_PT_ONE : M_PT_ZERO_ONE * 5;
    Rotate( s );
    GetShape( 0 ).Rotate( -s );

    Move( _dir * SPEED );
}
Example #9
0
// Merges shapes with a common unichar over the [start, end) interval.
// Assumes single unichar per shape.
void ShapeTable::ForceFontMerges(int start, int end) {
  for (int s1 = start; s1 < end; ++s1) {
    if (MasterDestinationIndex(s1) == s1 && GetShape(s1).size() == 1) {
      int unichar_id = GetShape(s1)[0].unichar_id;
      for (int s2 = s1 + 1; s2 < end; ++s2) {
        if (MasterDestinationIndex(s2) == s2 && GetShape(s2).size() == 1 &&
            unichar_id == GetShape(s2)[0].unichar_id) {
          MergeShapes(s1, s2);
        }
      }
    }
  }
  ShapeTable compacted(*unicharset_);
  compacted.AppendMasterShapes(*this);
  *this = compacted;
}
Example #10
0
    RigidBody2D::RigidBody2D(const RigidBody2D& other, Object& newObj)
        : Collider2D(other, newObj)
    {
        b2BodyDef bd;
        b2FixtureDef fdf;

        auto& pos = getObject()->getGlobalPosition();
        bd.angle = glm::eulerAngles(getObject()->getGlobalRotation()).z;
        bd.position = b2Vec2(pos.x, pos.y);
        bd.userData = this;

        auto om = other.m_body;

        bd.type = om->GetType();
        newObj.setIgnoreParent(other.getObject()->ignoresParent());
        fdf.isSensor = om->GetFixtureList()->IsSensor();
        bd.allowSleep = om->IsSleepingAllowed();

        m_body = other.m_worldRef2D.m_worldData2D->CreateBody(&bd);

        auto omf = om->GetFixtureList();

        fdf.filter = omf->GetFilterData();
        fdf.friction = omf->GetFriction();
        fdf.restitution = omf->GetRestitution();

        fdf.shape = omf->GetShape();
        fdf.density = omf->GetDensity();

        m_body->CreateFixture(&fdf);
    }
Example #11
0
wxString D_PAD::ShowPadShape() const
{
    switch( GetShape() )
    {
    case PAD_SHAPE_CIRCLE:
        return _( "Circle" );

    case PAD_SHAPE_OVAL:
        return _( "Oval" );

    case PAD_SHAPE_RECT:
        return _( "Rect" );

    case PAD_SHAPE_TRAPEZOID:
        return _( "Trap" );

    case PAD_SHAPE_ROUNDRECT:
        return _( "Roundrect" );

    case PAD_SHAPE_CUSTOM:
        return _( "CustomShape" );

    default:
        return wxT( "???" );
    }
}
Example #12
0
int D_PAD::boundingRadius() const
{
    int x, y;
    int radius;

    switch( GetShape() )
    {
    case PAD_CIRCLE:
        radius = m_Size.x / 2;
        break;

    case PAD_OVAL:
        radius = std::max( m_Size.x, m_Size.y ) / 2;
        break;

    case PAD_RECT:
        radius = 1 + (int) ( sqrt( (double) m_Size.y * m_Size.y
                                 + (double) m_Size.x * m_Size.x ) / 2 );
        break;

    case PAD_TRAPEZOID:
        x = m_Size.x + std::abs( m_DeltaSize.y );   // Remember: m_DeltaSize.y is the m_Size.x change
        y = m_Size.y + std::abs( m_DeltaSize.x );   // Remember: m_DeltaSize.x is the m_Size.y change
        radius = 1 + (int) ( sqrt( (double) y * y + (double) x * x ) / 2 );
        break;

    default:
        radius = 0;
    }

    return radius;
}
Example #13
0
// Returns a string listing the classes/fonts in a shape.
STRING ShapeTable::DebugStr(int shape_id) const {
  if (shape_id < 0 || shape_id >= shape_table_.size())
    return STRING("INVALID_UNICHAR_ID");
  const Shape& shape = GetShape(shape_id);
  STRING result;
  result.add_str_int("Shape", shape_id);
  if (shape.size() > 100) {
    result.add_str_int(" Num unichars=", shape.size());
    return result;
  }
  for (int c = 0; c < shape.size(); ++c) {
    result.add_str_int(" c_id=", shape[c].unichar_id);
    result += "=";
    result += unicharset_->id_to_unichar(shape[c].unichar_id);
    if (shape.size() < 10) {
      result.add_str_int(", ", shape[c].font_ids.size());
      result += " fonts =";
      int num_fonts = shape[c].font_ids.size();
      if (num_fonts > 10) {
        result.add_str_int(" ", shape[c].font_ids[0]);
        result.add_str_int(" ... ", shape[c].font_ids[num_fonts - 1]);
      } else {
        for (int f = 0; f < num_fonts; ++f) {
          result.add_str_int(" ", shape[c].font_ids[f]);
        }
      }
    }
  }
  return result;
}
Example #14
0
// Returns false if the unichars in neither shape is a subset of the other.
bool ShapeTable::SubsetUnichar(int shape_id1, int shape_id2) const {
  const Shape& shape1 = GetShape(shape_id1);
  const Shape& shape2 = GetShape(shape_id2);
  int c1, c2;
  for (c1 = 0; c1 < shape1.size(); ++c1) {
    int unichar_id1 = shape1[c1].unichar_id;
    if (!shape2.ContainsUnichar(unichar_id1))
      break;
  }
  for (c2 = 0; c2 < shape2.size(); ++c2) {
    int unichar_id2 = shape2[c2].unichar_id;
    if (!shape1.ContainsUnichar(unichar_id2))
      break;
  }
  return c1 == shape1.size() || c2 == shape2.size();
}
Example #15
0
void MyEvtHandler::OnBeginDragRight(double x, double y, int WXUNUSED(keys), int attachment)
{
  // Force attachment to be zero for now. Eventually we can deal with
  // the actual attachment point, e.g. a rectangle side if attachment mode is on.
  attachment = 0;

  wxClientDC dc(GetShape()->GetCanvas());
  GetShape()->GetCanvas()->PrepareDC(dc);

  wxPen dottedPen(*wxBLACK, 1, wxDOT);
  dc.SetLogicalFunction(OGLRBLF);
  dc.SetPen(dottedPen);
  double xp, yp;
  GetShape()->GetAttachmentPosition(attachment, &xp, &yp);
  dc.DrawLine((long) xp, (long) yp, (long) x, (long) y);
  GetShape()->GetCanvas()->CaptureMouse();
}
Example #16
0
// Returns true if any shape contains multiple unichars.
bool ShapeTable::AnyMultipleUnichars() const {
  int num_shapes = NumShapes();
  for (int s1 = 0; s1 < num_shapes; ++s1) {
    if (MasterDestinationIndex(s1) != s1) continue;
    if (GetShape(s1).size() > 1)
      return true;
  }
  return false;
}
Example #17
0
void Cursor::Show (void) {
  if (x-1>=0 || y-1>=0 || x-1+sizex<320 || y-1+sizey<200)
    GetShape (x-1,y-1,sizex,sizey,buffer);
  PutPixel (x,y+1,15);
  PutPixel (x,y-1,15);
  PutPixel (x+1,y,15);
  PutPixel (x-1,y,15);
  visible=1;
}
Example #18
0
// Returns the sum of the font counts in the master shape.
int ShapeTable::MasterFontCount(int shape_id) const {
  int master_id = MasterDestinationIndex(shape_id);
  const Shape& shape = GetShape(master_id);
  int font_count = 0;
  for (int c = 0; c < shape.size(); ++c) {
    font_count += shape[c].font_ids.size();
  }
  return font_count;
}
Example #19
0
int Clef::GetClefLocOffset() const
{
    int offset = 0;
    if (GetShape() == CLEFSHAPE_G)
        offset = -4;
    else if (GetShape() == CLEFSHAPE_F)
        offset = 4;

    offset += (GetLine() - 1) * 2;

    int disPlace = 0;
    if (GetDisPlace() == PLACE_above)
        disPlace = -1;
    else if (GetDisPlace() == PLACE_below)
        disPlace = 1;

    if ((disPlace != 0) && (GetDis() != OCTAVE_DIS_NONE)) offset += (disPlace * (GetDis() - 1));

    return offset;
}
Example #20
0
int D_PAD::boundingRadius() const
{
    int x, y;
    int radius;

    switch( GetShape() )
    {
    case PAD_SHAPE_CIRCLE:
        radius = m_Size.x / 2;
        break;

    case PAD_SHAPE_OVAL:
        radius = std::max( m_Size.x, m_Size.y ) / 2;
        break;

    case PAD_SHAPE_RECT:
        radius = 1 + KiROUND( EuclideanNorm( m_Size ) / 2 );
        break;

    case PAD_SHAPE_TRAPEZOID:
        x = m_Size.x + std::abs( m_DeltaSize.y );   // Remember: m_DeltaSize.y is the m_Size.x change
        y = m_Size.y + std::abs( m_DeltaSize.x );   // Remember: m_DeltaSize.x is the m_Size.y change
        radius = 1 + KiROUND( hypot( x, y ) / 2 );
        break;

    case PAD_SHAPE_ROUNDRECT:
        radius = GetRoundRectCornerRadius();
        x = m_Size.x >> 1;
        y = m_Size.y >> 1;
        radius += 1 + KiROUND( EuclideanNorm( wxSize( x - radius, y - radius )));
        break;

    case PAD_SHAPE_CUSTOM:
        radius = 0;

        for( int cnt = 0; cnt < m_customShapeAsPolygon.OutlineCount(); ++cnt )
        {
            const SHAPE_LINE_CHAIN& poly = m_customShapeAsPolygon.COutline( cnt );
            for( int ii = 0; ii < poly.PointCount(); ++ii )
            {
                int dist = KiROUND( poly.CPoint( ii ).EuclideanNorm() );
                radius = std::max( radius, dist );
            }
        }

        radius += 1;
        break;

    default:
        radius = 0;
    }

    return radius;
}
void __fastcall TOrgChartRLMainForm::dxDBOrgChartCreateNode(TObject *Sender,
	  TdxOcNode *Node)
{
	if (Table1->FindField("width")->AsInteger > 50)
	  Node->Width = Table1->FindField("width")->AsInteger;
	if (Table1->FindField("height")->AsInteger > 50)
	  Node->Height = Table1->FindField("height")->AsInteger;
	Node->Shape = GetShape(Table1->FindField("type")->AsString);
	Node->Color = (TColor)Table1->FindField("color")->AsInteger;
	Node->ImageAlign = GetImageAlign(Table1->FindField("ImageAlign")->AsString);
}
Example #22
0
void WeibullDistribution::SetParameters(double mean, double cov)
{
 Distribution::SetParameters(mean, cov);

 double vShape = GetShape(cov);
 double vScale = mean / boost::math::tgamma(1 + 1 / vShape) ;

 _wblObject = weibull_distribution<>(vShape, vScale);

 _name = "Wbl";
}
Example #23
0
void CNodeLocations::InsertNode(const void* apObject,
                                EObjectShapes aObjectShape,
                                const std::vector<wxPoint>& arCoords)
{
        CShapeLocation* pShape = GetShape(aObjectShape, arCoords);

        if (pShape)
        {
                CShapeLocationPtr pBox(pShape);
                mNodeLocations.insert(std::make_pair(apObject, pBox));
        }
}
Example #24
0
// Calculate what new size would be, at end of resize
void wxPolygonControlPoint::CalculateNewSize(double x, double y)
{
	double bound_x;
	double bound_y;
	GetShape()->GetBoundingBoxMin(&bound_x, &bound_y);

	double dist = (double)sqrt((x - m_shape->GetX()) * (x - m_shape->GetX()) +
	                           (y - m_shape->GetY()) * (y - m_shape->GetY()));

	m_newSize.x = (double)(dist / this->m_originalDistance) * this->m_originalSize.x;
	m_newSize.y = (double)(dist / this->m_originalDistance) * this->m_originalSize.y;
}
Example #25
0
void GalaxySetupPanel::GetSetupData(GalaxySetupData& setup_data) const {
    setup_data.m_seed =             GetSeed();
    setup_data.m_size =             Systems();
    setup_data.m_shape =            GetShape();
    setup_data.m_age =              GetAge();
    setup_data.m_starlane_freq =    GetStarlaneFrequency();
    setup_data.m_planet_density =   GetPlanetDensity();
    setup_data.m_specials_freq =    GetSpecialsFrequency();
    setup_data.m_monster_freq =     GetMonsterFrequency();
    setup_data.m_native_freq =      GetNativeFrequency();
    setup_data.m_ai_aggr =          GetAIAggression();
}
Example #26
0
std::vector<match_t> matchBodiesToRings(It begin, It end)
{
	std::vector<match_t> batch;

	std::transform(begin, end, std::back_inserter(batch), [](b2Body* body)
	{
		auto f = body->GetFixtureList();
		auto shape = static_cast<b2ChainShape*>(f->GetShape());
		return std::make_pair(body, convertShape(body->GetWorldCenter(), shape));
	});

	return batch;
}
void SEGVIA::SetLayerPair( LAYER_NUM top_layer, LAYER_NUM bottom_layer )
{
    if( GetShape() == VIA_THROUGH )
    {
        top_layer    = LAYER_N_FRONT;
        bottom_layer = LAYER_N_BACK;
    }

    if( bottom_layer > top_layer )
        EXCHG( bottom_layer, top_layer );

    // XXX EVIL usage of LAYER
    m_Layer = (top_layer & 15) + ( (bottom_layer & 15) << 4 );
}
void SEGVIA::LayerPair( LAYER_NUM* top_layer, LAYER_NUM* bottom_layer ) const
{
    LAYER_NUM b_layer = LAYER_N_BACK;
    LAYER_NUM t_layer = LAYER_N_FRONT;

    if( GetShape() != VIA_THROUGH )
    {
        // XXX EVIL usage of LAYER
        b_layer = (m_Layer >> 4) & 15;
        t_layer = m_Layer & 15;

        if( b_layer > t_layer )
            EXCHG( b_layer, t_layer );
    }
Example #29
0
// Returns true if the unichar sets are equal between the shapes.
bool ShapeTable::MergeEqualUnichars(int merge_id1, int merge_id2,
                                    int shape_id) const {
  const Shape& merge1 = GetShape(merge_id1);
  const Shape& merge2 = GetShape(merge_id2);
  const Shape& shape = GetShape(shape_id);
  for (int cs = 0; cs < shape.size(); ++cs) {
    int unichar_id = shape[cs].unichar_id;
    if (!merge1.ContainsUnichar(unichar_id) &&
        !merge2.ContainsUnichar(unichar_id))
      return false;  // Shape has a unichar that appears in neither merge.
  }
  for (int cm1 = 0; cm1 < merge1.size(); ++cm1) {
    int unichar_id1 = merge1[cm1].unichar_id;
    if (!shape.ContainsUnichar(unichar_id1))
      return false;  // Merge has a unichar that is not in shape.
  }
  for (int cm2 = 0; cm2 < merge2.size(); ++cm2) {
    int unichar_id2 = merge2[cm2].unichar_id;
    if (!shape.ContainsUnichar(unichar_id2))
      return false;  // Merge has a unichar that is not in shape.
  }
  return true;
}
Example #30
0
void MyEvtHandler::OnLeftClick(double WXUNUSED(x), double WXUNUSED(y), int keys, int WXUNUSED(attachment))
{
  wxClientDC dc(GetShape()->GetCanvas());
  GetShape()->GetCanvas()->PrepareDC(dc);

  if (keys == 0)
  {
    // Selection is a concept the library knows about
    if (GetShape()->Selected())
    {
      GetShape()->Select(false, &dc);
      GetShape()->GetCanvas()->Redraw(dc); // Redraw because bits of objects will be are missing
    }
    else
    {
      // Ensure no other shape is selected, to simplify Undo/Redo code
      bool redraw = false;
      wxObjectList::compatibility_iterator node = GetShape()->GetCanvas()->GetDiagram()->GetShapeList()->GetFirst();
      while (node)
      {
        wxShape *eachShape = (wxShape *)node->GetData();
        if (eachShape->GetParent() == NULL)
        {
          if (eachShape->Selected())
          {
            eachShape->Select(false, &dc);
            redraw = true;
          }
        }
        node = node->GetNext();
      }
      GetShape()->Select(true, &dc);
      if (redraw)
        GetShape()->GetCanvas()->Redraw(dc);
    }
  }
  else if (keys & KEY_CTRL)
  {
    // Do something for CONTROL
  }
  else
  {
#if wxUSE_STATUSBAR
    wxGetApp().frame->SetStatusText(label);
#endif // wxUSE_STATUSBAR
  }
}