Пример #1
0
//**************************************************
wxRealPoint wxSFBotLineShape::GetSrcPoint()
{
	wxRealPoint pt1, pt2;
	
	wxSFShapeBase* pSrcShape = GetShapeManager()->FindShape(m_nSrcShapeId);
	
	if( pSrcShape && !m_lstPoints.IsEmpty() )
	{
		RealPointList::compatibility_iterator node = m_lstPoints.GetFirst();
		if( node )
		{	
			pt1 = *node->GetData();
			if(pSrcShape->IsKindOf(CLASSINFO(wxSFIfShape)))
			{
				wxSFIfShape *ifShape = (wxSFIfShape *)pSrcShape;
				if(GetCondition() == 1)
					return ifShape->GetBorderPoint(true);
				else
					return ifShape->GetBorderPoint(false);
			}
			else
				return wxRealPoint(pSrcShape->GetBoundingBox().x + pSrcShape->GetBoundingBox().GetWidth() / 2, pSrcShape->GetBoundingBox().GetBottom());
		}
	}
	else
	{
		if( m_nMode != modeUNDERCONSTRUCTION )
			GetDirectLine( pt1, pt2 );
		else
			pt1 = wxRealPoint(pSrcShape->GetBoundingBox().x + pSrcShape->GetBoundingBox().GetWidth() / 2, pSrcShape->GetBoundingBox().GetBottom());
		return pt1;
	}

	return wxRealPoint();
}
Пример #2
0
//**************************************************
// public functions
//**************************************************
bool wxSFIfShape::CreateFromXPM(const char* const* bits)
{
	bool fSuccess = false;

	// create bitmap from XPM
	m_Image = wxImage(bits);
	fSuccess = m_Image.IsOk();

	if(!fSuccess)
	{
		m_Image = wxImage(NoSource_xpm);
	}

	m_OriginalImage = m_Image;

	m_nRectSize.x = m_Image.GetWidth();
	m_nRectSize.y = m_Image.GetHeight();

	wxRealPoint diamond[4]={wxRealPoint(0,						m_Image.GetHeight()/2), 
							wxRealPoint(m_Image.GetWidth()/2,	0), 
							wxRealPoint(m_Image.GetWidth(),		m_Image.GetHeight()/2), 
							wxRealPoint(m_Image.GetWidth()/2,	m_Image.GetHeight())};
	SetVertices(4, diamond);

	if(m_fCanScale)
	{
		AddStyle(sfsSIZE_CHANGE);
	}
	else
		RemoveStyle(sfsSIZE_CHANGE);

	return fSuccess;
}
Пример #3
0
wxReportImageItem::wxReportImageItem(const wxString& name, const wxString& path, double x, double y, int PPI, bool isVariable)
{
    this->m_sName = name;
    this->m_iType = wxRP_IMAGE;
    this->m_fVariable = isVariable;
    this->m_pVariable = NULL;

    if(x >= 0 && y >= 0)
        this->m_position = wxRealPoint(x, y);
    else
        this->m_position = wxRealPoint(0, 0);

    /*this->m_sValue = path;

    if(PPI > 0)
    	this->m_iPPI = PPI;

    wxInitAllImageHandlers();
    wxImage image(path);
    this->m_iHeight = image.GetHeight();
    this->m_iWidth = image.GetWidth();*/

    SetPath( path );
    SetPPI( PPI );
}
Пример #4
0
//**************************************************
wxRealPoint wxSFBotLineShape::GetTrgPoint()
{
	wxRealPoint pt1, pt2;
	
	wxSFShapeBase* pTrgShape = GetShapeManager()->FindShape(m_nTrgShapeId);
	
	if( pTrgShape && !m_lstPoints.IsEmpty() )
	{
		RealPointList::compatibility_iterator node = m_lstPoints.GetLast();
		if( node )
		{	
			pt2 = *node->GetData();
			wxRect trgBB = pTrgShape->GetBoundingBox();
			return wxRealPoint(trgBB.x + trgBB.GetWidth() / 2, trgBB.GetTop());
		}
	}
	else
	{
		if( m_nMode != modeUNDERCONSTRUCTION )
			GetDirectLine( pt1, pt2 );
		else
			pt2 = Conv2RealPoint( m_nUnfinishedPoint );
			
		return pt2;
	}

	return wxRealPoint();
}
GroundTruthBox ImageGroundTruthPanelViewer::AddGhostRectangle(vector_layer_ptr_t & p_layer)
{
    GroundTruthBox box;
    vector_layer_ghost::Rectangle ghost_rectangle;
    std::vector < double > v_x, v_y;
    wxRealPoint ghost_pt_1, ghost_pt_2, local_pt_1, local_pt_2;

    ghost_rectangle = * vectorlayerghost()->get < vector_layer_ghost::Rectangle > ();
    ghost_pt_1 = vectorlayerghost()->transform().from_local(ghost_rectangle.first);
    ghost_pt_2 = vectorlayerghost()->transform().from_local(ghost_rectangle.second);
    local_pt_1 = wxRealPoint(p_layer->transform().to_local(ghost_pt_1));
    local_pt_2 = wxRealPoint(p_layer->transform().to_local(ghost_pt_2));
    v_x.push_back(local_pt_1.x);
    v_y.push_back(local_pt_1.y);
    v_x.push_back(local_pt_2.x);
    v_y.push_back(local_pt_1.y);
    v_x.push_back(local_pt_2.x);
    v_y.push_back(local_pt_2.y);
    v_x.push_back(local_pt_1.x);
    v_y.push_back(local_pt_2.y);
    p_layer->add_polygon(v_x, v_y);
    box = GroundTruthBox(local_pt_1.x, local_pt_1.y, local_pt_2.x, local_pt_2.y);

    return box;
}
Пример #6
0
void wxSFScaledDC::DoDrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord xc, wxCoord yc)
{
	if( m_fEnableGC )
    {
        #if wxUSE_GRAPHICS_CONTEXT
        InitGC();
		wxGraphicsPath path = m_pGC->CreatePath();
		
		double dist, sang, eang;
		
		dist = wxSFCommonFcn::Distance( wxRealPoint(x2, y2), wxRealPoint(xc, yc) );
		sang = acos( (x2 - xc) / dist ) + ( yc > y2 ? wxSF::PI : 0 );
		
		dist = wxSFCommonFcn::Distance( wxRealPoint(x1, y1), wxRealPoint(xc, yc) );
		eang = acos( (x1 - xc) / dist ) + ( yc > y1 ? wxSF::PI : 0 );
		
		path.AddArc( xc, yc, dist, sang, eang, true );
		
		m_pGC->StrokePath( path );
		
        UninitGC();
        #endif
    }
    else
		m_pTargetDC->DrawArc(Scale(x1), Scale(y1), Scale(x2), Scale(y2), Scale(xc), Scale(yc));
}
Пример #7
0
/** bg_clr is optional and is transparent by default */
GdaCircle* LineChartCanvas::MakeSummAvgHelper(double y_avg, const wxColour& fg_clr, const wxColour& bg_clr)
{
	const double x = 100;
	const int x_nudge = 40;
	double y = (y_avg - axis_scale_y.scale_min) * scaleY;
	GdaRay* r0 = new GdaRay(wxRealPoint(x, y), 0, ray_len);
	GdaRay* r1 = new GdaRay(wxRealPoint(x, y), 180, ray_len);
	r0->setPen(fg_clr);
	r1->setPen(fg_clr);
	r0->setNudge(x_nudge, 0);
	r1->setNudge(x_nudge, 0);
	background_shps.push_back(r0);
	background_shps.push_back(r1);
	if (bg_clr != wxTransparentColor) {
		GdaCircle* bc = new GdaCircle(wxRealPoint(x,y), ss_circ_rad);
		bc->setNudge(x_nudge, 0);
		bc->setPen(bg_clr);
		bc->setBrush(bg_clr);
		background_shps.push_back(bc);
	}
	GdaCircle* c = new GdaCircle(wxRealPoint(x,y), circ_rad);
	c->setNudge(x_nudge, 0);
	c->setPen(fg_clr);
	c->setBrush(GdaColorUtils::ChangeBrightness(fg_clr));
	background_shps.push_back(c);
	return c;
}
Пример #8
0
 void configuration_visitor::set_bbox(const wxRect& r) {
     boost::shared_ptr<vector_layer_ghost> ghost = m_panel->vectorlayerghost();
     if(!ghost) return;
     ghost->reset<vector_layer_ghost::Rectangle>();
     ghost->add_point(wxRealPoint(r.GetLeft (),r.GetTop   ()));
     ghost->add_point(wxRealPoint(r.GetRight(),r.GetBottom()));
     ghost->m_penRectangle = wxPen(*wxRED, 2, wxDOT);
     ghost->m_brushRectangle = wxBrush(*wxRED, wxTRANSPARENT);
 }
Пример #9
0
Settings::Settings()
{
	// set default values of application properties:

	// int
	m_nIntData = 1024;
	// long
	m_nLongData = 123456789;
	// double
	m_nDoubleData = 3.14159267;
	// double
	m_nFloatData = 3.14f;
	// bool
	m_fBoolData = true;
	// wxChar
	m_nCharData = 'A';
	// wxString
	m_sTextData = wxT("Textual data");
	// wxPoint
	m_nPointData = wxPoint(0, 0);
	// wxSize
	m_nSizeData = wxSize(100, 200);
	// wxRealPoint
	m_nRealPointData = wxRealPoint(1.23, 4.56);
	// wxPen
	m_PenData = *wxBLACK_PEN;
	// wxBrush
	m_BrushData = *wxBLACK_BRUSH;
	// wxFont
	m_FontData = *wxSWISS_FONT;
	// wxColour
	m_nColourData = *wxWHITE;
	// wxArrayString
	m_arrStringData.Add(wxT("First string item"));
	m_arrStringData.Add(wxT("Second string item"));
	// RealPointArray - array of wxRealPoint values
	m_arrRealPointData.Add(wxRealPoint(1.2, 3.4));
	m_arrRealPointData.Add(wxRealPoint(5.6, 7.8));
	// RealPointList - list of wxRealPoint values
	m_lstRealPointData.Append(new wxRealPoint(1.2, 3.4));
	m_lstRealPointData.Append(new wxRealPoint(5.6, 7.8));
	// dynamic instances of xsSerializable class or other derived classes
	m_pDynamicSerializableObject = new SerializableObject();
	// static instances of xsSerializable class or other derived classes
	m_StaticSerializableObject.m_sTextData = wxT("Modified textual data encapsulated by 'SerializableObject' class object");

	// mark class data members which should be serialized
	MarkDataMembers();
}
Пример #10
0
PCB_BASE_FRAME::PCB_BASE_FRAME( wxWindow*       father,
                                int             idtype,
                                const wxString& title,
                                const wxPoint&  pos,
                                const wxSize&   size,
                                long style) :
    EDA_DRAW_FRAME( father, idtype, title, pos, size, style )
{
    m_internalUnits       = PCB_INTERNAL_UNIT;  // Internal unit = 1/10000 inch
    m_Pcb                 = NULL;

    m_DisplayPadFill      = true;   // How to draw pads
    m_DisplayViaFill      = true;   // How to draw vias
    m_DisplayPadNum       = true;   // show pads number

    m_DisplayModEdge      = FILLED; // How to display module drawings (line/ filled / sketch)
    m_DisplayModText      = FILLED; // How to display module texts (line/ filled / sketch)
    m_DisplayPcbTrackFill = true;   // false = sketch , true = filled
    m_Draw3DFrame         = NULL;   // Display Window in 3D mode (OpenGL)
    m_ModuleEditFrame     = NULL;   // Frame for footprint edition
    m_ModuleViewerFrame   = NULL;   // Frame for footprint viewer

    m_UserGridSize        = wxRealPoint( 100.0, 100.0 );
    m_UserGridUnit        = INCHES;
    m_Collector           = new GENERAL_COLLECTOR();

    m_FastGrid1           = 0;
    m_FastGrid2           = 0;

    m_auxiliaryToolBar    = NULL;
}
Пример #11
0
PCB_BASE_FRAME::PCB_BASE_FRAME( wxWindow* aParent, ID_DRAWFRAME_TYPE aFrameType,
                                const wxString& aTitle,
                                const wxPoint& aPos, const wxSize& aSize,
                                long aStyle, const wxString & aFrameName) :
    EDA_DRAW_FRAME( aParent, aFrameType, aTitle, aPos, aSize, aStyle, aFrameName )
{
    m_Pcb                 = NULL;

    m_DisplayPadFill      = true;   // How to draw pads
    m_DisplayViaFill      = true;   // How to draw vias
    m_DisplayPadNum       = true;   // show pads number

    m_DisplayModEdge      = FILLED; // How to display module drawings (line/ filled / sketch)
    m_DisplayModText      = FILLED; // How to display module texts (line/ filled / sketch)
    m_DisplayPcbTrackFill = true;   // false = sketch , true = filled
    m_Draw3DFrame         = NULL;   // Display Window in 3D mode (OpenGL)

    m_UserGridSize        = wxRealPoint( 100.0, 100.0 );
    m_UserGridUnit        = INCHES;
    m_Collector           = new GENERAL_COLLECTOR();

    m_FastGrid1           = 0;
    m_FastGrid2           = 0;

    m_auxiliaryToolBar    = NULL;
}
Пример #12
0
void tcOOBView::OnLButtonDClick(wxMouseEvent& event)
{
    wxPoint point = event.GetPosition();

    if (tsOOBInfo* info = 
        ButtonContainingPoint(wxRealPoint((float)point.x,(float)point.y)))
    {
        long new_key = info->mnID;
        if (new_key != -1)
        {
            long flags = 0;
            if (event.ShiftDown()) flags += 1;
            if (event.ControlDown()) flags += 2;
            if (event.AltDown()) flags += 4;

            wxCommandEvent command(wxEVT_COMMAND_BUTTON_CLICKED, ID_DCLICKHOOK) ;    
            command.SetEventObject(this);
            command.SetExtraLong(flags);
            AddPendingEvent(command);
        }
        mnSelectedKey = new_key;

        tcSound::Get()->PlayEffect("ShortBeep");
    }
}
Пример #13
0
PCB_BASE_FRAME::PCB_BASE_FRAME( wxWindow* aParent, ID_DRAWFRAME_TYPE aFrameType,
                                const wxString& aTitle,
                                const wxPoint& aPos, const wxSize& aSize,
                                long aStyle, const wxString & aFrameName) :
    EDA_DRAW_FRAME( aParent, aFrameType, aTitle, aPos, aSize, aStyle, aFrameName )
{
    m_Pcb                 = NULL;
    m_toolManager         = NULL;
    m_toolDispatcher      = NULL;

    m_DisplayPadFill      = true;   // How to draw pads
    m_DisplayViaFill      = true;   // How to draw vias
    m_DisplayPadNum       = true;   // show pads number

    m_DisplayModEdge      = FILLED; // How to display module drawings (line/ filled / sketch)
    m_DisplayModText      = FILLED; // How to display module texts (line/ filled / sketch)
    m_DisplayPcbTrackFill = true;   // false = sketch , true = filled
    m_Draw3DFrame         = NULL;   // Display Window in 3D mode (OpenGL)

    m_UserGridSize        = wxRealPoint( 100.0, 100.0 );
    m_UserGridUnit        = INCHES;
    m_Collector           = new GENERAL_COLLECTOR();

    m_FastGrid1           = 0;
    m_FastGrid2           = 0;

    SetGalCanvas( new EDA_DRAW_PANEL_GAL(
            this, -1, wxPoint( 0, 0 ), m_FrameSize,
            EDA_DRAW_PANEL_GAL::GAL_TYPE_OPENGL ) );

    // Hide by default, it has to be explicitly shown
    GetGalCanvas()->Hide();

    m_auxiliaryToolBar    = NULL;
}
Пример #14
0
bool wxReportImageItem::RetrieveFromXmlNode(const wxXmlNode* node)
{
    long type = -1, ppi = 72;
    double x = -1, y = -1;

    node->GetAttribute(wxT("Type"), wxT("")).ToLong(&type);
    if(type != wxRP_IMAGE) return false;
    if(!this->m_style.RetrieveFromXmlNode(node));
    this->m_sName = node->GetAttribute(wxT("Name"), wxT(""));
    wxString path = node->GetAttribute(wxT("Path"), wxT(""));
    wxImage image;

    if(image.LoadFile(path))
    {
        this->m_sValue = path;
    }
    else return false;

    wxSscanf(node->GetAttribute(wxT("X"), wxT("")), wxT("%lf"), &x);
    wxSscanf(node->GetAttribute(wxT("Y"), wxT("")), wxT("%lf"), &y);

    if(x >= 0 && y >= 0)
        this->m_position = wxRealPoint(x, y);
    else return false;

    wxSscanf(node->GetAttribute(wxT("PPI"), wxT("")), wxT("%d"), &ppi);
    this->m_iPPI = ppi;

    this->m_iWidth = image.GetWidth();
    this->m_iHeight = image.GetHeight();

    return true;
}
Пример #15
0
wxReportPositionedItem::wxReportPositionedItem(const wxString& name, double x, double y, bool isVariable)
{
    this->m_sName = name;
    this->m_fVariable = isVariable;
    this->m_pVariable = NULL;
    this->m_position = wxRealPoint(x, y);
}
double MinCirclePoints(double &mincx, double &mincy,
                       std::list <std::list<wxRealPoint> > &all_points,
                       std::vector<wxRealPoint> &points)
{
    if(all_points.size() == 0)
        return MinCircle(mincx, mincy, points);

    std::list<wxRealPoint> cpoints = all_points.front();
    all_points.pop_front();

    int s =  points.size();
    points.push_back(wxRealPoint());
    double mind = INFINITY;
    for(std::list<wxRealPoint>::iterator it = cpoints.begin();
        it != cpoints.end(); it++) {
        points[s] = *it;

        double cx, cy, cd;
        cd = MinCirclePoints(cx, cy, all_points, points);
        if(cd < mind) {
            mind = cd;
            mincx = cx;
            mincy = cy;
        }
    }
    points.pop_back();
    all_points.push_front(cpoints);

    if(isinf(mind))
        return NAN;
    return mind;
}
Пример #17
0
void wxSFGridShape::FitToChildren()
{
    // HINT: overload it for custom actions...

    wxSFShapeBase* pChild;

    // get bounding box of the shape and children set be inside it
    wxRealPoint nAbsPos = GetAbsolutePosition();
    wxRect chBB = wxRect(nAbsPos.x, nAbsPos.y, 0, 0);

    SerializableList::compatibility_iterator node = GetFirstChildNode();
    while(node)
    {
        pChild = (wxSFShapeBase*)node->GetData();

        if( pChild->GetStyle() & sfsALWAYS_INSIDE )
        {
            pChild->GetCompleteBoundingBox(chBB, bbSELF | bbCHILDREN);
        }
        node = node->GetNext();
    }

    // do not let the grid shape 'disappear' due to zero sizes...
    if( (!chBB.GetWidth() || !chBB.GetHeight()) && !m_nCellSpace )
    {
        chBB.SetWidth( 10 );
        chBB.SetHeight( 10 );
    }

    m_nRectSize = wxRealPoint(chBB.GetSize().x + 2*m_nCellSpace, chBB.GetSize().y + 2*m_nCellSpace);
}
Пример #18
0
wxRealPoint GetImageScaling(int width, int height, int towidth, int toheight){
	wxRealPoint scale;
	wxSize newsize(0,0);
	if ( towidth * height > toheight * width ){
		newsize.SetHeight(wxMax(toheight,1));
		newsize.SetWidth(newsize.GetHeight() * width / height);
	}
	else if ( towidth * height < toheight * width ){
		newsize.SetWidth(wxMax(towidth,1));
		newsize.SetHeight(newsize.GetWidth() * height / width);
	}
	if (newsize.GetHeight() && newsize.GetWidth())
		scale = wxRealPoint(newsize.GetWidth()/(float)width, newsize.GetHeight()/(float)height);
	else
		scale = wxRealPoint(1.0,1.0);
	return scale;
}
Пример #19
0
Curve::Curve(wxRealPoint a, wxRealPoint b, wxColour color):Shape() {
    _points.push_back(a);
    _points.push_back(b);
    _color = color;
    
    _initStart = a;
    _initEnd = b;
     
    double x, y;
    x = (a.x + b.x) / 2.f;
    y = (a.y + b.y) / 2.f;
    _bend = wxRealPoint(x, y);
}
Пример #20
0
//**************************************************
bool wxSFIfShape::CreateFromImage(wxImage *image)
{
	bool fSuccess = true;

	if(image)
	{
		m_Image = *image;
		fSuccess = true;
	}
	else
		fSuccess = false;

	if(!fSuccess)
	{
		m_Image = wxImage(NoSource_xpm);
	}

	m_OriginalImage = m_Image;

	m_nRectSize.x = m_Image.GetWidth();
	m_nRectSize.y = m_Image.GetHeight();

	wxRealPoint diamond[4]={wxRealPoint(0,						m_Image.GetHeight()/2), 
							wxRealPoint(m_Image.GetWidth()/2,	0), 
							wxRealPoint(m_Image.GetWidth(),		m_Image.GetHeight()/2), 
							wxRealPoint(m_Image.GetWidth()/2,	m_Image.GetHeight())};
	SetVertices(4, diamond);

	if(m_fCanScale)
	{
		AddStyle(sfsSIZE_CHANGE);
	}
	else
		RemoveStyle(sfsSIZE_CHANGE);

	return fSuccess;
}
Пример #21
0
wxRealPoint wxSFLayoutAlgorithm::GetTopLeft(const ShapeList& shapes)
{
	double startx = INT_MAX, starty = INT_MAX;
	
	for( ShapeList::const_iterator it = shapes.begin(); it != shapes.end(); ++ it )
	{
		wxSFShapeBase *pShape = *it;
		
		wxRealPoint nPos = pShape->GetAbsolutePosition();
		if( nPos.x < startx ) startx = nPos.x;
		if( nPos.y < starty ) starty = nPos.y;
	}
	
	return wxRealPoint( startx, starty );
}
Пример #22
0
BASE_SCREEN::BASE_SCREEN( KICAD_T aType ) :
    EDA_ITEM( aType )
{
    m_UndoRedoCountMax = DEFAULT_MAX_UNDO_ITEMS;
    m_Initialized      = false;
    m_ScreenNumber     = 1;
    m_NumberOfScreens  = 1;      // Hierarchy: Root: ScreenNumber = 1
    m_Zoom             = 32.0;
    m_Grid.m_Size      = wxRealPoint( 50, 50 );   // Default grid size
    m_Grid.m_CmdId     = ID_POPUP_GRID_LEVEL_50;
    m_Center           = true;
    m_IsPrinting       = false;
    m_ScrollPixelsPerUnitX = 1;
    m_ScrollPixelsPerUnitY = 1;

    m_FlagModified     = false;     // Set when any change is made on board.
    m_FlagSave         = false;     // Used in auto save set when an auto save is required.
}
Пример #23
0
//**************************************************
//*****************Figure LINE**********************
//**************************************************
void wxSFBotLineShape::GetDirectLine(wxRealPoint& src, wxRealPoint& trg)
{
	wxSFShapeBase* pSrcShape = GetShapeManager()->FindShape(m_nSrcShapeId);
	wxSFShapeBase* pTrgShape = GetShapeManager()->FindShape(m_nTrgShapeId);

	if(pSrcShape && pTrgShape)
	{
		wxRealPoint trgCenter = GetModTrgPoint();
		wxRealPoint srcCenter = GetModSrcPoint();

		if( (pSrcShape->GetParent() == pTrgShape) || (pTrgShape->GetParent() == pSrcShape) )
		{
			wxRect trgBB = pTrgShape->GetBoundingBox();
			wxRect srcBB = pSrcShape->GetBoundingBox();

			if( trgBB.Contains((int)srcCenter.x, (int)srcCenter.y) )
			{
				src = wxRealPoint(srcCenter.x, srcBB.GetTop());
				trg = wxRealPoint(trgBB.x + trgBB.GetWidth() / 2, trgBB.GetTop());
				return;
			}
			else if( srcBB.Contains((int)trgCenter.x, (int)trgCenter.y) )
			{
				src = wxRealPoint(srcCenter.x, srcBB.GetTop());
				trg = wxRealPoint(trgBB.x + trgBB.GetWidth() / 2, trgBB.GetTop());
				return;
			}
		}
		
		if(pSrcShape->IsKindOf(CLASSINFO(wxSFIfShape)))
		{
			wxSFIfShape *ifShape = (wxSFIfShape *)pSrcShape;
			if(GetCondition() == 1)
				src = ifShape->GetBorderPoint(true);
			else
				src = ifShape->GetBorderPoint(false);
		}
		else
			src = wxRealPoint(pSrcShape->GetBoundingBox().x + pSrcShape->GetBoundingBox().GetWidth() / 2, pSrcShape->GetBoundingBox().GetBottom());

		if(pTrgShape->IsKindOf(CLASSINFO(wxSFIfShape)))
			trg = wxRealPoint(trgCenter.x, pTrgShape->GetBoundingBox().GetTop());
		else
			trg = wxRealPoint(pTrgShape->GetBoundingBox().x + pTrgShape->GetBoundingBox().GetWidth() / 2, pTrgShape->GetBoundingBox().GetTop());
	}	
}
Пример #24
0
void tcOOBView::OnLButtonUp(wxMouseEvent& event) 
{
    if (!mbMouseDrag) {return;}

    wxPoint point = event.GetPosition();

    if (tsOOBInfo* info = 
        ButtonContainingPoint(wxRealPoint((float)point.x,(float)point.y))) 
    {
        if (info->mnID != mnSelectedKey) 
        {
            msFormationChangeInfo.mnNewLeaderKey = info->mnID;
            msFormationChangeInfo.mbApply = true;

            tcSound::Get()->PlayEffect("MutedBeep");
        }
    }
    mbMouseDrag = false;
}
Пример #25
0
BASE_SCREEN::BASE_SCREEN( KICAD_T aType ) :
    EDA_ITEM( aType )
{
    m_UndoRedoCountMax = 10;     // undo/Redo command Max depth, 10 is a reasonable value
    m_FirstRedraw      = true;
    m_ScreenNumber     = 1;
    m_NumberOfScreen   = 1;      // Hierarchy: Root: ScreenNumber = 1
    m_Zoom             = 32.0;
    m_Grid.m_Size      = wxRealPoint( 50, 50 );   // Default grid size
    m_Grid.m_Id        = ID_POPUP_GRID_LEVEL_50;
    m_Center           = true;
    m_IsPrinting       = false;
    m_ScrollPixelsPerUnitX = 1;
    m_ScrollPixelsPerUnitY = 1;

    m_FlagModified     = false;     // Set when any change is made on board.
    m_FlagSave         = false;     // Used in auto save set when an auto save is required.

    SetCurItem( NULL );
}
Пример #26
0
SCH_SCREEN::SCH_SCREEN() : BASE_SCREEN( SCH_SCREEN_T ),
    m_paper( wxT( "A4" ) )
{
    size_t i;

    SetZoom( 32 );

    for( i = 0; i < SCHEMATIC_ZOOM_LIST_CNT; i++ )
        m_ZoomList.push_back( SchematicZoomList[i] );

    for( i = 0; i < SCHEMATIC_GRID_LIST_CNT; i++ )
        AddGrid( SchematicGridList[i] );

    SetGrid( wxRealPoint( 50, 50 ) );   // Default grid size.
    m_refCount = 0;

    // Suitable for schematic only. For libedit and viewlib, must be set to true
    m_Center = false;

    InitDataPoints( m_paper.GetSizeIU() );
}
Пример #27
0
PCB_BASE_FRAME::PCB_BASE_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrameType,
        const wxString& aTitle, const wxPoint& aPos, const wxSize& aSize,
        long aStyle, const wxString & aFrameName ) :
    EDA_DRAW_FRAME( aKiway, aParent, aFrameType, aTitle, aPos, aSize, aStyle, aFrameName )
{
    m_Pcb                 = NULL;

    m_UserGridSize        = wxRealPoint( 100.0, 100.0 );
    m_UserGridUnit        = INCHES;
    m_Collector           = new GENERAL_COLLECTOR();

    m_FastGrid1           = 0;
    m_FastGrid2           = 0;

    m_auxiliaryToolBar    = NULL;

    m_zoomLevelCoeff      = 110.0 * IU_PER_DECIMILS;  // Adjusted to roughly displays zoom level = 1
                                        // when the screen shows a 1:1 image
                                        // obviously depends on the monitor,
                                        // but this is an acceptable value
}
Пример #28
0
SCH_SCREEN::SCH_SCREEN( KIWAY* aKiway ) :
    BASE_SCREEN( SCH_SCREEN_T ),
    KIWAY_HOLDER( aKiway ),
    m_paper( wxT( "A4" ) )
{
    SetZoom( 32 );

    for( unsigned i = 0; i < DIM( SchematicZoomList ); i++ )
        m_ZoomList.push_back( SchematicZoomList[i] );

    for( unsigned i = 0; i < DIM( SchematicGridList ); i++ )
        AddGrid( SchematicGridList[i] );

    SetGrid( wxRealPoint( 50, 50 ) );   // Default grid size.
    m_refCount = 0;

    // Suitable for schematic only. For libedit and viewlib, must be set to true
    m_Center = false;

    InitDataPoints( m_paper.GetSizeIU() );
}
Пример #29
0
bool StepGuider::UpdateCalibrationState(const PHD_Point& currentLocation)
{
    bool bError = false;

    try
    {
        if (!m_calibrationStartingLocation.IsValid())
        {
            m_calibrationStartingLocation = currentLocation;
            Debug.AddLine(wxString::Format("Stepguider::UpdateCalibrationstate: starting location = %.2f,%.2f", currentLocation.X, currentLocation.Y));
        }

        wxString status0, status1;
        int stepsRemainingUp = MaxPosition(UP) - CurrentPosition(UP);
        int stepsRemainingDown = MaxPosition(DOWN) - CurrentPosition(DOWN);
        int stepsRemainingRight  = MaxPosition(RIGHT)  - CurrentPosition(RIGHT);
        int stepsRemainingLeft  = MaxPosition(LEFT)  - CurrentPosition(LEFT);

        stepsRemainingUp /= m_calibrationStepsPerIteration;
        stepsRemainingDown /= m_calibrationStepsPerIteration;
        stepsRemainingRight /= m_calibrationStepsPerIteration;
        stepsRemainingLeft /= m_calibrationStepsPerIteration;

        int stepsRemainingDownAndRight = wxMax(stepsRemainingDown, stepsRemainingRight);

        assert(stepsRemainingUp >= 0);
        assert(stepsRemainingDown >= 0);
        assert(stepsRemainingRight  >= 0);
        assert(stepsRemainingLeft  >= 0);
        assert(stepsRemainingDownAndRight    >= 0);


        bool moveUp = false;
        bool moveDown = false;
        bool moveRight  = false;
        bool moveLeft  = false;
        double x_dist;
        double y_dist;

        switch (m_calibrationState)
        {
            case CALIBRATION_STATE_GOTO_LOWER_RIGHT_CORNER:
                if (stepsRemainingDownAndRight > 0)
                {
                    status0.Printf(_("Init Calibration: %3d"), stepsRemainingDownAndRight);
                    moveDown = stepsRemainingDown > 0;
                    moveRight  = stepsRemainingRight > 0;
                    break;
                }
                Debug.AddLine(wxString::Format("Falling through to state AVERAGE_STARTING_LOCATION, position=(%.2f, %.2f)",
                                                currentLocation.X, currentLocation.Y));
                m_calibrationAverageSamples = 0;
                m_calibrationAveragedLocation.SetXY(0.0, 0.0);
                m_calibrationState = CALIBRATION_STATE_AVERAGE_STARTING_LOCATION;
                // fall through
            case CALIBRATION_STATE_AVERAGE_STARTING_LOCATION:
                m_calibrationAverageSamples++;
                m_calibrationAveragedLocation += currentLocation;
                status0.Printf(_("Averaging: %3d"), m_samplesToAverage - m_calibrationAverageSamples + 1);
                if (m_calibrationAverageSamples < m_samplesToAverage )
                {
                    break;
                }
                m_calibrationAveragedLocation /= m_calibrationAverageSamples;
                m_calibrationStartingLocation = m_calibrationAveragedLocation;
                m_calibrationIterations = 0;
                Debug.AddLine(wxString::Format("Falling through to state GO_LEFT, startinglocation=(%.2f, %.2f)",
                                                m_calibrationStartingLocation.X, m_calibrationStartingLocation.Y));
                m_calibrationState = CALIBRATION_STATE_GO_LEFT;
                // fall through
            case CALIBRATION_STATE_GO_LEFT:
                if (stepsRemainingLeft > 0)
                {
                    status0.Printf(_("Left Calibration: %3d"), stepsRemainingLeft);
                    m_calibrationIterations++;
                    moveLeft  = true;
                    x_dist = m_calibrationStartingLocation.dX(currentLocation);
                    y_dist = m_calibrationStartingLocation.dY(currentLocation);
                    GuideLog.CalibrationStep(this, "Left", stepsRemainingLeft,
                        x_dist,  y_dist,
                        currentLocation, m_calibrationStartingLocation.Distance(currentLocation));
                    m_calibrationDetails.raSteps.push_back(wxRealPoint(x_dist, y_dist));            // Just put "left" in "ra" steps
                    break;
                }
                Debug.AddLine(wxString::Format("Falling through to state AVERAGE_CENTER_LOCATION, position=(%.2f, %.2f)",
                                                currentLocation.X, currentLocation.Y));
                m_calibrationAverageSamples = 0;
                m_calibrationAveragedLocation.SetXY(0.0, 0.0);
                m_calibrationState = CALIBRATION_STATE_AVERAGE_CENTER_LOCATION;
                // fall through
            case CALIBRATION_STATE_AVERAGE_CENTER_LOCATION:
                m_calibrationAverageSamples++;
                m_calibrationAveragedLocation += currentLocation;
                status0.Printf(_("Averaging: %3d"), m_samplesToAverage -m_calibrationAverageSamples+1);
                if (m_calibrationAverageSamples < m_samplesToAverage )
                {
                    break;
                }
                m_calibrationAveragedLocation /= m_calibrationAverageSamples;
                m_calibration.xAngle = m_calibrationStartingLocation.Angle(m_calibrationAveragedLocation);
                m_calibration.xRate  = m_calibrationStartingLocation.Distance(m_calibrationAveragedLocation) /
                                                     (m_calibrationIterations * m_calibrationStepsPerIteration);
                status1.Printf(_("angle=%.1f rate=%.2f"), m_calibration.xAngle * 180. / M_PI, m_calibration.xRate);
                GuideLog.CalibrationDirectComplete(this, "Left", m_calibration.xAngle, m_calibration.xRate);
                Debug.AddLine(wxString::Format("LEFT calibration completes with angle=%.1f rate=%.2f", m_calibration.xAngle * 180. / M_PI, m_calibration.xRate));
                Debug.AddLine(wxString::Format("distance=%.2f iterations=%d",  m_calibrationStartingLocation.Distance(m_calibrationAveragedLocation), m_calibrationIterations));
                m_calibrationStartingLocation = m_calibrationAveragedLocation;
                m_calibrationIterations = 0;
                m_calibrationState = CALIBRATION_STATE_GO_UP;
                Debug.AddLine(wxString::Format("Falling through to state GO_UP, startinglocation=(%.2f, %.2f)",
                                                m_calibrationStartingLocation.X, m_calibrationStartingLocation.Y));
                // fall through
            case CALIBRATION_STATE_GO_UP:
                if (stepsRemainingUp > 0)
                {
                    status0.Printf(_("up Calibration: %3d"), stepsRemainingUp);
                    m_calibrationIterations++;
                    moveUp = true;
                    x_dist = m_calibrationStartingLocation.dX(currentLocation);
                    y_dist = m_calibrationStartingLocation.dY(currentLocation);
                    GuideLog.CalibrationStep(this, "Up", stepsRemainingLeft,
                        x_dist,  y_dist,
                        currentLocation, m_calibrationStartingLocation.Distance(currentLocation));
                    m_calibrationDetails.decSteps.push_back(wxRealPoint(x_dist, y_dist));                   // Just put "up" in "dec" steps
                    break;
                }
                Debug.AddLine(wxString::Format("Falling through to state AVERAGE_ENDING_LOCATION, position=(%.2f, %.2f)",
                                                currentLocation.X, currentLocation.Y));
                m_calibrationAverageSamples = 0;
                m_calibrationAveragedLocation.SetXY(0.0, 0.0);
                m_calibrationState = CALIBRATION_STATE_AVERAGE_ENDING_LOCATION;
                // fall through
            case CALIBRATION_STATE_AVERAGE_ENDING_LOCATION:
                m_calibrationAverageSamples++;
                m_calibrationAveragedLocation += currentLocation;
                status0.Printf(_("Averaging: %3d"), m_samplesToAverage -m_calibrationAverageSamples+1);
                if (m_calibrationAverageSamples < m_samplesToAverage )
                {
                    break;
                }
                m_calibrationAveragedLocation /= m_calibrationAverageSamples;
                m_calibration.yAngle = m_calibrationAveragedLocation.Angle(m_calibrationStartingLocation);
                m_calibration.yRate  = m_calibrationStartingLocation.Distance(m_calibrationAveragedLocation) /
                                                     (m_calibrationIterations * m_calibrationStepsPerIteration);
                status1.Printf(_("angle=%.1f rate=%.2f"), m_calibration.yAngle * 180. / M_PI, m_calibration.yRate);
                GuideLog.CalibrationDirectComplete(this, "Up", m_calibration.yAngle, m_calibration.yRate);
                Debug.AddLine(wxString::Format("UP calibration completes with angle=%.1f rate=%.2f", m_calibration.yAngle * 180. / M_PI, m_calibration.yRate));
                Debug.AddLine(wxString::Format("distance=%.2f iterations=%d",  m_calibrationStartingLocation.Distance(m_calibrationAveragedLocation), m_calibrationIterations));
                m_calibrationStartingLocation = m_calibrationAveragedLocation;
                m_calibrationState = CALIBRATION_STATE_RECENTER;
                Debug.AddLine(wxString::Format("Falling through to state RECENTER, position=(%.2f, %.2f)",
                                                currentLocation.X, currentLocation.Y));
                // fall through
            case CALIBRATION_STATE_RECENTER:
                status0.Printf(_("Finish Calibration: %3d"), stepsRemainingDownAndRight/2);
                moveRight = (CurrentPosition(LEFT) >= m_calibrationStepsPerIteration);
                moveDown = (CurrentPosition(UP) >= m_calibrationStepsPerIteration);
                if (moveRight || moveDown)
                {
                    Debug.AddLine(wxString::Format("CurrentPosition(LEFT)=%d CurrentPosition(UP)=%d", CurrentPosition(LEFT), CurrentPosition(UP)));
                    break;
                }
                m_calibrationState = CALIBRATION_STATE_COMPLETE;
                Debug.AddLine(wxString::Format("Falling through to state COMPLETE, position=(%.2f, %.2f)",
                                                currentLocation.X, currentLocation.Y));
                // fall through
            case CALIBRATION_STATE_COMPLETE:
                m_calibration.declination = 0.;
                m_calibration.pierSide = PIER_SIDE_UNKNOWN;
                m_calibration.rotatorAngle = Rotator::RotatorPosition();
                SetCalibration(m_calibration);
                SetCalibrationDetails(m_calibrationDetails, m_calibration.xAngle, m_calibration.yAngle);
                status1 = _T("calibration complete");
                GuideLog.CalibrationComplete(this);
                Debug.AddLine("Calibration Complete");
                break;
            default:
                assert(false);
                break;
        }

        if (moveUp)
        {
            assert(!moveDown);
            pFrame->ScheduleCalibrationMove(this, UP, m_calibrationStepsPerIteration);
        }

        if (moveDown)
        {
            assert(!moveUp);
            pFrame->ScheduleCalibrationMove(this, DOWN, m_calibrationStepsPerIteration);
        }

        if (moveRight)
        {
            assert(!moveLeft);
            pFrame->ScheduleCalibrationMove(this, RIGHT, m_calibrationStepsPerIteration);
        }

        if (moveLeft)
        {
            assert(!moveRight);
            pFrame->ScheduleCalibrationMove(this, LEFT, m_calibrationStepsPerIteration);
        }

        if (m_calibrationState != CALIBRATION_STATE_COMPLETE)
        {
            if (status1.IsEmpty())
            {
                double dX = m_calibrationStartingLocation.dX(currentLocation);
                double dY = m_calibrationStartingLocation.dY(currentLocation);
                double dist = m_calibrationStartingLocation.Distance(currentLocation);
                status1.Printf(_T("dx=%4.1f dy=%4.1f dist=%4.1f"), dX, dY, dist);
            }
        }

        if (!status0.IsEmpty())
        {
            pFrame->SetStatusText(status0, 0);
        }

        if (!status1.IsEmpty())
        {
            pFrame->SetStatusText(status1, 1);
        }
    }
    catch (wxString Msg)
    {
        POSSIBLY_UNUSED(Msg);
        bError = true;

        ClearCalibration();
    }

    return bError;
}
Пример #30
0

/* Default grid sizes for the schematic editor.
 * Do NOT add others values (mainly grid values in mm), because they
 * can break the schematic: Because wires and pins are considered as
 * connected when the are to the same coordinate we cannot mix
 * coordinates in mils (internal units) and mm (that cannot exactly
 * converted in mils in many cases).  In fact schematic must only use
 * 50 and 25 mils to place labels, wires and components others values
 * are useful only for graphic items (mainly in library editor) so use
 * integer values in mils only.  The 100 mil grid is added to help
 * conform to the KiCad Library Convention. Which states: "Using a
 * 100mil grid, pin ends and origin must lie on grid nodes IEC-60617"
*/
static GRID_TYPE SchematicGridList[] = {
    { ID_POPUP_GRID_LEVEL_100, wxRealPoint( 100, 100 ) },
    { ID_POPUP_GRID_LEVEL_50, wxRealPoint( 50, 50 ) },
    { ID_POPUP_GRID_LEVEL_25, wxRealPoint( 25, 25 ) },
    { ID_POPUP_GRID_LEVEL_10, wxRealPoint( 10, 10 ) },
    { ID_POPUP_GRID_LEVEL_5, wxRealPoint( 5, 5 ) },
    { ID_POPUP_GRID_LEVEL_2, wxRealPoint( 2, 2 ) },
    { ID_POPUP_GRID_LEVEL_1, wxRealPoint( 1, 1 ) },
};


SCH_SCREEN::SCH_SCREEN( KIWAY* aKiway ) :
    BASE_SCREEN( SCH_SCREEN_T ),
    KIWAY_HOLDER( aKiway ),
    m_paper( wxT( "A4" ) )
{
    m_modification_sync = 0;