inline void upd(nd *n){
    if(!n) return;
    n->sz=sz(n->l)+1+sz(n->r);
}
Beispiel #2
0
void PointerCoverSvc::ProcessBigLabel(RefPtr<Pango::Layout> lay, const Point& pos)
{
    DPoint sz(CalcTextSize(lay));
    AddRect( RectASz(DPoint(pos), sz) );
}
void upd(item *v)
{
	if (v)
		v->cnt = 1 + sz(v->l) + sz(v->r);
}
Beispiel #4
0
BOOL CVCAMetaParserMSXML::ParseMetaData( unsigned char *pMetadata, int nLength )
{
	CComBSTR sz( (char *)pMetadata );
	VARIANT_BOOL vb;
	USES_CONVERSION;

	pMetadata[nLength] = '\0';

	BSTR bstr = SysAllocString( A2W( (char *)pMetadata ) );

//	sz = CComBSTR("<?xml version=\"1.0\"?>\n<vca>\n <vca_hdr>\n  <frame_id>10</frame_id>\n </vca_hdr>\n</vca>\n");

//	TRACE( (char *)pMetadata );

	vb = m_pDOMDoc->loadXML( bstr);

//	FILE *pFile;
//	pFile = fopen( "C:\\vtmeta.txt", "a" );
//	fwrite( pMetadata, strlen( (char *)pMetadata ), 1, pFile );
//	fclose( pFile );

	if( VARIANT_TRUE == vb )
	{
		// Find the header
		ParseHeader();
		ParseStab();
		ParseObjects();
		ParseEvents();
		ParseCounts();
		ParseBlobsImp(_XML_TAMPERMAP, &m_TamperInfo);
		ParseBlobsImp(_XML_SCENECHANGEMAP, &m_SceneChangeInfo);
		ParseBlobsImp(_XML_BLOBMAP, &m_BlobMap);
		ParseBlobsImp(_XML_STATBLOBMAP, &m_StationaryMap);
		ParseBlobsImp(_XML_SMOKEMAP,&m_SmokeMap);
		ParseBlobsImp(_XML_FIREMAP,&m_FireMap);
		
		ParseCE();
	}
	else
	{
		// Loading the doc failed, find out why...
		MSXML2::IXMLDOMParseErrorPtr pErr = m_pDOMDoc->parseError;

		CString strLine, sResult;
		strLine.Format(_T(" ( line %u, column %u )"), pErr->Getline(), pErr->Getlinepos());
		// Return validation results in message to the user.
		if (pErr->errorCode != S_OK)
		{
			sResult = CString("Validation failed on ") +
			 CString ("\n=====================") +
			 CString("\nReason: ") + CString( (char*)(pErr->Getreason())) +
			 CString("\nSource: ") + CString( (char*)(pErr->GetsrcText())) +
			 strLine + CString("\n");

			ATLTRACE(sResult);

//			AfxMessageBox( (char *)pMetadata );


		}
	}

//	memset( pMetadata, NULL, 2048 );
	SysFreeString( bstr );

	return TRUE;
}
Beispiel #5
0
void SceneGraph::present(SceneNode *camera)
{
    glAssertError();
    glCullFace(GL_BACK);
    glEnable(GL_CULL_FACE);
    glEnable(GL_DEPTH_TEST);
    glPolygonMode(GL_FRONT, GL_FILL);
    glDisable(GL_BLEND);
    glDepthMask(GL_TRUE);
    glAssertError();

    //  setup camera
    CameraInfo ci;
    camera->prepare(ci);
    ci = *camera->as<CameraSceneNode>()->cam_;

    glEnable(GL_LIGHT0);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    Vec3 pos(1, 2, 3);
    normalize(pos);
    Matrix m(ci.mmat_);
    m.setTranslation(Vec3(0, 0, 0));
    multiply(m, pos);
    glLightfv(GL_LIGHT0, GL_POSITION, &pos.x);

    Rgba ambLight(0.25f, 0.2f, 0.3f);
    glLightfv(GL_LIGHT0, GL_AMBIENT, &ambLight.r);
    Rgba diffLight(0.75f, 0.75f, 0.6f);
    glLightfv(GL_LIGHT0, GL_DIFFUSE, &diffLight.r);
    Rgba specLight(0.75f, 0.75f, 0.6f);
    glLightfv(GL_LIGHT0, GL_SPECULAR, &diffLight.r);
    Rgba zero(0, 0, 0);
    glLightModelfv(GL_LIGHT_MODEL_AMBIENT, &zero.r);

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    Vec3 sz(ctx_->size());
    float fy = tanf(ci.fovY / 360.0f * (float)3.1415927f);
    float fx = fy * sz.x / sz.y;
    glFrustum(-fx, fx, -fy, fy, 0.9f, 10000.0f);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glAssertError();

    //  prepare all objects
    for (std::set<SceneNode*>::iterator ptr(scene_.begin()), end(scene_.end());
        ptr != end; ++ptr)
    {
        if ((*ptr) != camera)
        {
            (*ptr)->prepare(ci);
        }
    }

    //  render all objects
    static std::vector<std::pair<float, SceneNode *> > toDraw;
    toDraw.reserve(8000);
    Vec3 camBack(ci.back);

    for (int pno = 0; pno < p_num_passes; ++pno)
    {
        int pass = (1 << pno);
        toDraw.clear();
        for (std::set<SceneNode*>::iterator ptr(scene_.begin()), end(scene_.end());
            ptr != end; ++ptr)
        {
            if (((*ptr)->pass_ & pass) != 0)
            {
                toDraw.push_back(std::pair<float, SceneNode *>(dot((*ptr)->worldPos(), camBack), *ptr));
            }
        }
        if (pass == p_transparent)
        {
            //  transparency is sorted back-to-front
            std::sort(toDraw.begin(), toDraw.end(), CompareFarNear());
        }
        else
        {
            //  everything else is sorted front-to-back, to get early z rejection
            std::sort(toDraw.begin(), toDraw.end(), CompareNearFar());
        }
        for (std::vector<std::pair<float, SceneNode *> >::iterator
            ptr(toDraw.begin()), end(toDraw.end());
            ptr != end;
            ++ptr)
        {
            (*ptr).second->render(ci, pass);
        }
    }

    glAssertError();
}
cv::Rect ObjectDetection::testClassifyMultiScale(cv::Mat& img, int stride, double& prob)
{
//	cv::imshow("object detector", img);
//        int c = cv::waitKey(0) & 255;

	prob = 0.0;
	int ht = img.rows;
	int wid = img.cols;

	// scale to 64 if one of the dim is less than 64
	if( ht < m_winHt || wid < m_winWid ) {
		int minzD = m_winWid;
                int minz = wid;
                if(ht*m_winWid < m_winHt*wid) { minz = ht; minzD = m_winHt; }

                double sc = ((minzD*1.0) / (double)minz);

                if(sc > 1.5) return cv::Rect(0,0,0,0);

                cv::Size sz(0,0);
                if(ht == minz) {
                        sz.height = m_winHt;
                        sz.width = (sc * img.cols);
                        cv::resize(img, img, sz, sc, 0, cv::INTER_LINEAR);
                } else {
                        sz.width = m_winWid;
                        sz.height = (sc * img.rows);
                        cv::resize(img, img, sz, 0, sc, cv::INTER_LINEAR);
                }
                ht = img.rows;
                wid = img.cols;
	}

	// multiscale detection - it calculates the max prob at diff scales
	double max_prob = 0.0;
	cv::Mat max_frame;
	cv::Rect max_frame_rect(0, 0, 0, 0);

	for(double scale = 1.0; scale <= 5.0; scale *= 1.2) {
		cv::Mat simg;
		cv::resize(img, simg, cv::Size(0, 0), (1.0/scale), (1.0/scale), cv::INTER_LINEAR);
		if( simg.rows < m_winHt || simg.cols < m_winWid)
			continue;
		int sht = simg.rows;
		int swid = simg.cols;
		for(int x = 0; x < swid; x += stride) {
			for(int y = 0; y < sht; y += stride) {
				if( (x + m_winWid) > swid || (y + m_winHt) > sht)
					continue;
				// detect
				double p = 0.0;
				cv::Mat blockImg = simg(cv::Range(y,y+m_winHt), cv::Range(x, x+m_winWid));
				this->testClassify(blockImg, p);
				if( p > max_prob) {
					max_prob = p;
					blockImg.copyTo(max_frame);
					max_frame_rect.x = (x * scale);
					max_frame_rect.y = (y * scale);
					max_frame_rect.width = (m_winWid * scale);
					max_frame_rect.height = (m_winHt * scale);
				}
			}
		}
	}
	prob = max_prob;
	cout << "Max probability: " << max_prob << endl;

	if(max_frame.data != NULL) {	
		cv::imshow("object detector", max_frame);
        	cv::waitKey(0) & 255;
	}
	
	return max_frame_rect;
}
Beispiel #7
0
Rectangle Level::getSplashVisibleBounds() {
  Vec2 sz(40, 20);
  return Rectangle(getSplashBounds().middle() - sz / 2, getSplashBounds().middle() + sz / 2);
}
Beispiel #8
0
void CUploadTipCtrl::OnPaint(CDC* pDC, CUploadTransfer* pUpload)
{
	CPoint pt( 0, 0 );
	CSize sz( m_sz.cx, TIP_TEXTHEIGHT );

	DrawText( pDC, &pt, m_pUploadFile->m_sName );
	pt.y += TIP_TEXTHEIGHT;
	DrawText( pDC, &pt, m_sAddress );
	pDC->SelectObject( &CoolInterface.m_fntNormal );
	pt.y += TIP_TEXTHEIGHT;

	int nFlagIndex = Flags.GetFlagIndex( pUpload->m_sCountry );
	if ( nFlagIndex >= 0 )
	{
		Flags.Draw( nFlagIndex, pDC->GetSafeHdc(), pt.x, pt.y, CoolInterface.m_crTipBack );
		pDC->ExcludeClipRect( pt.x, pt.y, pt.x + 16, pt.y + 16 );
	}
	pt.x += 16 + 4;
	DrawText( pDC, &pt, pUpload->m_sCountryName );
	pt.x -= 16 + 4;
	pt.y += 16;

	DrawRule( pDC, &pt );

	CString strStatus, strSpeed, strText;
	CString strOf;
	LoadString( strOf, IDS_GENERAL_OF );

	strSpeed.Format( _T("%s %s %s (%s)"),
		(LPCTSTR)Settings.SmartSpeed( pUpload->GetMeasuredSpeed() ),
		(LPCTSTR)strOf,
		(LPCTSTR)Settings.SmartSpeed( pUpload->m_nBandwidth ),
		(LPCTSTR)Settings.SmartSpeed( pUpload->GetMaxSpeed() ) );

	int nQueue = UploadQueues.GetPosition( pUpload, FALSE );
	if ( m_pUploadFile != pUpload->m_pBaseFile || pUpload->m_nState == upsNull )
	{
		LoadString( strStatus, IDS_TIP_INACTIVE );
	}
	else if ( nQueue == 0 )
	{
		if ( pUpload->m_nState == upsQueued )
		{
			LoadString( strText, IDS_TIP_NEXT );
			strStatus.Format( _T("%s: %s"),
				(LPCTSTR)pUpload->m_pQueue->m_sName, (LPCTSTR)strText );
		}
		else
		{
			LoadString( strText, IDS_TIP_ACTIVE );
			strStatus.Format( _T("%s: %s"),
				(LPCTSTR)pUpload->m_pQueue->m_sName, (LPCTSTR)strText );
		}
	}
	else if ( nQueue > 0 )
	{
		strStatus.Format( _T("%s: %i %s %u"),
			(LPCTSTR)pUpload->m_pQueue->m_sName,
			nQueue, (LPCTSTR)strOf, pUpload->m_pQueue->GetQueuedCount() );
	}
	else
	{
		LoadString( strStatus, IDS_TIP_ACTIVE );
	}

	LoadString( strText, IDS_TIP_STATUS );
	DrawText( pDC, &pt, strText );
	DrawText( pDC, &pt, strStatus, 80 );
	pt.y += TIP_TEXTHEIGHT;

	LoadString( strText, IDS_TIP_SPEED );
	DrawText( pDC, &pt, strText );
	DrawText( pDC, &pt, strSpeed, 80 );
	pt.y += TIP_TEXTHEIGHT;

	LoadString( strText, IDS_TIP_USERAGENT );
	DrawText( pDC, &pt, strText );
	DrawText( pDC, &pt, pUpload->m_sUserAgent, 80 );
	pt.y += TIP_TEXTHEIGHT;

	pt.y += TIP_GAP;

	DrawProgressBar( pDC, &pt, m_pUploadFile );
	pt.y += TIP_GAP;

	CRect rc( pt.x, pt.y, m_sz.cx, pt.y + 40 );
	pDC->Draw3dRect( &rc, CoolInterface.m_crTipBorder, CoolInterface.m_crTipBorder );
	rc.DeflateRect( 1, 1 );
	if ( m_pGraph)
		m_pGraph->BufferedPaint( pDC, &rc );
	rc.InflateRect( 1, 1 );
	pDC->ExcludeClipRect( &rc );
	pt.y += 40;
	pt.y += TIP_GAP;

	if ( Settings.General.GUIMode != GUI_BASIC )
	{
		if ( m_nHeaders != pUpload->m_pHeaderName.GetSize() )
		{
			ShowImpl( true );
			return;
		}
		for ( int nHeader = 0 ; nHeader < m_nHeaders ; nHeader++ )
		{
			CString strName = pUpload->m_pHeaderName.GetAt( nHeader ) + _T(':');
			CString strValue = pUpload->m_pHeaderValue.GetAt( nHeader );
			DrawText( pDC, &pt, strName );
			pt.x += m_nHeaderWidth;
			sz.cx -= m_nHeaderWidth;
			DrawText( pDC, &pt, strValue, &sz );
			pt.x -= m_nHeaderWidth;
			sz.cx += m_nHeaderWidth;
			pt.y += TIP_TEXTHEIGHT;
		}
	}
}
Beispiel #9
0
void CMainFrame::OnFileCapture() 
{
	DlgCapture dlg;
	if (dlg.DoModal()==IDOK){
		// get the desired window from dialog box
		HWND hwnd=dlg.m_SelectedWnd;
		// get window size
		CRect r;
		::GetWindowRect(hwnd,&r);

		int xScreen,yScreen;	//check if the window is out of the screen or maximixed <Qiang>
		int xshift = 0, yshift = 0;
		xScreen = GetSystemMetrics(SM_CXSCREEN);
		yScreen = GetSystemMetrics(SM_CYSCREEN);
		if(r.right > xScreen)
			   r.right = xScreen;
		if(r.bottom > yScreen)
			   r.bottom = yScreen;
		if(r.left < 0){
			   xshift = -r.left;
			   r.left = 0;
		}
		if(r.top < 0){
			   yshift = -r.top;
			   r.top = 0;
		}
		
		CSize sz(r.Width(), r.Height());
		if(sz.cx <= 0 || sz.cy <= 0) return;

		// bring the window at the top most level
		::SetWindowPos(hwnd,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);

		// prepare the DCs
		HDC dstDC = ::GetDC(NULL);
        HDC srcDC = ::GetWindowDC(hwnd); //full window (::GetDC(hwnd); = clientarea)
		HDC memDC = ::CreateCompatibleDC(dstDC);
		
		// copy the screen to the bitmap
		HBITMAP bm =::CreateCompatibleBitmap(dstDC, sz.cx, sz.cy);
		HBITMAP oldbm = (HBITMAP)::SelectObject(memDC,bm);
		::BitBlt(memDC, 0, 0, sz.cx, sz.cy, srcDC, xshift, yshift, SRCCOPY);
	
		// restore the position
		::SetWindowPos(hwnd,HWND_NOTOPMOST,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
		::SetWindowPos(m_hWnd,HWND_TOP,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);

		// prepare the new document
		CDemoDoc *NewDoc=(CDemoDoc*)((CDemoApp*)AfxGetApp())->demoTemplate->OpenDocumentFile(NULL); 
		if (NewDoc)	{
			CxImage *newima = new CxImage();
			newima->CreateFromHBITMAP(bm);
			NewDoc->image = newima;
			CString s;
			s.Format(_T("Captured Image %d"),((CDemoApp*)AfxGetApp())->m_nDocCount++);
			NewDoc->SetTitle(s);
			NewDoc->UpdateAllViews(0,WM_USER_NEWIMAGE);
			NewDoc->UpdateStatusBar();
		}

		// free objects
		DeleteObject(SelectObject(memDC,oldbm));
		DeleteObject(memDC);
	}
}
Beispiel #10
0
void wxGridBagSizer::RecalcSizes()
{
    if (m_children.GetCount() == 0)
        return;

    wxPoint pt( GetPosition() );
    wxSize  sz( GetSize() );

    m_rows = m_rowHeights.GetCount();
    m_cols = m_colWidths.GetCount();
    int idx, width, height;

    AdjustForGrowables(sz);

    // Find the start positions on the window of the rows and columns
    wxArrayInt rowpos;
    rowpos.Add(0, m_rows);
    int y = pt.y;
    for (idx=0; idx < m_rows; idx++)
    {
        height = m_rowHeights[idx] + m_vgap;
        rowpos[idx] = y;
        y += height;
    }

    wxArrayInt colpos;
    colpos.Add(0, m_cols);
    int x = pt.x;
    for (idx=0; idx < m_cols; idx++)
    {
        width = m_colWidths[idx] + m_hgap;
        colpos[idx] = x;
        x += width;
    }


    // Now iterate the children, setting each child's dimensions
    wxSizerItemList::compatibility_iterator node = m_children.GetFirst();
    while (node)
    {
        int row, col, endrow, endcol;
        wxGBSizerItem* item = (wxGBSizerItem*)node->GetData();

        if ( item->IsShown() )
        {
            item->GetPos(row, col);
            item->GetEndPos(endrow, endcol);

            height = 0;
            for(idx=row; idx <= endrow; idx++)
                height += m_rowHeights[idx];
            height += (endrow - row) * m_vgap; // add a vgap for every row spanned

            width = 0;
            for (idx=col; idx <= endcol; idx++)
                width += m_colWidths[idx];
            width += (endcol - col) * m_hgap; // add a hgap for every col spanned

            SetItemBounds(item, colpos[col], rowpos[row], width, height);
        }

        node = node->GetNext();
    }
}
Beispiel #11
0
PNS_ITEM* PNS_ROUTER::syncPad( D_PAD* aPad )
{
    PNS_LAYERSET layers( 0, MAX_CU_LAYERS - 1 );

    // ignore non-copper pads
    if ( (aPad->GetLayerSet() & LSET::AllCuMask()).none() )
        return NULL;

    switch( aPad->GetAttribute() )
    {
    case PAD_ATTRIB_STANDARD:
        break;

    case PAD_ATTRIB_SMD:
    case PAD_ATTRIB_HOLE_NOT_PLATED:
    case PAD_ATTRIB_CONN:
        {
            LSET lmsk = aPad->GetLayerSet();
            bool is_copper = false;

            for( int i = 0; i < MAX_CU_LAYERS; i++ )
            {
                if( lmsk[i] )
                {
                    is_copper = true;
                    if( aPad->GetAttribute() != PAD_ATTRIB_HOLE_NOT_PLATED )
                        layers = PNS_LAYERSET( i );
                    break;
                }
            }

            if( !is_copper )
                return NULL;
        }
        break;

    default:
        TRACE( 0, "unsupported pad type 0x%x", aPad->GetAttribute() );
        return NULL;
    }

    PNS_SOLID* solid = new PNS_SOLID;

    solid->SetLayers( layers );
    solid->SetNet( aPad->GetNetCode() );
    solid->SetParent( aPad );

    wxPoint wx_c = aPad->ShapePos();
    wxSize  wx_sz = aPad->GetSize();
    wxPoint offset = aPad->GetOffset();

    VECTOR2I c( wx_c.x, wx_c.y );
    VECTOR2I sz( wx_sz.x, wx_sz.y );

    RotatePoint( &offset, aPad->GetOrientation() );

    solid->SetPos( VECTOR2I( c.x - offset.x, c.y - offset.y ) );
    solid->SetOffset ( VECTOR2I ( offset.x, offset.y ) );

    double orient = aPad->GetOrientation() / 10.0;

    if( aPad->GetShape() == PAD_SHAPE_CIRCLE )
    {
        solid->SetShape( new SHAPE_CIRCLE( c, sz.x / 2 ) );
    }
    else
    {
        if( orient == 0.0 || orient == 90.0 || orient == 180.0 || orient == 270.0 )
        {
            if( orient == 90.0 || orient == 270.0 )
                sz = VECTOR2I( sz.y, sz.x );

            switch( aPad->GetShape() )
            {
            case PAD_SHAPE_OVAL:
                if( sz.x == sz.y )
                    solid->SetShape( new SHAPE_CIRCLE( c, sz.x / 2 ) );
                else
                {
                    VECTOR2I delta;

                    if( sz.x > sz.y )
                        delta = VECTOR2I( ( sz.x - sz.y ) / 2, 0 );
                    else
                        delta = VECTOR2I( 0, ( sz.y - sz.x ) / 2 );

                    SHAPE_SEGMENT* shape = new SHAPE_SEGMENT( c - delta, c + delta,
                                                              std::min( sz.x, sz.y ) );
                    solid->SetShape( shape );
                }
                break;

            case PAD_SHAPE_RECT:
                solid->SetShape( new SHAPE_RECT( c - sz / 2, sz.x, sz.y ) );
                break;

            case PAD_SHAPE_TRAPEZOID:
            {
                wxPoint coords[4];
                aPad->BuildPadPolygon( coords, wxSize( 0, 0 ), aPad->GetOrientation() );
                SHAPE_CONVEX* shape = new SHAPE_CONVEX();

                for( int ii = 0; ii < 4; ii++ )
                {
                    shape->Append( wx_c + coords[ii] );
                }

                solid->SetShape( shape );
                break;
            }

            default:
                TRACEn( 0, "unsupported pad shape" );
                delete solid;
                return NULL;
            }
        }
        else
        {
            switch( aPad->GetShape() )
            {
            // PAD_SHAPE_CIRCLE already handled above

            case PAD_SHAPE_OVAL:
                if( sz.x == sz.y )
                    solid->SetShape( new SHAPE_CIRCLE( c, sz.x / 2 ) );
                else
                {
                    wxPoint start;
                    wxPoint end;
                    wxPoint corner;

                    SHAPE_CONVEX* shape = new SHAPE_CONVEX();

                    int w = aPad->BuildSegmentFromOvalShape( start, end, 0.0, wxSize( 0, 0 ) );

                    if( start.y == 0 )
                        corner = wxPoint( start.x, -( w / 2 ) );
                    else
                        corner = wxPoint( w / 2, start.y );

                    RotatePoint( &start, aPad->GetOrientation() );
                    RotatePoint( &corner, aPad->GetOrientation() );
                    shape->Append( wx_c + corner );

                    for( int rot = 100; rot <= 1800; rot += 100 )
                    {
                        wxPoint p( corner );
                        RotatePoint( &p, start, rot );
                        shape->Append( wx_c + p );
                    }

                    if( end.y == 0 )
                        corner = wxPoint( end.x, w / 2 );
                    else
                        corner = wxPoint( -( w / 2 ), end.y );

                    RotatePoint( &end, aPad->GetOrientation() );
                    RotatePoint( &corner, aPad->GetOrientation() );
                    shape->Append( wx_c + corner );

                    for( int rot = 100; rot <= 1800; rot += 100 )
                    {
                        wxPoint p( corner );
                        RotatePoint( &p, end, rot );
                        shape->Append( wx_c + p );
                    }

                    solid->SetShape( shape );
                }
                break;

            case PAD_SHAPE_RECT:
            case PAD_SHAPE_TRAPEZOID:
            {
                wxPoint coords[4];
                aPad->BuildPadPolygon( coords, wxSize( 0, 0 ), aPad->GetOrientation() );

                SHAPE_CONVEX* shape = new SHAPE_CONVEX();
                for( int ii = 0; ii < 4; ii++ )
                {
                    shape->Append( wx_c + coords[ii] );
                }

                solid->SetShape( shape );
                break;
            }

            default:
                TRACEn( 0, "unsupported pad shape" );
                delete solid;

                return NULL;
            }
        }
    }
    return solid;
}
Beispiel #12
0
/*-------------------------------------------------------------------------
 * Compute x2yIdx which maps from input dimensions to the type of output
 * we want.  The format of x2yIdx is:
 *   [Xdimlabels Ydimlabels] 
 * so it reflects the order of the dimensions in the output Z.
 * The value and sign of the integer label tells us what type of
 * operation to perform on this dimension.
 *    0   this is a squeezed dim which must be singlenton
 *   -ve  this is the index in X/Y of the matching dim to be accumulated
 *   +ve  this number is the position of the dimension at this location in
 *        the output matrix.
 *-------------------------------------------------------------------------*/
TprodErrorCode compx2yIdx(MxInfo xinfo, int xnidx, int *xidx,
								  MxInfo yinfo, int ynidx, int *yidx,
								  int **x2yIdxp, int *znd, int *maccnd, int *seqnd){
  char msgTxt[256];
  int i,j;
  int *x2yIdx;

  *znd=0; *maccnd=0; *seqnd=0; 
  /* fill in the x2yIdx for the new type of indicies */
  if( xnidx<xinfo.nd ) { ERROR("tprod:Less X indicies than dimensions"); return LESSXIND; }
  if( ynidx<yinfo.nd ) { ERROR("tprod:Less Y indicies than dimensions"); return LESSYIND; }

  x2yIdx=(int*)CALLOC(xnidx+ynidx,sizeof(int)); /* alloc mem for result */
  *x2yIdxp=x2yIdx; /* direct access to the result */

  /* find the max value of xip, this is num output dims */
  /* also check for non multiple instances of acc dims labels */
  *znd=MAX((int)xidx[0],0);
  for( i=1; i<xnidx; i++){
	 if ( xidx[i] < 0 ) {
		for( j=0; j<i; j++)
		  if(xidx[i]==xidx[j]) { ERROR("tprod: Duplicate x-dim label"); return DUPXLABEL; }
	 } else if ( xidx[i] > 0 ) {
		*znd=MAX(*znd,(int)xidx[i]); /* find the largest target dim */
	 } else if ( sz(xinfo,i)!=1 ) {
		ERROR("tprod: Ignored dims *MUST* have size 1");   return NONSINGLENTONIGNORED;
	 }
  }
  /* same for yidx */
  /* but also check that we always have matching x label to accumulate */
  *znd=MAX(*znd,(int)yidx[0]); 
  for( i=1; i<ynidx; i++){
	 if ( yidx[i] < 0 ) {
		for( j=0; j<i; j++)
		  if(yidx[i]==yidx[j]) { ERROR("tprod: Duplicate y-dim label"); return DUPYLABEL; }
		for( j=0; j<xnidx; j++) if( yidx[i]==xidx[j] ) break;
		if( j==xnidx ) {
		  sprintf(msgTxt,"tprod: Couldn't find a matching negative x-label for the y-label=%d",(int)yidx[i]);
		  ERROR(msgTxt);		  return NOMATCHINGXYACC;
		}
	 } else if ( yidx[i] > 0 ) {
		*znd=MAX(*znd,(int)yidx[i]); /* find the largest target dim */
	 } else if ( sz(yinfo,i)!=1 ) {
		ERROR("tprod: Ignored dims *MUST* have size 1"); return NONSINGLENTONIGNORED;
	 }
  }

  /* compute the x->y mapping */
  for( i=0; i<xnidx; i++){
	 if ( xidx[i] < 0 ) {
		/* search for the matching y */
		for( j=0; j<ynidx; j++) {
		  if ( yidx[j]==xidx[i] ) {
			 x2yIdx[i]=-(j+1);    x2yIdx[xnidx+j]=-(i+1);    (*maccnd)++;
			 break;
		  }
		}
		if ( x2yIdx[i]==0 ) {
		  ERROR("tprod: Couldn't find a matching y-idx for the x"); return NOMATCHINGXY;
		}
		if( sz(xinfo,i) != sz(yinfo,j)) {/* check sizes match too */
		  ERROR("tprod: Matched dims must have the same size!");    return MATCHDIMMISMATCH;
		}
	 } else { /* just copy it through */
		x2yIdx[i]=(int)xidx[i];
		/* search for the matching y, & check sizes match */
		for( j=0; j<ynidx && yidx[j]!=xidx[i]; j++);
		if ( j<ynidx ){ /* sequential dimension */
		  if ( sz(xinfo,i) != sz(yinfo,j) ){
			 ERROR("tprod: Matched dims must have the same size!");  return MATCHDIMMISMATCH;
		  }
		  if ( sz(xinfo,i)!=1 ) { /* only *really* sequ if >1 size strides */
			 (*seqnd)++; 
		  } 
		}
	 }
  }
  /* now set the y parts -- for the non-set non-accumulated dimensions */ 
  for( i=0; i<ynidx; i++){ 
	 if( yidx[i] > 0 ) { x2yIdx[i+xnidx]=(int)yidx[i]; }
  }
  /*   } */
  *znd=MAX(*znd,1); /* ensure at least 1 output dim */
  *maccnd=MAX(*maccnd,1); /* ensure at least 1 macc dim */

  return OK;
}
Beispiel #13
0
/* initialize the size of the accumulated sub-matrices and update the x/y
	matrices */
TprodErrorCode initrestmaccmxInfo(int znd,
											 const MxInfo xinfo, const MxInfo yinfo, 
											 const int x2yIdx[], int xnidx, int ynidx,
											 MxInfo *xrestinfo,  MxInfo *yrestinfo,
											 MxInfo *xmaccinfo,  MxInfo *ymaccinfo){
  int maccnd=0;
  int i;
  if( xrestinfo->nd < znd || yrestinfo->nd < znd ) {
	 ERROR("mxInfo structures size too small");	 return XYTOOSMALL;
  }
	 
  /* ensure all output dims start with unit size -- so if we specify to map
	  input dim beyond the end we pad the gaps out with unit dims */
  for (i=0;i<xrestinfo->nd;i++) xrestinfo->sz[i]=1;
  for (i=0;i<yrestinfo->nd;i++) yrestinfo->sz[i]=1;

  /* ensure outputs have the same types as the inputs */
  xrestinfo->dtype = xinfo.dtype; xmaccinfo->dtype = xinfo.dtype;
  yrestinfo->dtype = yinfo.dtype; ymaccinfo->dtype = yinfo.dtype;

  /* this works in 2 stages -- first it sets up ?maccinfo/?restinfo and then
     squeezes the restinfo to minimum size */
  /* do the x part of the input */
  for( i=0; i<xnidx; i++ ) {

	 if ( x2yIdx[i] < 0 ) { /* accumulated dimension */
		/* compute the accumulated sub-matrices sizes */
		/* in the accumulated matrix the x size is the dim size */
		xmaccinfo->stride[maccnd]= stride(xinfo,i);
		xmaccinfo->sz[maccnd]    = sz(xinfo,i);
		/* in the accumulated matrix the y size is the dim size */
		ymaccinfo->stride[maccnd]= stride(yinfo,-x2yIdx[i]-1);
		ymaccinfo->sz[maccnd]    = sz(yinfo,-x2yIdx[i]-1);
		
		if ( sz(*xmaccinfo,maccnd) != sz(*ymaccinfo,maccnd) ) { 
		  ERROR("Accumulated dimensions sizes must match!");return ACCDIMMISMATCH;
		}
		maccnd++; /* 1 more accumulated dimension */
		
	 } else if ( x2yIdx[i]>0 ) { /* OP dimension -- just copy to rest */
		/* in the x rest set, y's size is 1 */
		xrestinfo->stride[x2yIdx[i]-1] = stride(xinfo,i); 
		xrestinfo->sz[x2yIdx[i]-1]     = sz(xinfo,i);		
		yrestinfo->stride[x2yIdx[i]-1] = 0; 
		yrestinfo->sz[x2yIdx[i]-1]     = 1;	  
	 } /* else ; */ /* ignored dimension so ignore it! */
  }
  xmaccinfo->nd=maccnd; ymaccinfo->nd=maccnd; /* set actual number macc dims*/

  for( ; i<xnidx+ynidx; i++){ /* do the y part of x2yIdx */
	 if ( x2yIdx[i] < 0 ) { /* acc dimension -- allready done */
	
	 } else if ( x2yIdx[i] > 0){/* non-acc dimension -- just copy to rest */
 		if ( xrestinfo->sz[x2yIdx[i]-1] == 0 ){ /* if not allready set */
		  xrestinfo->stride[x2yIdx[i]-1] = 0; 
		  xrestinfo->sz[x2yIdx[i]-1]     = 1;
		}
		yrestinfo->stride[x2yIdx[i]-1] = stride(yinfo,i-xnidx); 
		yrestinfo->sz[x2yIdx[i]-1]     = sz(yinfo,i-xnidx);		
	 }
  }

  /* deal with size edge cases */
  /*if ( xrestinfo->nd==0 )    xrestinfo->nd=1;*//* everything macc'd away */
  /*if ( xrestinfo->sz[0]==0 ) xrestinfo->sz[0]=1;*//* everything macc'd away*/
  /*if ( xrestinfo->sz[1]==0 ) xrestinfo->sz[1]=1;*/
  if ( xmaccinfo->nd == 0 )  xmaccinfo->sz[0]=1; /* nothing macc'd away */
  if ( ymaccinfo->nd == 0 )  ymaccinfo->sz[0]=1; /* nothing macc'd away */

  /* set the numels & the final strides -- to simplify debuggin */
  xrestinfo->numel=xrestinfo->sz[0];
  for ( i=1; i<xrestinfo->nd; i++ ) xrestinfo->numel *= xrestinfo->sz[i];
  xrestinfo->stride[xrestinfo->nd] = xinfo.stride[xinfo.nd];
  yrestinfo->numel=yrestinfo->sz[0];
  for ( i=1; i<yrestinfo->nd; i++ ) yrestinfo->numel *= yrestinfo->sz[i];
  yrestinfo->stride[yrestinfo->nd] = yinfo.stride[yinfo.nd];
  xmaccinfo->numel=xmaccinfo->sz[0];
  for ( i=1; i<xmaccinfo->nd; i++ ) xmaccinfo->numel *= xmaccinfo->sz[i];
  xmaccinfo->stride[xmaccinfo->nd] = xinfo.stride[xinfo.nd];
  ymaccinfo->numel=ymaccinfo->sz[0];
  for ( i=1; i<ymaccinfo->nd; i++ ) ymaccinfo->numel *= ymaccinfo->sz[i];
  ymaccinfo->stride[ymaccinfo->nd] = yinfo.stride[yinfo.nd];

  /* set the data pointers */
  xrestinfo->rp=xinfo.rp; xrestinfo->ip=xinfo.ip;
  yrestinfo->rp=yinfo.rp; yrestinfo->ip=yinfo.ip;
  xmaccinfo->rp=xinfo.rp; xmaccinfo->ip=xinfo.ip;
  ymaccinfo->rp=yinfo.rp; ymaccinfo->ip=yinfo.ip;

  return OK;
  
}
Beispiel #14
0
bool wxSlider::Create(wxWindow *parent, wxWindowID id,
        int value, int minValue, int maxValue,
        const wxPoint& pos, const wxSize& size,
        long style, const wxValidator& validator, const wxString& name )
{
    m_acceptsFocus = TRUE;
    m_needParent = TRUE;

    if (!PreCreation( parent, pos, size ) ||
        !CreateBase( parent, id, pos, size, style, validator, name ))
    {
        wxFAIL_MSG( wxT("wxSlider creation failed") );
        return FALSE;
    }

    m_oldPos = 0.0;

    if (style & wxSL_VERTICAL)
        m_widget = gtk_vscale_new( (GtkAdjustment *) NULL );
    else
        m_widget = gtk_hscale_new( (GtkAdjustment *) NULL );

    if (style & wxSL_LABELS)
    {
        gtk_scale_set_draw_value( GTK_SCALE( m_widget ), TRUE );
        gtk_scale_set_digits( GTK_SCALE( m_widget ), 0 );

        /* labels need more space and too small window will
           cause junk to appear on the dialog */
        if (style & wxSL_VERTICAL)
        {
            wxSize sz( size );
            if (sz.x < 35)
            {
                sz.x = 35;
                SetSize( sz );
            }
        }
        else
        {
            wxSize sz( size );
            if (sz.y < 35)
            {
                sz.y = 35;
                SetSize( sz );
            }
        }
    }
    else
        gtk_scale_set_draw_value( GTK_SCALE( m_widget ), FALSE );

    m_adjust = gtk_range_get_adjustment( GTK_RANGE(m_widget) );

#ifdef __WXGTK20__
    if (style & wxSL_INVERSE)
        gtk_range_set_inverted( GTK_RANGE(m_widget), TRUE );
#endif

    GtkEnableEvents();

#ifdef __WXGTK20__
    g_signal_connect (m_widget, "button_press_event",
                      G_CALLBACK (gtk_slider_button_press_callback),
                      this);
    g_signal_connect (m_widget, "button_release_event",
                      G_CALLBACK (gtk_slider_button_release_callback),
                      this);
#endif

    SetRange( minValue, maxValue );
    SetValue( value );

    m_parent->DoAddChild( this );

    PostCreation(size);

    return TRUE;
}
Beispiel #15
0
void CMatchTipCtrl::OnPaint(CDC* pDC)
{
	CPoint pt( 0, 0 );
	CSize sz( m_sz.cx, TIP_TEXTHEIGHT );

	DrawText( pDC, &pt, m_sName );
	pt.y += TIP_TEXTHEIGHT;

	pDC->SelectObject( &CoolInterface.m_fntNormal );

	if ( m_sUser.GetLength() )
	{
		DrawText( pDC, &pt, m_sUser );
		pt.y += TIP_TEXTHEIGHT;
	}

	if ( m_sCountry.GetLength() )
	{
		int nFlagIndex = Flags.GetFlagIndex( m_sCountryCode );
		if ( nFlagIndex >= 0 )
		{
			Flags.Draw( nFlagIndex, *pDC, pt.x, pt.y, CoolInterface.m_crTipBack, CoolInterface.m_crTipBack );
			pDC->ExcludeClipRect( pt.x, pt.y, pt.x + 16, pt.y + 16 );
		}
		pt.x += 16 + 4;
		DrawText( pDC, &pt, m_sCountry );
		pt.x -= 16 + 4;
		pt.y += max( 16, TIP_TEXTHEIGHT );
	}

	if ( m_sStatus.GetLength() )
	{
		DrawRule( pDC, &pt );

		pDC->SetTextColor( m_crStatus );
		pDC->SelectObject( &CoolInterface.m_fntBold );
		DrawText( pDC, &pt, m_sStatus );
		pDC->SelectObject( &CoolInterface.m_fntNormal );
		pDC->SetTextColor( CoolInterface.m_crTipText );
		pt.y += TIP_TEXTHEIGHT;
	}

	DrawRule( pDC, &pt );

	ShellIcons.Draw( pDC, m_nIcon, 32, pt.x, pt.y, CoolInterface.m_crTipBack );
	pDC->ExcludeClipRect( pt.x, pt.y, pt.x + 32, pt.y + 32 );

	if ( m_nRating > 1 )
	{
		CPoint ptStar( m_sz.cx - 3, pt.y - 2 );

		for ( int nRating = m_nRating - 1 ; nRating ; nRating-- )
		{
			ptStar.x -= 16;
			CoolInterface.Draw( pDC, IDI_STAR, 16, ptStar.x, ptStar.y, CoolInterface.m_crTipBack );
			pDC->ExcludeClipRect( ptStar.x, ptStar.y, ptStar.x + 16, ptStar.y + 16 );
		}
	}

	pt.x += 40;
	DrawText( pDC, &pt, m_sSize );
	pt.y += TIP_TEXTHEIGHT;
	DrawText( pDC, &pt, m_sType );
	pt.y -= TIP_TEXTHEIGHT;
	pt.x -= 40;

	pt.y += max( 32, TIP_TEXTHEIGHT * 2 );

	//Hashes
	if ( m_sSHA1.GetLength() || m_sTiger.GetLength() || m_sED2K.GetLength() || m_sBTH.GetLength() || m_sMD5.GetLength() )
	{
		DrawRule( pDC, &pt );

		if ( m_sSHA1.GetLength() )
		{
			DrawText( pDC, &pt, m_sSHA1 );
			pt.y += TIP_TEXTHEIGHT;
		}

		if ( m_sTiger.GetLength() )
		{
			DrawText( pDC, &pt, m_sTiger );
			pt.y += TIP_TEXTHEIGHT;
		}

		if ( m_sED2K.GetLength() )
		{
			DrawText( pDC, &pt, m_sED2K );
			pt.y += TIP_TEXTHEIGHT;
		}

		if ( m_sBTH.GetLength() )
		{
			DrawText( pDC, &pt, m_sBTH );
			pt.y += TIP_TEXTHEIGHT;
		}

		if ( m_sMD5.GetLength() )
		{
			DrawText( pDC, &pt, m_sMD5 );
			pt.y += TIP_TEXTHEIGHT;
		}
	}

	//Busy, firewalled, unstabled warnings. Queue info
	if ( m_sBusy.GetLength() || m_sPush.GetLength() || m_sUnstable.GetLength() || m_sQueue.GetLength() )
	{
		DrawRule( pDC, &pt );

		pDC->SetTextColor( CoolInterface.m_crTipWarnings );
		pDC->SelectObject( &CoolInterface.m_fntBold );

		//Source busy warning
		if (m_sBusy.GetLength())
		{
			CoolInterface.Draw( pDC, IDI_BUSY, 16, pt.x, pt.y, CoolInterface.m_crTipBack );
			pDC->ExcludeClipRect( pt.x, pt.y, pt.x + 16, pt.y + 16 );
			pt.x += 20;
			DrawText( pDC, &pt, m_sBusy);
			pt.x -= 20;
			pt.y += max( 16, TIP_TEXTHEIGHT );
		}

		pDC->SetTextColor( CoolInterface.m_crTipText );
		pDC->SelectObject( &CoolInterface.m_fntNormal );

		//Queue info
		if ( m_sQueue.GetLength() )
		{
			if ( m_sBusy.GetLength() || m_sPush.GetLength() || m_sUnstable.GetLength() ) // Align queue info with above (if present)
			{
				pt.x += 20;
				DrawText( pDC, &pt, m_sQueue );
				pt.x -= 20;
			}
			else
				DrawText( pDC, &pt, m_sQueue );

			pt.y += TIP_TEXTHEIGHT;
		}

		pDC->SetTextColor( CoolInterface.m_crTipWarnings );
		pDC->SelectObject( &CoolInterface.m_fntBold );

		//Source firewalled warning
		if (m_sPush.GetLength())
		{
			CoolInterface.Draw( pDC, IDI_FIREWALLED, 16, pt.x, pt.y, CoolInterface.m_crTipBack );
			pDC->ExcludeClipRect( pt.x, pt.y, pt.x + 16, pt.y + 16 );
			pt.x += 20;
			DrawText( pDC, &pt, m_sPush);
			pt.x -= 20;
			pt.y += max( 16, TIP_TEXTHEIGHT );
		}

		//Source unstable warning
		if (m_sUnstable.GetLength())
		{
			CoolInterface.Draw( pDC, IDI_UNSTABLE, 16, pt.x, pt.y, CoolInterface.m_crTipBack );
			pDC->ExcludeClipRect( pt.x, pt.y, pt.x + 16, pt.y + 16 );
			pt.x += 20;
			DrawText( pDC, &pt, m_sUnstable);
			pt.x -= 20;
			pt.y += max( 16, TIP_TEXTHEIGHT );
		}
		pDC->SetTextColor( CoolInterface.m_crTipText );
		pDC->SelectObject( &CoolInterface.m_fntNormal );
	}

	//Partial warning
	if ( m_sPartial.GetLength() )
	{
		DrawRule( pDC, &pt );
		DrawText( pDC, &pt, m_sPartial );
		pt.y += TIP_TEXTHEIGHT;
	}

	//Metadata
	if ( m_pMetadata.GetCount( TRUE ) )
	{
		DrawRule( pDC, &pt );
		for ( POSITION pos = m_pMetadata.GetIterator() ; pos ; )
		{
			const CMetaItem* pItem = m_pMetadata.GetNext( pos );
			if ( pItem->m_pMember && pItem->m_pMember->m_bHidden ) continue;

			DrawText( pDC, &pt, Settings.General.LanguageRTL ? _T(':') + pItem->m_sKey : pItem->m_sKey + _T(':') );
			pt.x += m_nKeyWidth;
			DrawText( pDC, &pt, pItem->m_sValue );
			pt.x -= m_nKeyWidth;
			pt.y += TIP_TEXTHEIGHT;
		}
	}
}
Beispiel #16
0
std::unique_ptr<PNS::SOLID> PNS_KICAD_IFACE::syncPad( D_PAD* aPad )
{
    LAYER_RANGE layers( 0, MAX_CU_LAYERS - 1 );

    // ignore non-copper pads
    if( ( aPad->GetLayerSet() & LSET::AllCuMask()).none() )
        return NULL;

    switch( aPad->GetAttribute() )
    {
    case PAD_ATTRIB_STANDARD:
        break;

    case PAD_ATTRIB_SMD:
    case PAD_ATTRIB_HOLE_NOT_PLATED:
    case PAD_ATTRIB_CONN:
        {
            LSET lmsk = aPad->GetLayerSet();
            bool is_copper = false;

            for( int i = 0; i < MAX_CU_LAYERS; i++ )
            {
                if( lmsk[i] )
                {
                    is_copper = true;

                    if( aPad->GetAttribute() != PAD_ATTRIB_HOLE_NOT_PLATED )
                        layers = LAYER_RANGE( i );

                    break;
                }
            }

            if( !is_copper )
                return NULL;
        }
        break;

    default:
        wxLogTrace( "PNS", "unsupported pad type 0x%x", aPad->GetAttribute() );
        return NULL;
    }

    std::unique_ptr< PNS::SOLID > solid( new PNS::SOLID );

    solid->SetLayers( layers );
    solid->SetNet( aPad->GetNetCode() );
    solid->SetParent( aPad );

    wxPoint wx_c = aPad->ShapePos();
    wxSize  wx_sz = aPad->GetSize();
    wxPoint offset = aPad->GetOffset();

    VECTOR2I c( wx_c.x, wx_c.y );
    VECTOR2I sz( wx_sz.x, wx_sz.y );

    RotatePoint( &offset, aPad->GetOrientation() );

    solid->SetPos( VECTOR2I( c.x - offset.x, c.y - offset.y ) );
    solid->SetOffset( VECTOR2I( offset.x, offset.y ) );

    double orient = aPad->GetOrientation() / 10.0;

    if( aPad->GetShape() == PAD_SHAPE_CIRCLE )
    {
        solid->SetShape( new SHAPE_CIRCLE( c, sz.x / 2 ) );
    }
    else if( aPad->GetShape() == PAD_SHAPE_CUSTOM )
    {
        SHAPE_POLY_SET outline;
        outline.Append( aPad->GetCustomShapeAsPolygon() );
        aPad->CustomShapeAsPolygonToBoardPosition( &outline, wx_c, aPad->GetOrientation() );

        SHAPE_CONVEX* shape = new SHAPE_CONVEX();

        // We use the convex hull of the pad shape, because PnS knows
        // only convex shapes.
        std::vector<wxPoint> convex_hull;
        BuildConvexHull( convex_hull, outline );

        for( unsigned ii = 0; ii < convex_hull.size(); ii++ )
            shape->Append( convex_hull[ii] );

        solid->SetShape( shape );
    }
    else
    {
        if( orient == 0.0 || orient == 90.0 || orient == 180.0 || orient == 270.0 )
        {
            if( orient == 90.0 || orient == 270.0 )
                sz = VECTOR2I( sz.y, sz.x );

            switch( aPad->GetShape() )
            {
            case PAD_SHAPE_OVAL:
                if( sz.x == sz.y )
                    solid->SetShape( new SHAPE_CIRCLE( c, sz.x / 2 ) );
                else
                {
                    VECTOR2I delta;

                    if( sz.x > sz.y )
                        delta = VECTOR2I( ( sz.x - sz.y ) / 2, 0 );
                    else
                        delta = VECTOR2I( 0, ( sz.y - sz.x ) / 2 );

                    SHAPE_SEGMENT* shape = new SHAPE_SEGMENT( c - delta, c + delta,
                                                              std::min( sz.x, sz.y ) );
                    solid->SetShape( shape );
                }
                break;

            case PAD_SHAPE_RECT:
                solid->SetShape( new SHAPE_RECT( c - sz / 2, sz.x, sz.y ) );
                break;

            case PAD_SHAPE_TRAPEZOID:
            {
                wxPoint coords[4];
                aPad->BuildPadPolygon( coords, wxSize( 0, 0 ), aPad->GetOrientation() );
                SHAPE_CONVEX* shape = new SHAPE_CONVEX();

                for( int ii = 0; ii < 4; ii++ )
                {
                    shape->Append( wx_c + coords[ii] );
                }

                solid->SetShape( shape );
                break;
            }

            case PAD_SHAPE_ROUNDRECT:
            {
                SHAPE_POLY_SET outline;
                const int segmentToCircleCount = 64;

                aPad->BuildPadShapePolygon( outline, wxSize( 0, 0 ), segmentToCircleCount, 1.0 );

                // TransformRoundRectToPolygon creates only one convex polygon
                SHAPE_LINE_CHAIN& poly = outline.Outline( 0 );
                SHAPE_CONVEX* shape = new SHAPE_CONVEX();

                for( int ii = 0; ii < poly.PointCount(); ++ii )
                {
                    shape->Append( wxPoint( poly.Point( ii ).x, poly.Point( ii ).y ) );
                }

                solid->SetShape( shape );
            }
                break;

            default:
                wxLogTrace( "PNS", "unsupported pad shape" );
                return nullptr;
            }
        }
        else
        {
            switch( aPad->GetShape() )
            {
            // PAD_SHAPE_CIRCLE and PAD_SHAPE_CUSTOM already handled above

            case PAD_SHAPE_OVAL:
                if( sz.x == sz.y )
                    solid->SetShape( new SHAPE_CIRCLE( c, sz.x / 2 ) );
                else
                {
                    wxPoint start;
                    wxPoint end;
                    wxPoint corner;

                    SHAPE_CONVEX* shape = new SHAPE_CONVEX();

                    int w = aPad->BuildSegmentFromOvalShape( start, end, 0.0, wxSize( 0, 0 ) );

                    if( start.y == 0 )
                        corner = wxPoint( start.x, -( w / 2 ) );
                    else
                        corner = wxPoint( w / 2, start.y );

                    RotatePoint( &start, aPad->GetOrientation() );
                    RotatePoint( &corner, aPad->GetOrientation() );
                    shape->Append( wx_c + corner );

                    for( int rot = 100; rot <= 1800; rot += 100 )
                    {
                        wxPoint p( corner );
                        RotatePoint( &p, start, rot );
                        shape->Append( wx_c + p );
                    }

                    if( end.y == 0 )
                        corner = wxPoint( end.x, w / 2 );
                    else
                        corner = wxPoint( -( w / 2 ), end.y );

                    RotatePoint( &end, aPad->GetOrientation() );
                    RotatePoint( &corner, aPad->GetOrientation() );
                    shape->Append( wx_c + corner );

                    for( int rot = 100; rot <= 1800; rot += 100 )
                    {
                        wxPoint p( corner );
                        RotatePoint( &p, end, rot );
                        shape->Append( wx_c + p );
                    }

                    solid->SetShape( shape );
                }
                break;

            case PAD_SHAPE_RECT:
            case PAD_SHAPE_TRAPEZOID:
            {
                wxPoint coords[4];
                aPad->BuildPadPolygon( coords, wxSize( 0, 0 ), aPad->GetOrientation() );

                SHAPE_CONVEX* shape = new SHAPE_CONVEX();
                for( int ii = 0; ii < 4; ii++ )
                {
                    shape->Append( wx_c + coords[ii] );
                }

                solid->SetShape( shape );
                break;
            }

            case PAD_SHAPE_ROUNDRECT:
            {
                SHAPE_POLY_SET outline;
                const int segmentToCircleCount = 32;
                aPad->BuildPadShapePolygon( outline, wxSize( 0, 0 ),
                                            segmentToCircleCount, 1.0 );

                // TransformRoundRectToPolygon creates only one convex polygon
                SHAPE_LINE_CHAIN& poly = outline.Outline( 0 );
                SHAPE_CONVEX* shape = new SHAPE_CONVEX();

                for( int ii = 0; ii < poly.PointCount(); ++ii )
                {
                    shape->Append( wxPoint( poly.Point( ii ).x, poly.Point( ii ).y ) );
                }

                solid->SetShape( shape );
                break;
            }

            default:
                wxLogTrace( "PNS", "unsupported pad shape" );
                return nullptr;
            }
        }
    }
    return solid;
}
int ObjectDetection::trainMultiScale(std::string imgName, bool classType)
{
	int stride = 32;
        // get the bounding box too if there
	// format of line - imageName #objs=1 x y x_width y_width
	// split
	std::vector<std::string> strs;
//	boost::split(strs, imgName, boost::is_any_of(" ") );
	SplitStr(imgName, ' ', strs);
	
	if( strs.empty() == true ) return -1;
	
	std::string imgStr = strs[0];

	cv::Mat img = cv::imread(imgStr.c_str());

        if(img.data == NULL)
                return -1;

        int ht = img.rows;
        int wid = img.cols;

        if( 4*ht < 3*m_winHt || 4*wid < 3*m_winWid ) {
		return 0;
        }

        // bounding box
        int x_left = 0, y_left = 0, x_wid = wid, y_ht = ht;
        if(strs.size() >= 6) {
                x_left = atoi(strs[2].c_str());
                y_left = atoi(strs[3].c_str());
                x_wid = atoi(strs[4].c_str());
                y_ht = atoi(strs[5].c_str());
        }

        if( 4*y_ht < 3*m_winHt || 4*x_wid < 3*m_winWid ) {
		return 0;
        }

        cv::Rect roi(x_left, y_left, x_wid, y_ht);
        //cv::Mat boundedImg = cvCreateImage(cvGetSize(&img), img->depth, img->nChannels);
        cv::Mat boundedImg = cv::Mat(img, roi);

	if(classType == 0) {
		// multiscale training on negative dataset 
		for(int x = 0; x < wid; x += stride) {
			for(int y = 0; y < ht; y += stride) {
				if( (x + m_winWid) > wid || (y + m_winHt) > ht)
					continue;
				// detect
				cv::Mat blockImg = boundedImg(cv::Range(y,y+m_winHt), cv::Range(x, x+m_winWid));
				this->train(blockImg, classType);
			}
		}
	} else {
		// image resize
		cv::Size sz(m_winWid, m_winHt);
		cv::resize(boundedImg, boundedImg, sz, 0, 0, cv::INTER_LINEAR); 

		ht = m_winHt;
		wid = m_winWid;

/*		cv::imshow("object detector", boundedImg);
	        int c = cv::waitKey(0) & 255;
*/		this->train(boundedImg, classType);
	}
        return 0;
}
Beispiel #18
0
void Data_El_Geom_GWin::box_user_geom(Pt2di & res1,Pt2di & res2) const
{
    interval_window_to_user(res1.x,res2.x,0,sz().x,_tr.x,_sc.x);
    interval_window_to_user(res1.y,res2.y,0,sz().y,_tr.y,_sc.y);
}
Beispiel #19
0
 sort* dl_decl_plugin::mk_rule_sort() {
     sort_size sz(sort_size::mk_infinite());
     sort_info info(m_family_id, DL_RULE_SORT, sz, 0, 0);
     return m_manager->mk_sort(m_rule_sym, info);
 }
Beispiel #20
0
void wxOSXPrintData::TransferPaperInfoTo( wxPrintData &data )
{
    PMGetPageFormatPaper(m_macPageFormat, &m_macPaper);

    PMPrinter printer ;
    PMSessionGetCurrentPrinter( m_macPrintSession, &printer );
    OSStatus err = noErr ;
    UInt32 copies ;
    err = PMGetCopies( m_macPrintSettings , &copies ) ;
    if ( err == noErr )
        data.SetNoCopies( copies ) ;

    PMOrientation orientation ;
    err = PMGetOrientation(  m_macPageFormat , &orientation ) ;
    if ( err == noErr )
    {
        if ( orientation == kPMPortrait || orientation == kPMReversePortrait )
        {
            data.SetOrientation( wxPORTRAIT  );
            data.SetOrientationReversed( orientation == kPMReversePortrait );
        }
        else
        {
            data.SetOrientation( wxLANDSCAPE );
            data.SetOrientationReversed( orientation == kPMReverseLandscape );
        }
    }

    Boolean collate;
    if (PMGetCollate(m_macPrintSettings, &collate) == noErr)
        data.SetCollate(collate);


    PMDuplexMode mode = 0 ;
    PMGetDuplex(  m_macPrintSettings, &mode ) ;
    switch( mode )
    {
        case kPMDuplexNoTumble :
            data.SetDuplex(wxDUPLEX_HORIZONTAL);
            break ;
        case kPMDuplexTumble :
            data.SetDuplex(wxDUPLEX_VERTICAL);
            break ;
        case kPMDuplexNone :
        default :
            data.SetDuplex(wxDUPLEX_SIMPLEX);
            break ;
    }

    double height, width;
    PMPaperGetHeight(m_macPaper, &height);
    PMPaperGetWidth(m_macPaper, &width);

    wxSize sz((int)(width * pt2mm + 0.5 ) ,
              (int)(height * pt2mm + 0.5 ));
    data.SetPaperSize(sz);
    wxPaperSize id = wxThePrintPaperDatabase->GetSize(wxSize(sz.x* 10, sz.y * 10));
    if (id != wxPAPER_NONE)
    {
        data.SetPaperId(id);
    }
}
Beispiel #21
0
void lena_for_ever()
{

    Gray_Pal       Pgray  (30);
    Disc_Pal       Pdisc  = Disc_Pal::P8COL();

    Elise_Set_Of_Palette SOP(newl(Pgray)+Pdisc);
    Video_Display Ecr((char *) NULL);
    Ecr.load(SOP);

    Video_Win   Wv  (Ecr,SOP,Pt2di(50,50),Pt2di(SZX,SZY));


    PS_Display disp("TMP/test.ps","Mon beau fichier ps",SOP);

    Pt2di NBW(4,20);
    Pt2di sz(200,100);
    Mat_PS_Window mps(disp,sz,Pt2dr(2.0,2.0),NBW,Pt2dr(0.5,0.1));

    for (int x = 0; x < NBW.x ; x++)
        for (int y = 0; y < NBW.y ; y++)
        {
            mps(x,y).fill_rect(Pt2di(0,0),sz,Pgray((y*255)/( NBW.y-1)));
            mps(x,y).draw_rect(Pt2di(0,0),sz,Pdisc(P8COL::red));
        }
/*
    PS_Window  Wps = disp.w_centered_max(Pt2di(SZX,SZY),Pt2dr(0.0,8.0));


    Elise_File_Im FLena("../IM_ELISE/lena",Pt2di(SZX,SZY),GenIm::u_int1);
    Im2D_U_INT1 I(SZX,SZY);



    Col_Pal        red    = Pdisc(P8COL::red);
    Col_Pal        blue   = Pdisc(P8COL::blue);
    Col_Pal        green  = Pdisc(P8COL::green);
    Col_Pal        black  = Pdisc(P8COL::black);
    Col_Pal        cyan   = Pdisc(P8COL::cyan);
    Col_Pal        white  = Pdisc(P8COL::white);
    Col_Pal        yellow  = Pdisc(P8COL::yellow);


    El_Window W = Wv|Wps;

    ELISE_COPY
    (
       Wps.all_pts(),
       32*(FLena.in()/32),
       W.ogray()|I.out()
    );
    W.fill_rect(Pt2dr(100,200),Pt2dr(400,300),yellow);


    Line_St s1     (red,3);
    Line_St s2     (green,2);

    Plot_1d  Plot1  (W,s1,s2,Interval(-10,10),newl(PlBox(50,50,300,400)));


    Plot1.show_axes();

    Plot1.show_axes
    (
              newl(PlBox(150,150,250,250)) + PlOriY(0.2)
            + PlAxeSty(s2)
    );


    Plot_1d  Plot2(W,s1,s2,Interval(-100,100));


    Plot1.show_box
    (
            newl(PlBox(150,150,250,250))  + PlBoxSty(cyan,2)
    );


    Plot2.set
    (
              newl(PlBox(20,200,400,400)) 
            + PlOriY(0.4)
            + PlAxeSty(Line_St(Pdisc(P8COL::yellow),1))
            + PlBoxSty(Line_St(black,2))
            + PlClearSty(white)
    );
    Plot2.show_axes();
    Plot2.show_box();


    Plot2.plot(10*sin(FX/4.0));

    Plot2.plot
    (
         10*sin(FX/4.0),
            newl(PlIntervBoxX(-50,50))
         +  PlotLinSty(red,2) 
    );

    Plot2.plot
    (
         10*sin(FX/4.0),
           newl( PlotLinSty(blue,2) )
         + PlIntervPlotX(-30,70)
         + PlAutoScalY(true)
         + PlShAxes(true)
         + PlAxeSty(cyan,3)
    );

    
    Plot2.plot
    (
         10*(1.2+sin(FX/4.0)),
           newl( PlotLinSty(red,2) )
         + PlAutoScalOriY(true)
         + PlShAxes(true)
         + PlAxeSty(cyan,2)
         + PlAutoClear(true)
    );



    Plot2.clear(newl(PlClearSty(Pgray(196))));

    Plot2.plot
    ( 
         50*cos(FX/9.0),
         newl(PlotLinSty(Pdisc(P8COL::red)))
       + PlClipY(false) + PlStepX(1.0)
    );


    Plot2.plot
    (
         70*sin(square(FX) / 500.0),
         newl(PlotLinSty(Pdisc(P8COL::blue)))
       + PlClipY(true) + PlStepX(0.15)
    );
    
    
    Plot2.set ( newl(PlBox(20,0,400,200)) );
    Plot2.set(newl(PlIntervBoxX(-20,20)));
    Plot2.clear();

    Plot2.plot
    (
         10 * cos(FX/4.0),
         newl(PlotFilSty(green))
        + PlClipY(false)
        + PlModePl(Plots::fill_box)
    );

     Plot2.plot
     (
         10 * cos(FX/4.0),
         newl(PlotFilSty(red))
        + PlClipY(true)
        + PlModePl(Plots::fill_box)
     );



     Plot2.plot
     (
         10 * cos(FX/4.0),
         newl(PlotLinSty(black,2))
        + PlClipY(true)
        + PlModePl(Plots::draw_box)
        + PlShAxes(true)
        + PlAxeSty(Line_St(Pdisc(P8COL::blue),2))
     );

cout << "aaaaaaaaaa\n";

getchar();
*/
}
Beispiel #22
0
UINT Enconn::ConnectThread(LPVOID pParam)//接收线程
{		
	int rcvLen = 0;
	int nDataLen = 0;
	int recvedlen =0;
	char pData[256] = {0};	 
	unsigned char msgcmd=0;
		IPicture   *pPic;     
	IStream   *pStm;
				
	HGLOBAL hMem;
	LPVOID lpBuf;
	HDC			hdc;
	HWND		hwnd;
	MSGHEAD head;

	CString finename;
	int pptindex=0;
	Enconn* pEnconn = (Enconn*) pParam;


	pEnconn->m_hSocket = socket(AF_INET,SOCK_STREAM,0);	
	struct sockaddr_in        client_addr;
	client_addr.sin_family = AF_INET;
	client_addr.sin_addr.s_addr = inet_addr(pEnconn->m_pAddr);
	client_addr.sin_port = htons(PORT);
	int nSize = 4000;
	pEnconn->PostMessage(RM_ST_CONNING,0);//给窗体发送消息
	setsockopt(pEnconn->m_hSocket, SOL_SOCKET, SO_RCVTIMEO, (char *)&nSize ,sizeof(nSize));	//设置socket接收超时,4秒钟
	if(connect(pEnconn->m_hSocket, (LPSOCKADDR)&client_addr, sizeof(client_addr)) != 0)
	{	
		pEnconn->PostMessage(RM_ST_FAIL,NULL);	
		closesocket(pEnconn->m_hSocket);
		pEnconn->m_hSocket=0;		
		return 0;
	}
	pEnconn->Connflag=1;
	pEnconn->PostMessage(RM_ST_SUCCESS,0);
	if(pEnconn->Enctype==1)//ENC1200
	{
		pEnconn->PackHeaderMSG((BYTE *)pData, MSG_PASSWORD, (HEAD_LEN+1+_tcslen(pEnconn->m_pPassword)));
		pData[HEAD_LEN]='A';//表示管理员	
		WideCharToMultiByte(CP_ACP,NULL,pEnconn->m_pPassword,_tcslen(pEnconn->m_pPassword),&pData[HEAD_LEN+1],8,NULL,FALSE);
		rcvLen=pEnconn->Send((char*)pData,HEAD_LEN+1+_tcslen(pEnconn->m_pPassword));//发送密码
	}
	else//ENC110
	{
		*(short*)(&pData)=htons(4+_tcslen(pEnconn->m_pPassword));
		pData[2]=MSG_PASSWORD;
		pData[3]='A';//表示管理员	
		WideCharToMultiByte(CP_ACP,NULL,pEnconn->m_pPassword,_tcslen(pEnconn->m_pPassword),&pData[4],8,NULL,FALSE);
		rcvLen=pEnconn->Send((char*)pData,4+_tcslen(pEnconn->m_pPassword));//发送密码
	}
	if(rcvLen==-1)goto Exit;
	while(pEnconn->m_hSocket>0)
	{
		int nn = GetTickCount();
		if(pEnconn->Enctype==1)//ENC1200
		{
			rcvLen=pEnconn->Recv((char*)pEnconn->m_cVideoBuffer, HEAD_LEN);//接收编码器的数据
		}
		else//ENC110
		{
			rcvLen=pEnconn->Recv((char*)pEnconn->m_cVideoBuffer, 2);//接收编码器的数据
		}
		
		if(rcvLen == -1)
		{
			goto Exit;
		}		
		if(pEnconn->Enctype==1)//ENC1200
		{
			memcpy(&head,(pEnconn->m_cVideoBuffer),HEAD_LEN);	
			nDataLen=ntohs(head.nLen)-HEAD_LEN;
			if(nDataLen < 0)goto Exit;
			rcvLen=pEnconn->Recv((char*)pEnconn->m_cVideoBuffer, nDataLen);		
			msgcmd=head.nMsg;

		}
		else//ENC110
		{
			nDataLen=htons(*((unsigned short*)(pEnconn->m_cVideoBuffer)))-2;	
			if(nDataLen < 1)goto Exit;
			rcvLen=pEnconn->Recv((char*)pEnconn->m_cVideoBuffer, nDataLen);		
			msgcmd=pEnconn->m_cVideoBuffer[0];

		}
			
		if(rcvLen == -1)
		{
			goto Exit;
		}			
		switch(msgcmd) 
		{
		case MSG_CONNECTSUCC:				
			(pEnconn->m_RichEdit)->SetWindowTextW(_T("链接成功"));
			break;
		case MSG_PASSWORD_ERR:	
			pEnconn->PostMessage(RM_PASSWD_ERR,NULL);	
			(pEnconn->m_RichEdit)->SetWindowTextW(_T("密码错误"));
			break;
		case MSG_MAXCLIENT_ERR:				
			(pEnconn->m_RichEdit)->SetSel(-1,-1);
			(pEnconn->m_RichEdit)->ReplaceSel(_T("最大客户数\n"),0);
			break;
		case MSG_SCREENDATA:	
			//(pEnconn->m_RichEdit)->SetSel(-1,-1);
			//(pEnconn->m_RichEdit)->ReplaceSel(_T("h264 Data\n"),0);		
			//(pEnconn->m_RichEdit)->SetWindowTextW(_T("h264"));
			//printf("Recv h264 Data\n");
			
			if(pEnconn->saveStream==1)
			{
				if(pEnconn->Enctype==1)//ENC1200
					pEnconn->H264File.Write((char*)pEnconn->m_cVideoBuffer+sizeof(FRAMEHEAD),nDataLen-sizeof(FRAMEHEAD));
				else
					pEnconn->H264File.Write((char*)pEnconn->m_cVideoBuffer+1+sizeof(DataHeader),nDataLen-1-sizeof(DataHeader));
					
			}
			break;
		case MSG_AUDIODATA:							
			//(pEnconn->m_RichEdit)->SetSel(-1,-1);
			//(pEnconn->m_RichEdit)->ReplaceSel(_T("AAC Data\n"),0);
			//printf("Recv AAC Data\n");
			if(pEnconn->saveStream==1)
			{
				if(pEnconn->Enctype==1)//ENC1200
				pEnconn->AacFile.Write((char*)pEnconn->m_cVideoBuffer+sizeof(FRAMEHEAD),nDataLen-sizeof(FRAMEHEAD));
				else
				pEnconn->AacFile.Write((char*)pEnconn->m_cVideoBuffer+1+sizeof(DataHeader),nDataLen-1-sizeof(DataHeader));
			}
			break;
		case MSG_SYSPARAMS:
			
			printf("Recv MSG_SYSPARAMS \n");
			break;
		case MSG_TRACKAUTO:
			
			printf("Recv MSG_TRACKAUTO \n");
			break;
		case MSG_DATAINFO:
			
			printf("Recv MSG_DATAINFO \n");
			break;	
		case MSG_LOW_BITRATE:
			
			printf("Recv LowStream ok \n");
			break;
		case  MSG_LOW_SCREENDATA:			
			printf("Recv LowStream Data\n");
			break;
		case MSG_PIC_DATA:					
			//memcpy(&nDataLen, &pEnconn->m_cVideoBuffer[1],sizeof(nDataLen));
			memcpy(&nDataLen, (char*)pEnconn->m_cVideoBuffer+1,sizeof(nDataLen));
			printf("PPT索引图片=%d 字节\n", nDataLen);
			//hMem = ::GlobalAlloc(GMEM_MOVEABLE,nDataLen);
			//lpBuf = ::GlobalLock(hMem);
			rcvLen = pEnconn->Recv((char*)pEnconn->m_cVideoBuffer+4, nDataLen);
			finename.Format(_T("%d.jpg"),pptindex);
			if (!(pEnconn->JpgFile.Open(finename,CFile::modeCreate | CFile::modeWrite)))
			{
				printf("open jpegFile fail! \n");
				pptindex++;
				break;
			}
			pEnconn->JpgFile.Write((char*)pEnconn->m_cVideoBuffer+4,nDataLen);
			pEnconn->JpgFile.Close();
			pptindex++;
			hMem = ::GlobalAlloc(GMEM_MOVEABLE,nDataLen);
			lpBuf = ::GlobalLock(hMem);
			memcpy(lpBuf,(char*)pEnconn->m_cVideoBuffer+4,nDataLen);
			::GlobalUnlock(hMem);
			::CreateStreamOnHGlobal(hMem, TRUE, &pStm); //装入图形文件	
			if(SUCCEEDED(OleLoadPicture(pStm,nDataLen,TRUE,IID_IPicture,(LPVOID*)&pPic)))
			{
					
				OLE_XSIZE_HIMETRIC hmWidth;
				OLE_YSIZE_HIMETRIC hmHeight;
				pPic->get_Width(&hmWidth); //用接口方法获得图片的宽和高
				pPic->get_Height(&hmHeight);				
				printf("PPTJPEG=%d=%d\n",hmWidth,hmHeight);
				//获取桌面窗口句柄
				hwnd = ::GetDesktopWindow();
				//获取桌面窗口DC
				hdc = ::GetWindowDC(hwnd);				
				CRect rect;
				CDC *pDC=CDC::FromHandle(hdc);
				//////显示原图大小/////////////////////////////////////////////////////////////
				CSize sz(hmWidth,hmHeight);
				pDC->HIMETRICtoDP(&sz); //转换MM_HIMETRIC模式单位为MM_TEXT像素单位			
				pPic->Render(hdc,80,80,sz.cx,sz.cy,0,hmHeight,hmWidth,-hmHeight,NULL);
				//按窗口尺寸显示///////////////////						  
				GetClientRect(hwnd,&rect);
				if(pPic) pPic->Release();					
				::ReleaseDC(hwnd, hdc);
				
			}				
			pStm->Release();  

			printf("Recv PPT Data\n");
			break;
		case MSG_GET_LOGOINFO:	
			printf("Recv MSG_GET_LOGOINFO \n");
			break;
		case MSG_PIC_DATAEX:	
			printf("Recv MSG_PIC_DATAEX \n");
			recvedlen=0;			
			break;
		default:
	
			break;
		}
		
	}

Exit:	
	pEnconn->Connflag=0;
	pEnconn->PostMessage(RM_DISCONN,NULL);
	return 1;

}
Beispiel #23
0
 int size() { return sz(root); }
static void Print_Module( EDA_DRAW_PANEL* aPanel, wxDC* aDC, MODULE* aModule,
                          GR_DRAWMODE aDraw_mode, LSET aMask,
                          PRINT_PARAMETERS::DrillShapeOptT aDrillShapeOpt )
{
    // Print pads
    for( D_PAD* pad = aModule->Pads();  pad;  pad = pad->Next() )
    {
        if( !( pad->GetLayerSet() & aMask ).any() )
            continue;

        // Manage hole according to the print drill option
        wxSize drill_tmp = pad->GetDrillSize();

        switch( aDrillShapeOpt )
        {
        case PRINT_PARAMETERS::NO_DRILL_SHAPE:
            pad->SetDrillSize( wxSize(0,0) );
            break;

        case PRINT_PARAMETERS::SMALL_DRILL_SHAPE:
            {
                wxSize sz(  std::min( SMALL_DRILL, pad->GetDrillSize().x ),
                            std::min( SMALL_DRILL, pad->GetDrillSize().y ) );

                pad->SetDrillSize( sz );
            }
            break;

        case PRINT_PARAMETERS::FULL_DRILL_SHAPE:
            // Do nothing
            break;
        }

        pad->Draw( aPanel, aDC, aDraw_mode );
        pad->SetDrillSize( drill_tmp );
    }

    // Print footprint graphic shapes
    LSET mlayer( aModule->GetLayer() );

    if( aModule->GetLayer() == B_Cu )
        mlayer = LSET( B_SilkS );
    else if( aModule->GetLayer() == F_Cu )
        mlayer = LSET( F_SilkS );

    if( ( mlayer & aMask ).any() )
    {
        if( aModule->Reference().IsVisible() )
            aModule->Reference().Draw( aPanel, aDC, aDraw_mode );

        if( aModule->Value().IsVisible() )
            aModule->Value().Draw( aPanel, aDC, aDraw_mode );
    }

    for( EDA_ITEM* item = aModule->GraphicalItems();  item;  item = item->Next() )
    {
        switch( item->Type() )
        {
        case PCB_MODULE_TEXT_T:
            {
                if( !( mlayer & aMask ).any() )
                    break;

                TEXTE_MODULE* textMod = static_cast<TEXTE_MODULE*>( item );
                textMod->Draw( aPanel, aDC, aDraw_mode );
                break;
            }

        case PCB_MODULE_EDGE_T:
            {
                EDGE_MODULE* edge = static_cast<EDGE_MODULE*>( item );

                if( !aMask[edge->GetLayer()] )
                    break;

                edge->Draw( aPanel, aDC, aDraw_mode );
            }
            break;

        default:
            break;
        }
    }
}
Beispiel #25
0
void CEditPrevWnd::OnMouseMove(UINT nFlags, CPoint point) 
{
	if(!m_bCropPress)
	{
		if(m_bMoveEnabled)
		{
			m_ptChanged = point - m_ptMoveStart;
			m_ptMoveStart = point;

			if(!m_bMoveFore)
			{
				if(m_ptChanged != CPoint(0,0))
					PointContrast();
			}
			else	//move fore image
			{
				CSize sz(0,0);
				sz = CSize((LONG)(m_ptChanged.x/m_dScaling), (LONG)(m_ptChanged.y/m_dScaling));
				if(sz != CSize(0,0))
				{
					(((CPhotoEditDlg*)m_pParentWnd)->GetCurObject())->MoveForeImage(sz);
					((CPhotoEditDlg*)m_pParentWnd)->SetCurImageModified(true);
					CDC* pDC = GetDC();
					DrawFore(pDC);
					ReleaseDC(pDC);
				}
			}
		}
		else
		{
			::SetCursor(::AfxGetApp()->LoadCursor(IDC_CURSOR_HAND_ON));
		}
	}
	else
	{
		if(((CPhotoEditDlg*)m_pParentWnd)->GetEditType() == EDIT_RESIZE)
		{
		if(!m_rtImageRect.PtInRect(point))
			return;
		::SetCursor(::AfxGetApp()->LoadStandardCursor(IDC_CROSS));
		{
			
			if((nFlags & MK_LBUTTON) == MK_LBUTTON)//&&(m_rtImageRect.PtInRect(m_OldPoint)))
			{
				if(m_bAfterCrop)
				{
					Invalidate();
					m_bAfterCrop = FALSE;
				}
			
				CDC * pDC = GetDC();
				CRect rtOld;
				if(m_OldPoint.x < m_rtImageRect.left)
					 m_OldPoint.x = m_rtImageRect.left;
				if (m_OldPoint.x > m_rtImageRect.right)
					 m_OldPoint.x = m_rtImageRect.right;
				if(m_OldPoint.y < m_rtImageRect.top)
					 m_OldPoint.y = m_rtImageRect.top;
				if (m_OldPoint.y > m_rtImageRect.bottom)
					 m_OldPoint.y = m_rtImageRect.bottom;
				int x1 = m_OldPoint.x;
				int y1 = m_OldPoint.y;
				int x2 = m_PrePoint.x;
				int y2 = m_PrePoint.y;
				rtOld.left = min(x1,x2);
				rtOld.top = min(y1,y2);
				rtOld.right = max(x1,x2);
				rtOld.bottom = max(y1,y2);
				DrawRect(pDC,rtOld);
				if(point.x < m_rtImageRect.left)
					 point.x = m_rtImageRect.left;
				if (point.x > m_rtImageRect.right)
					 point.x = m_rtImageRect.right;
				if(point.y < m_rtImageRect.top)
					 point.y = m_rtImageRect.top;
				if (point.y > m_rtImageRect.bottom)
					 point.y = m_rtImageRect.bottom;
				m_PrePoint = point;
				CRect rtNew;
				x1 = m_OldPoint.x;
				y1 = m_OldPoint.y;
				x2 = point.x;
				y2 = point.y;
				rtNew.left = min(x1,x2);
				rtNew.top = min(y1,y2);
				rtNew.right = max(x1,x2);
				rtNew.bottom = max(y1,y2);
				m_rtPreRect = rtNew;
				DrawRect(pDC,m_rtPreRect);
			
				m_bRectExist = TRUE;
				//Draw(pDC);
				ReleaseDC(pDC);
			}
			}
		}
	}
	CWnd::OnMouseMove(nFlags, point);
}
Beispiel #26
0
/* When called with c==-1, it just creates the prompt */
static int itype(W *w, int c, void *obj, int *notify)
{
	IREC *i;
	int omid;
	BW *bw;
	struct isrch *isrch = (struct isrch *)obj;
	WIND_BW(bw,w);

	if (isrch->quote) {
		goto in;
	}
	if (c == 8 || c == 127) {	/* Backup */
		if ((i = isrch->irecs.link.prev) != &isrch->irecs) {
			pgoto(bw->cursor, i->disp);
			if (globalsrch)
				globalsrch->wrap_flag = i->wrap_flag;
			omid = opt_mid;
			opt_mid = 1;
			dofollows();
			opt_mid = omid;
			isrch->pattern = vstrunc(isrch->pattern, sLEN(isrch->pattern) - i->what);
			frirec(deque_f(IREC, link, i));
		} else {
			if(joe_beep)
				ttputc(7);
		}
	} else if (c == 'Q' - '@' /* || c == '`' */) {
		isrch->quote = 1;
	} else if (c == 'S' - '@' || c == '\\' - '@' || c == 'L' - '@' || c == 'R' - '@') {
		/* Repeat */
		if (c == 'R' - '@') {
			isrch->dir = 1;
		} else {
			isrch->dir = 0;
		}
		if (qempty(IREC, link, &isrch->irecs)) {
			if (lastpat && lastpat[0]) {
				iappend(bw, isrch, sv(lastpat));
			}
		} else {
			SRCH *srch;
			i = alirec();
			i->disp = i->start = bw->cursor->byte;
			i->what = 0;

			if (!globalsrch)
				srch = mksrch(NULL,NULL,opt_icase,isrch->dir,-1,0,0,0,0);
			else {
				srch = globalsrch;
				globalsrch = 0;
			}

			srch->addr = bw->cursor->byte;

			if (!srch->wrap_p || srch->wrap_p->b!=bw->b) {
				prm(srch->wrap_p);
				srch->wrap_p = pdup(bw->cursor, "itype");
				srch->wrap_p->owner = &srch->wrap_p;
				srch->wrap_flag = 0;
			}

			i->wrap_flag = srch->wrap_flag;

			setpat(srch, vsncpy(NULL, 0, isrch->pattern, sLen(isrch->pattern)));
			srch->backwards = isrch->dir;

			if (dopfnext(bw, srch, NULL)) {
				if(joe_beep)
					ttputc(7);
				frirec(i);
			} else {
				enqueb(IREC, link, &isrch->irecs, i);
			}
		}
	} else if (c >= 0 && c < 32) {
		/* Done when a control character is received */
		nungetc(c);
		if (notify) {
			*notify = 1;
		}
		smode = 2;
		if (lastisrch) {
			lastpat = vstrunc(lastpat, 0);
			lastpat = vsncpy(lastpat, 0, lastisrch->pattern, sLen(lastisrch->pattern));
			rmisrch(lastisrch);
		}
		lastisrch = isrch;
		return 0;
	} else if (c != -1) {
		char buf[16];
		ptrdiff_t buf_len;
		/* Search */

		in:

		if (bw->b->o.charmap->type) {
			buf_len = utf8_encode(buf, c);
		} else {
			buf[0] = TO_CHAR_OK(from_uni(bw->b->o.charmap, c));
			buf_len = 1;
		}		

		isrch->quote = 0;
		iappend(bw, isrch, buf, buf_len);
	}
	omid = opt_mid;
	opt_mid = 1;
	bw->cursor->xcol = piscol(bw->cursor);
	dofollows();
	opt_mid = omid;

	isrch->prompt = vstrunc(isrch->prompt, isrch->ofst);

	if (locale_map->type && !bw->b->o.charmap->type) {
		/* Translate bytes to utf-8 */
		char buf[16];
		int x;
		for (x=0; x!=sLEN(isrch->pattern); ++x) {
			int tc = to_uni(bw->b->o.charmap, isrch->pattern[x]);
			utf8_encode(buf, tc);
			isrch->prompt = vsncpy(sv(isrch->prompt),sz(buf));
		}
	} else if (!locale_map->type && bw->b->o.charmap->type) {
		/* Translate utf-8 to bytes */
		const char *p = isrch->pattern;
		ptrdiff_t len = sLEN(isrch->pattern);
		while (len) {
			int tc = utf8_decode_fwrd(&p, &len);
			if (tc >= 0) {
				tc = from_uni(locale_map, tc);
				isrch->prompt = vsadd(isrch->prompt, TO_CHAR_OK(tc));
			}
		}
	} else {
		/* FIXME: translate when charmaps do not match */
		isrch->prompt = vsncpy(sv(isrch->prompt),sv(isrch->pattern));
	}

	if (mkqwnsr(bw->parent, sv(isrch->prompt), itype, iabrt, isrch, notify)) {
		return 0;
	} else {
		rmisrch(isrch);
		return -1;
	}
}
//////////////////
// Create string dialog. If no icon specified, use IDI_QUESTION. Note that
// the order in which the controls are added is the TAB order.
//
BOOL CInputDialog::Init(LPCTSTR caption, LPCTSTR prompt, CWnd* pParent, WORD nIDIcon)
{
	const DWORD CXDIALOG  = 200;					 // dialog width
	const DWORD DLGMARGIN = 7;						 // margins all around
	const DWORD CYSTATIC  = 8;						 // height of static text
	const DWORD CYEDIT    = 12;					 // height of edit control
	const DWORD CYSPACE   = 5;						 // vertical space between controls
	const DWORD CXBUTTON  = 40;					 // button width...
	const DWORD CYBUTTON  = 15;					 // ..and height

	CDlgTemplateBuilder& dtb = m_dtb;
	CRect rc(
		CPoint(0,0),
		CSize(CXDIALOG, CYSTATIC + CYEDIT + CYBUTTON + 2*DLGMARGIN + 2*CYSPACE));

	// create dialog header
	DLGTEMPLATE* pTempl = dtb.Begin(WS_POPUPWINDOW|DS_MODALFRAME|WS_DLGFRAME,rc,caption);

	// shrink main rect by margins
	rc.DeflateRect(CSize(DLGMARGIN,DLGMARGIN));

	// create icon if needed
	if (nIDIcon) {
		if (nIDIcon >= (WORD)IDI_APPLICATION) {
			// if using a system icon, I load it here and set it in OnInitDialog
			// because can't specify system icon in template, only icons from
			// application resource file.
			m_hIcon = ::LoadIcon(NULL, MAKEINTRESOURCE(nIDIcon));
			nIDIcon = 0;
		} else {
			m_hIcon = NULL;
		}

		// The size is calculated in pixels, but it seems to work OK--???
		CSize sz(GetSystemMetrics(SM_CXICON),GetSystemMetrics(SM_CYICON));
		CRect rcIcon(rc.TopLeft(), sz);
		dtb.AddItem(CDlgTemplateBuilder::STATIC, // add icon 
			WS_VISIBLE|WS_CHILD|SS_LEFT|SS_ICON, rc, nIDIcon, IDICON);
		rc.left += sz.cx;  // shrink main rect by width of icon
	}

	// add prompt
	rc.bottom = rc.top + CYSTATIC;					// height = height of static
	dtb.AddItem(CDlgTemplateBuilder::STATIC,		// add it
		WS_VISIBLE|WS_CHILD|SS_LEFT, rc, prompt);

	// add edit control
	rc += CPoint(0, rc.Height() + CYSPACE);		// move below static
	rc.bottom = rc.top + CYEDIT;						// height = height of edit control
	dtb.AddItem(CDlgTemplateBuilder::EDIT,			// add it ES_AUTOHSCROLL must be add
		WS_VISIBLE|WS_CHILD|WS_BORDER|WS_TABSTOP|ES_AUTOHSCROLL, rc, m_str, IDEDIT);

	// add OK button
	rc += CPoint(0, rc.Height() + CYSPACE);		// move below edit control
	rc.bottom = rc.top + CYBUTTON;					// height = button height
	rc.left   = rc.right - CXBUTTON;					// width  = button width
	rc -= CPoint(CXBUTTON + DLGMARGIN,0);			// move left one button width
	dtb.AddItem(CDlgTemplateBuilder::BUTTON,		// add it
		WS_VISIBLE|WS_CHILD|WS_TABSTOP|BS_DEFPUSHBUTTON, rc, _T("&OK"), IDOK);

	// add Cancel button
	rc += CPoint(CXBUTTON + DLGMARGIN,0);			// move right again
	dtb.AddItem(CDlgTemplateBuilder::BUTTON,		// add Cancel button
		WS_VISIBLE|WS_CHILD|WS_TABSTOP, rc, _T("&Cancel"), IDCANCEL);

	return InitModalIndirect(pTempl, pParent);
}
Beispiel #28
0
// Pass true to show full screen, false to restore.
bool wxFrame::ShowFullScreen( bool bShow, long lStyle )
{
    if (bShow)
    {
        if (IsFullScreen())
            return false;

        m_bFsIsShowing = true;
        m_lFsStyle = lStyle;

#if wxUSE_TOOLBAR
        wxToolBar*                  pTheToolBar = GetToolBar();
#endif //wxUSE_TOOLBAR

#if wxUSE_STATUSBAR
        wxStatusBar*                pTheStatusBar = GetStatusBar();
#endif //wxUSE_STATUSBAR

        int                         nDummyWidth;

#if wxUSE_TOOLBAR
        if (pTheToolBar)
            pTheToolBar->GetSize(&nDummyWidth, &m_nFsToolBarHeight);
#endif //wxUSE_TOOLBAR

#if wxUSE_STATUSBAR
        if (pTheStatusBar)
            pTheStatusBar->GetSize(&nDummyWidth, &m_nFsStatusBarHeight);
#endif //wxUSE_STATUSBAR

#if wxUSE_TOOLBAR
        //
        // Zap the toolbar, menubar, and statusbar
        //
        if ((lStyle & wxFULLSCREEN_NOTOOLBAR) && pTheToolBar)
        {
            pTheToolBar->SetSize(wxDefaultCoord,0);
            pTheToolBar->Show(false);
        }
#endif //wxUSE_TOOLBAR

        if (lStyle & wxFULLSCREEN_NOMENUBAR)
        {
            ::WinSetParent(m_hMenu, m_hFrame, FALSE);
            ::WinSetOwner(m_hMenu, m_hFrame);
            ::WinSendMsg((HWND)m_hFrame, WM_UPDATEFRAME, (MPARAM)FCF_MENU, (MPARAM)0);
        }

#if wxUSE_STATUSBAR
        //
        // Save the number of fields in the statusbar
        //
        if ((lStyle & wxFULLSCREEN_NOSTATUSBAR) && pTheStatusBar)
        {
            m_nFsStatusBarFields = pTheStatusBar->GetFieldsCount();
            SetStatusBar(NULL);
            delete pTheStatusBar;
        }
        else
            m_nFsStatusBarFields = 0;
#endif //wxUSE_STATUSBAR

        //
        // Zap the frame borders
        //

        //
        // Save the 'normal' window style
        //
        m_lFsOldWindowStyle = ::WinQueryWindowULong(m_hFrame, QWL_STYLE);

        //
        // Save the old position, width & height, maximize state
        //
        m_vFsOldSize = GetRect();
        m_bFsIsMaximized = IsMaximized();

        //
        // Decide which window style flags to turn off
        //
        LONG lNewStyle = m_lFsOldWindowStyle;
        LONG lOffFlags = 0;

        if (lStyle & wxFULLSCREEN_NOBORDER)
            lOffFlags |= FCF_BORDER;
        if (lStyle & wxFULLSCREEN_NOCAPTION)
            lOffFlags |= (FCF_TASKLIST | FCF_SYSMENU);

        lNewStyle &= (~lOffFlags);

        //
        // Change our window style to be compatible with full-screen mode
        //
        ::WinSetWindowULong((HWND)m_hFrame, QWL_STYLE, (ULONG)lNewStyle);

        //
        // Resize to the size of the desktop
        int                         nWidth;
        int                         nHeight;

        RECTL                       vRect;

        ::WinQueryWindowRect(HWND_DESKTOP, &vRect);
        nWidth = vRect.xRight - vRect.xLeft;
        //
        // Remember OS/2 is backwards!
        //
        nHeight = vRect.yTop - vRect.yBottom;

        SetSize( nWidth, nHeight);

        //
        // Now flush the window style cache and actually go full-screen
        //
        ::WinSetWindowPos( (HWND) GetParent()->GetHWND()
                          ,HWND_TOP
                          ,0
                          ,0
                          ,nWidth
                          ,nHeight
                          ,SWP_SIZE | SWP_SHOW
                         );

        wxSize sz( nWidth, nHeight );
        wxSizeEvent vEvent( sz, GetId() );

        HandleWindowEvent(vEvent);
        return true;
    }
    else
    {
        if (!IsFullScreen())
            return false;

        m_bFsIsShowing = false;

#if wxUSE_TOOLBAR
        wxToolBar*                  pTheToolBar = GetToolBar();

        //
        // Restore the toolbar, menubar, and statusbar
        //
        if (pTheToolBar && (m_lFsStyle & wxFULLSCREEN_NOTOOLBAR))
        {
            pTheToolBar->SetSize(wxDefaultCoord, m_nFsToolBarHeight);
            pTheToolBar->Show(true);
        }
#endif //wxUSE_TOOLBAR

#if wxUSE_STATUSBAR
        if ((m_lFsStyle & wxFULLSCREEN_NOSTATUSBAR) && (m_nFsStatusBarFields > 0))
        {
            CreateStatusBar(m_nFsStatusBarFields);
//          PositionStatusBar();
        }
#endif //wxUSE_STATUSBAR

        if ((m_lFsStyle & wxFULLSCREEN_NOMENUBAR) && (m_hMenu != 0))
        {
            ::WinSetParent(m_hMenu, m_hFrame, FALSE);
            ::WinSetOwner(m_hMenu, m_hFrame);
            ::WinSendMsg(m_hFrame, WM_UPDATEFRAME, (MPARAM)FCF_MENU, (MPARAM)0);
        }
        Maximize(m_bFsIsMaximized);

        ::WinSetWindowULong( m_hFrame
                            ,QWL_STYLE
                            ,(ULONG)m_lFsOldWindowStyle
                           );
        ::WinSetWindowPos( (HWND) GetParent()->GetHWND()
                          ,HWND_TOP
                          ,m_vFsOldSize.x
                          ,m_vFsOldSize.y
                          ,m_vFsOldSize.width
                          ,m_vFsOldSize.height
                          ,SWP_SIZE | SWP_SHOW
                         );
    }
    return wxFrameBase::ShowFullScreen(bShow, lStyle);
} // end of wxFrame::ShowFullScreen
Beispiel #29
0
void Objecte::readObj(QString filename)
{

    FILE *fp = fopen(filename.toLocal8Bit(),"rb");
    if (!fp)
    {
        cout << "No puc obrir el fitxer " << endl;
    }
    else {

        while (true)
        {
            char *comment_ptr = ReadFile::fetch_line (fp);

            if (comment_ptr == (char *) -1)  /* end-of-file */
                break;

            /* did we get a comment? */
            if (comment_ptr) {
                //make_comment (comment_ptr);
                continue;
            }

            /* if we get here, the line was not a comment */
            int nwords = ReadFile::fetch_words();

            /* skip empty lines */
            if (nwords == 0)
                continue;

            char *first_word = ReadFile::words[0];

            if (!strcmp (first_word, "v"))
            {
                if (nwords < 4)
                {
                    fprintf (stderr, "Too few coordinates: '%s'", ReadFile::str_orig);
                    exit (-1);
                }
                QString sx(ReadFile::words[1]);
                QString sy(ReadFile::words[2]);
                QString sz(ReadFile::words[3]);
                double x = sx.toDouble();
                double y = sy.toDouble();
                double z = sz.toDouble();

                if (nwords == 5)
                {
                    QString sw(ReadFile::words[4]);
                    double w = sw.toDouble();
                    x/=w;
                    y/=w;
                    z/=w;
                }
                // S'afegeix el vertex a l'objecte
                vertexs.push_back(point4(x, y, z, 1));

            }
            else if (!strcmp (first_word, "vn")) {
            }
            else if (!strcmp (first_word, "vt")) {
            }
            else if (!strcmp (first_word, "f")) {
                // S'afegeix la cara a l'objecte
                // A modificar si es vol carregar mes de un objecte
                construeix_cara (&ReadFile::words[1], nwords-1, this, 0);
            }
            // added
            else if (!strcmp (first_word, "mtllib")) {
                //read_mtllib (&words[1], nwords-1, matlib, filename);
            }
            else if (!strcmp (first_word, "usemtl")) {
                //int size = strlen(words[1])-1;
                //while (size && (words[1][size]=='\n' || words[1][size]=='\r') ) words[1][size--]=0;
                //currentMaterial = matlib.index(words[1]);
            }
            // fadded
            else {
                //fprintf (stderr, "Do not recognize: '%s'\n", str_orig);
            }
        }
    }

    capsa = calculCapsa3D();
}
void spt(nd *n,nd *&l,nd *&r,int key){
    if(!n)l=r=0;
    else if(sz(n->l)<key)spt(n->r,n->r,r,key-sz(n->l)-1),l=n;
    else spt(n->l,l,n->l,key),r=n;
    upd(n);
}