コード例 #1
0
ファイル: ODdc.cpp プロジェクト: Hakansv/ocpn_draw_pi
void ODDC::DrawPolygonsTessellated( int n, int npoints[], wxPoint points[], wxCoord xoffset, wxCoord yoffset )
{
    if( dc ) {
        int prev = 0;
        for( int i = 0; i < n; i++ ) {
            dc->DrawPolygon( npoints[i], &points[i + prev], xoffset, yoffset );
            prev += npoints[i];
        }
    }
    #ifdef ocpnUSE_GL
    else {
        
        GLUtesselator *tobj = gluNewTess();
        
        gluTessCallback( tobj, GLU_TESS_VERTEX, (_GLUfuncptr) &ODDCvertexCallback );
        gluTessCallback( tobj, GLU_TESS_BEGIN, (_GLUfuncptr) &ODDCbeginCallback );
        gluTessCallback( tobj, GLU_TESS_END, (_GLUfuncptr) &ODDCendCallback );
        gluTessCallback( tobj, GLU_TESS_COMBINE, (_GLUfuncptr) &ODDCcombineCallback );
        gluTessCallback( tobj, GLU_TESS_ERROR, (_GLUfuncptr) &ODDCerrorCallback );
        
        gluTessNormal( tobj, 0, 0, 1);
        gluTessProperty(tobj, GLU_TESS_WINDING_RULE, GLU_TESS_WINDING_ODD);
        glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
        gluTessProperty(tobj, GLU_TESS_BOUNDARY_ONLY, GL_FALSE);
        
        if(glIsEnabled(GL_TEXTURE_2D)) g_bTexture2D = true;
        else g_bTexture2D = false;
        
        ConfigurePen();
        if( ConfigureBrush() ) {
            gluTessBeginPolygon(tobj, NULL);
            int prev = 0;
            for( int j = 0; j < n; j++ ) {
                gluTessBeginContour(tobj);
                for( int i = 0; i < npoints[j]; i++ ) {
                    GLvertex* vertex = new GLvertex();
                    gTesselatorVertices.Add( vertex );
                    vertex->info.x = (GLdouble) points[i + prev].x;
                    vertex->info.y = (GLdouble) points[i + prev].y;
                    vertex->info.z = (GLdouble) 0.0;
                    vertex->info.r = (GLdouble) 0.0;
                    vertex->info.g = (GLdouble) 0.0;
                    vertex->info.b = (GLdouble) 0.0;
                    vertex->info.a = (GLdouble) 0.0;
                    gluTessVertex( tobj, (GLdouble*)vertex, (GLdouble*)vertex );
                }
                gluTessEndContour( tobj );
                prev += npoints[j];
            }
            gluTessEndPolygon(tobj);
        }
        
        gluDeleteTess(tobj);
        for (unsigned int i = 0; i<gTesselatorVertices.Count(); i++)
            delete (GLvertex*)gTesselatorVertices.Item(i);
        gTesselatorVertices.Clear();
        
    }
    #endif    
}
コード例 #2
0
ファイル: ocpndc.cpp プロジェクト: libai245/wht1
void ocpnDC::DrawPolygonTessellated( int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset )
{
    if( dc )
        dc->DrawPolygon( n, points, xoffset, yoffset );
#ifdef ocpnUSE_GL
    else {
# ifndef ocpnUSE_GLES  // tessalator in glues is broken
        if( n < 5 )
# endif
        {
            DrawPolygon( n, points, xoffset, yoffset );
            return;
        }

        glPushAttrib( GL_ENABLE_BIT | GL_COLOR_BUFFER_BIT | GL_LINE_BIT | GL_HINT_BIT | GL_POLYGON_BIT ); //Save state
        SetGLAttrs( false );

        static GLUtesselator *tobj = NULL;
        if( ! tobj ) tobj = gluNewTess();

        gluTessCallback( tobj, GLU_TESS_VERTEX, (_GLUfuncptr) &ocpnDCvertexCallback );
        gluTessCallback( tobj, GLU_TESS_BEGIN, (_GLUfuncptr) &ocpnDCbeginCallback );
        gluTessCallback( tobj, GLU_TESS_END, (_GLUfuncptr) &ocpnDCendCallback );
        gluTessCallback( tobj, GLU_TESS_COMBINE, (_GLUfuncptr) &ocpnDCcombineCallback );
        gluTessCallback( tobj, GLU_TESS_ERROR, (_GLUfuncptr) &ocpnDCerrorCallback );

        gluTessNormal( tobj, 0, 0, 1);
        gluTessProperty( tobj, GLU_TESS_WINDING_RULE, GLU_TESS_WINDING_NONZERO );

        if( ConfigureBrush() ) {
            gluTessBeginPolygon( tobj, NULL );
            gluTessBeginContour( tobj );

            for( int i = 0; i < n; i++ ) {
                GLvertex* vertex = new GLvertex();
                gTesselatorVertices.Add( vertex );
                vertex->info.x = (GLdouble) points[i].x;
                vertex->info.y = (GLdouble) points[i].y;
                vertex->info.z = (GLdouble) 0.0;
                vertex->info.r = (GLdouble) 0.0;
                vertex->info.g = (GLdouble) 0.0;
                vertex->info.b = (GLdouble) 0.0;
                gluTessVertex( tobj, (GLdouble*)vertex, (GLdouble*)vertex );
            }
            gluTessEndContour( tobj );
            gluTessEndPolygon( tobj );
        }

        glPopAttrib();

        for( unsigned int i=0; i<gTesselatorVertices.Count(); i++ )
            delete (GLvertex*)gTesselatorVertices.Item(i);
        gTesselatorVertices.Clear();
    }
#endif    
}
コード例 #3
0
wxSpeedButton::~wxSpeedButton() {
int         n;

// release the mouse

//    if (HasCapture()) ReleaseMouse();

// erase entry in master array

    n = sbgArray.Index((void *) this);
    if (n != wxNOT_FOUND) sbgArray.RemoveAt(n);

}
コード例 #4
0
void    wxSpeedButton::SetAllUp(wxSpeedButton *inButton) {
int             i,n;
wxSpeedButton   *b;

// no button?

    if (inButton == NULL) return;

// simple button

    if (inButton->mGroupIndex == 0) {
        inButton->mButtonDown = false;
        inButton->Refresh(false);
    }

// toggle button

    else if (inButton->mGroupIndex == -1) {
        inButton->mButtonDown = false;
        inButton->Refresh(false);
    }

// group button, grouped by immediate parent

    else if (inButton->mGroupIndex == -2) {
        n = sbgArray.GetCount();
        for(i=0; i<n; i++) {
            b = (wxSpeedButton *) sbgArray.Item(i);
            if (b->mParent == inButton->mParent) {
                b->mButtonDown = false;
                b->Refresh(false);
            };
        };
    }

// all else is a group toggle button, grouped by index and top-level parent

    else {
        n = sbgArray.GetCount();
        for(i=0; i<n; i++) {
            b = (wxSpeedButton *) sbgArray.Item(i);
            if ((b->mGroupIndex == inButton->mGroupIndex) && (b->mTopParent == inButton->mTopParent)) {
                b->mButtonDown = false;
                b->Refresh(false);
            };
        };
    };


}
コード例 #5
0
ファイル: pdfparser.cpp プロジェクト: 469306621/Languages
void
wxPdfParser::GetPageContent(wxPdfObject* contentRef, wxArrayPtrVoid& contents)
{
  int type = contentRef->GetType();
  if (type == OBJTYPE_INDIRECT)
  {
    wxPdfObject* content = ResolveObject(contentRef);
    if (content->GetType() == OBJTYPE_ARRAY)
    {
      GetPageContent(content, contents);
      delete content;
    }
    else
    {
      contents.Add(content);
    }
  }
  else if (type == OBJTYPE_ARRAY)
  {
    wxPdfArray* contentArray = (wxPdfArray*) contentRef;
    size_t n = contentArray->GetSize();
    size_t j;
    for (j = 0; j < n; j++)
    {
      GetPageContent(contentArray->Get(j), contents);
    }
  }
}
コード例 #6
0
ファイル: tutorial5.cpp プロジェクト: maxmods/wx.mod
 // Better table
 void ImprovedTable(wxArrayString& header,wxArrayPtrVoid& data)
 {
   // Column widths
   double w[4] = {40,35,40,45};
   // Header
   size_t i;
   for (i = 0; i <header.GetCount(); i++)
   {
     Cell(w[i],7,header[i],wxPDF_BORDER_FRAME,0,wxPDF_ALIGN_CENTER);
   }
   Ln();
   // Data
   size_t j;
   for (j = 0; j < data.GetCount(); j++)
   {
     wxArrayString* row = (wxArrayString*) data[j];
     Cell(w[0],6,(*row)[0],wxPDF_BORDER_LEFT | wxPDF_BORDER_RIGHT);
     Cell(w[1],6,(*row)[1],wxPDF_BORDER_LEFT | wxPDF_BORDER_RIGHT);
     Cell(w[2],6,(*row)[2],wxPDF_BORDER_LEFT | wxPDF_BORDER_RIGHT,0,wxPDF_ALIGN_RIGHT);
     Cell(w[3],6,(*row)[3],wxPDF_BORDER_LEFT | wxPDF_BORDER_RIGHT,0,wxPDF_ALIGN_RIGHT);
     Ln();
   }
   // Closure line
   Cell((w[0]+w[1]+w[2]+w[3]),0,wxS(""),wxPDF_BORDER_TOP);
 }
コード例 #7
0
ファイル: tutorial5.cpp プロジェクト: maxmods/wx.mod
 // Colored table
 void FancyTable(wxArrayString& header, wxArrayPtrVoid& data)
 {
   // Colors, line width and bold font
   SetFillColour(wxColour(255,0,0));
   SetTextColour(255);
   SetDrawColour(wxColour(128,0,0));
   SetLineWidth(.3);
   SetFont(wxS(""),wxS("B"));
   //Header
   double w[4] = {40,35,40,45};
   size_t i;
   for (i = 0; i < header.GetCount(); i++)
   {
     Cell(w[i],7,header[i],wxPDF_BORDER_FRAME, 0, wxPDF_ALIGN_CENTER, 1);
   }
   Ln();
   // Color and font restoration
   SetFillColour(wxColour(224,235,255));
   SetTextColour(0);
   SetFont(wxS(""));
   // Data
   int fill = 0;
   size_t j;
   for (j = 0; j < data.GetCount(); j++)
   {
     wxArrayString* row = (wxArrayString*) data[j];
     Cell(w[0],6,(*row)[0],wxPDF_BORDER_LEFT | wxPDF_BORDER_RIGHT,0,wxPDF_ALIGN_LEFT,fill);
     Cell(w[1],6,(*row)[1],wxPDF_BORDER_LEFT | wxPDF_BORDER_RIGHT,0,wxPDF_ALIGN_LEFT,fill);
     Cell(w[2],6,(*row)[2],wxPDF_BORDER_LEFT | wxPDF_BORDER_RIGHT,0,wxPDF_ALIGN_RIGHT,fill);
     Cell(w[3],6,(*row)[3],wxPDF_BORDER_LEFT | wxPDF_BORDER_RIGHT,0,wxPDF_ALIGN_RIGHT,fill);
     Ln();
     fill = 1 - fill;
   }
   Cell((w[0]+w[1]+w[2]+w[3]),0,wxS(""),wxPDF_BORDER_TOP);
 }
コード例 #8
0
ファイル: Utils.cpp プロジェクト: Hreinnjons/guayadeque
// -------------------------------------------------------------------------------- //
void GetMediaViewersList( const guTrackArray &tracks, wxArrayPtrVoid &MediaViewerPtrs )
{
    int Index;
    int Count = tracks.Count();
    for( Index = 0; Index < Count; Index++ )
    {
        guTrack &Track = tracks[ Index ];
        guMediaViewer * MediaViewer = Track.m_MediaViewer;
        if( MediaViewer )
        {
            if( MediaViewerPtrs.Index( MediaViewer ) == wxNOT_FOUND )
            {
                MediaViewerPtrs.Add( MediaViewer );
            }
        }
    }
}
コード例 #9
0
ファイル: thread.cpp プロジェクト: gitrider/wxsj2
wxThread::wxThread(wxThreadKind kind)
{
    g_numberOfThreads++;
    m_internal = new wxThreadInternal();

    m_isDetached = kind == wxTHREAD_DETACHED;
    s_threads.Add( (void*) this ) ;
}
コード例 #10
0
ファイル: main.cpp プロジェクト: caicry/wxVSImport
	void DoGetGridInfoString()
	{
		int row, col, i;
		wxString strFilterName, strFilterPath;
		row = m_grid_dir->GetNumberRows();
		col = m_grid_dir->GetNumberCols();
		m_GridInfoPtr.Empty();

		for (i=0; i<row; i++) {
			strFilterName = m_grid_dir->GetCellValue(i, 0);
			strFilterPath = m_grid_dir->GetCellValue(i, 1);
			if (strFilterName.IsEmpty())
				break;
			CGridInfo *pInfo = new CGridInfo;
			pInfo->strFilterName = strFilterName;
			pInfo->strFilterPath = strFilterPath;
			m_GridInfoPtr.Add(pInfo);
		}
	}
コード例 #11
0
ファイル: recbookfile.cpp プロジェクト: DDMAL/aruspix
bool RecBookFile::TypAdaptation( wxArrayPtrVoid params, AxProgressDlg *dlg )
{
	// params 0: nbfiles (unused)
	// params 1: paths (unused)
	// params 2: filenames 
	// params 3: is the cache ok ?
	// params 4: fast adaptation ? (unused)
	
	wxArrayString *filenames = (wxArrayString*)params[2];
	bool isCacheOk = *(bool*)params[3];

    // name of model to generate - temporary...
    RecTypModel model( "rec_typ_adapt" );
	if ( isCacheOk || wxFileExists( GetTypCacheFilename() ) )
		model.Open( GetTypCacheFilename() );
	else
		model.New();
    
    // name of adapted model to generate - temporary...
    RecTypModel outModel( "rec_typ_adapt_out" );
    outModel.New();
	params.Add( &outModel );
    
    bool failed = false;
    
    if ( !failed )
        failed = !model.AddFiles( params, dlg );

    if ( !failed )  
        failed = !model.Commit( dlg );
		
	if ( !failed )
		failed = !model.SaveAs( GetTypCacheFilename() );
        
    if ( !failed )  
        failed = !model.Adapt( params, dlg );
    
    if ( !failed )
        failed = !outModel.SaveAs( GetTypFilename() );
		
	if ( !failed )
	{
		if ( isCacheOk )
		{
			WX_APPEND_ARRAY( m_optFiles, *filenames );
		}
		else
		{
			m_optFiles = *filenames;
		}
	}

    return ( !failed );
}
コード例 #12
0
ファイル: ODdc.cpp プロジェクト: Hakansv/ocpn_draw_pi
void __CALL_CONVENTION ODDCcombineCallback(GLdouble coords[3], GLdouble *vertex_data[4], GLfloat weight[4], GLdouble **dataOut)
{
    GLvertex *vertex;

    vertex = new GLvertex();
    gTesselatorVertices.Add(vertex );

    vertex->info.x = coords[0];
    vertex->info.y = coords[1];
    vertex->info.z = coords[2];

    for( int i = 3; i < 7; i++ ) {
        vertex->data[i] = weight[0] * vertex_data[0][i] + weight[1] * vertex_data[1][i];
    }

    *dataOut = &(vertex->data[0]);
}
コード例 #13
0
ファイル: thread.cpp プロジェクト: gitrider/wxsj2
// static functions
// ----------------
wxThread *wxThread::This()
{
    wxMacStCritical critical ;

    ThreadID current ;
    OSErr err ;

    err = MacGetCurrentThread( &current ) ;

    for ( size_t i = 0 ; i < s_threads.Count() ; ++i )
    {
        if ( ( (wxThread*) s_threads[i] )->GetId() == current )
            return (wxThread*) s_threads[i] ;
    }

    wxLogSysError(_("Couldn't get the current thread pointer"));
    return NULL;
}
コード例 #14
0
ファイル: thread.cpp プロジェクト: gitrider/wxsj2
wxThread::~wxThread()
{
    if (g_numberOfThreads>0)
    {
        g_numberOfThreads--;
    }
#ifdef __WXDEBUG__
    else
    {
        wxFAIL_MSG(wxT("More threads deleted than created."));
    }
#endif

    s_threads.Remove( (void*) this ) ;
    if (m_internal != NULL) {
        delete m_internal;
        m_internal = NULL;
    }
}
コード例 #15
0
ファイル: tutorial5.cpp プロジェクト: maxmods/wx.mod
 // Simple table
 void BasicTable(wxArrayString& header,wxArrayPtrVoid& data)
 {
   size_t j;
   // Header
   for (j = 0; j < header.GetCount(); j++)
   {
     Cell(40,7,header[j],wxPDF_BORDER_FRAME);
   }
   Ln();
   // Data
   for (j = 0; j < data.GetCount(); j++)
   {
     wxArrayString* row = (wxArrayString*) data[j];
     size_t k;
     for (k = 0; k < (*row).GetCount(); k++)
     {
       Cell(40,6,(*row)[k],wxPDF_BORDER_FRAME);
     }
     Ln();
   }
 }
コード例 #16
0
ファイル: tutorial5.cpp プロジェクト: maxmods/wx.mod
 // Load data
 void LoadData(const wxString& file, wxArrayPtrVoid& data)
 {
   // Read file lines
   wxFileInputStream f(file);
   wxTextInputStream text( f );
   wxString line;
   while (!f.Eof())
   {
     text >> line;
     if (!f.Eof() && line.Length() > 0)
     {
       wxArrayString* row = new wxArrayString;
       data.Add(row);
       wxStringTokenizer tkz(line, wxS(";"));
       while ( tkz.HasMoreTokens() )
       {
         wxString token = tkz.GetNextToken();
         row->Add(token);
       }
     }
   }
 }
コード例 #17
0
ファイル: main.cpp プロジェクト: caicry/wxVSImport
	virtual void OnbtnImportClick( wxCommandEvent& event ) 
	{
		wxString strInputPath = m_textCtrlVSPrjPath->GetValue();
		TiXmlDocument doc(strInputPath);
		wxFileName fn(strInputPath);
		int i;

		wxString strSavePath =wxString::Format("%s\\%s.import.vcproj", fn.GetPath(), fn.GetName());
		// 获取多个Filter的信息
		DoGetGridInfoString();
		int num = m_GridInfoPtr.GetCount();
		if (num<=0) {
			wxMessageBox("Not Import Path");
			return;
		}

		m_strInfo.empty();
		for (i=0; i<num; i++) {
			// 多个Filter
			m_iTreeLevel = 0;
			CGridInfo *pInfo = (CGridInfo*)m_GridInfoPtr[i];
			pInfo->pElement = newFilter(pInfo->strFilterName);
			dirTrace(pInfo->strFilterPath, pInfo->pElement);
		}
		m_textCtrlInfo->AppendText(m_strInfo);


		if (!doc.LoadFile()) {
			wxMessageBox(wxT("Load Fail"));
			return;
		}


		// 删除重复的多个Filter
		TiXmlElement* root = doc.FirstChildElement("VisualStudioProject"); 
		if (root) {
			TiXmlElement *files  = root->FirstChildElement("Files");
			if (files) {
				TiXmlElement* filter = files->FirstChildElement("Filter");
				while(filter) {
					wxString str = filter->Attribute("Name");

					for (i=0; i<num; i++) {
						CGridInfo *pInfo = (CGridInfo*)m_GridInfoPtr[i];
						if (str == pInfo->strFilterName) {
							files->RemoveChild(filter);
							break;
						}
					}
					filter = filter->NextSiblingElement("Filter");
				}
				for (i=0; i<num; i++) {
					CGridInfo *pInfo = (CGridInfo*)m_GridInfoPtr[i];
					files->LinkEndChild(pInfo->pElement);
				}
			}
		}

		doc.SaveFile(strSavePath);

		m_textCtrlInfo->AppendText("\n ** Output Project Path:  " + strSavePath);

		/*
		<Files>
			<Filter
			Name="源文件"
			Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
			>
			<File
			RelativePath=".\main.cpp"
			>
			</File>
			</Filter>
			<Filter
			Name="头文件"
			Filter="h;hpp;hxx;hm;inl;inc;xsd"
			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
			>
			</Filter>
			<Filter
			Name="资源文件"
			Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
			UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
			>
			</Filter>
			</Files>*/
	}
コード例 #18
0
bool wxSpeedButton::Create( wxWindow       *inParent,           // parent window
                            wxWindowID      inID,               // id of this button
                            const wxString &inLabel,            // button text
                            const wxBitmap &inGlyph,            // bitmaps displayed on button
                            int             inGlyphCount,       // number of images in inGlyph
                            int             inMargin,           // area around image and tex
                            int             inGroupIndex,       // ident of a group of buttons
                            bool            inAllowAllUp,       // allow all buttons up
                            const wxPoint  &inPos,              // button position
                            const wxSize   &inSize,             // button size
                            long            inStyle,            // border styles
                            const wxValidator &inVal,           // validator
                            const wxString &inName) {           // name of button

int         n;
wxString    name;
wxPoint     pos;
wxSize      size;
wxString    s;

// make sure we can load images

    wxInitAllImageHandlers();

// one more button

    sbgCount += 1;

// make a default name

    name = inName;
    name.Trim(true);
    name.Trim(false);
    if (name.Len() == 0) name.Printf(_T("SpeedButton-%d"), sbgCount);

// the position

    pos = inPos;
    if (pos.x < 0) pos.x = 0;
    if (pos.y < 0) pos.y = 0;

// the size - default size is 72 x 24

    size = inSize;
    size.SetDefaults(wxSize(72, 24));

// fix the alignment -- default to BU_LEFT
// clear border styles and make sure we clip children

    n = inStyle;
    n = n & (~ wxBORDER_MASK);
    n = n | wxBORDER_NONE;
    n = n | wxCLIP_CHILDREN;

    if (((n & wxBU_LEFT)   == 0) &&
        ((n & wxBU_TOP)    == 0) &&
        ((n & wxBU_RIGHT)  == 0) &&
        ((n & wxBU_BOTTOM) == 0))
            n = n | wxBU_LEFT;

// make the control, make sure we clip children

    if (! wxControl::Create(inParent, inID, pos, size, n, inVal, name)) return false;

// basic stuff for any control

    wxControl::SetLabel(inLabel);
    wxControl::SetBackgroundColour(inParent->GetBackgroundColour());
    wxControl::SetForegroundColour(inParent->GetForegroundColour());
    wxControl::SetFont(inParent->GetFont());

// extract bitmaps

    SplitGlyphs(inGlyph, inGlyphCount);

// the blank space around images and text

    mMargin = inMargin;
    if (mMargin < 0) mMargin = 0;

// ID for a group of buttons

    mGroupIndex = inGroupIndex;
    mAllowAllUp = inAllowAllUp;

// no button down yet

    mMouseDown     = false;
    mMouseOver     = false;
    mButtonDown    = false;
    mButtonFocused = false;

// the is a small chance that CalcLayout could be called recursively

    mCalcBusy = false;

// keep track of our parent, and the top-most parent

    mParent = GetParent();
    mTopParent = mParent;
    while ((mTopParent != NULL) && (! mTopParent->IsKindOf(CLASSINFO(wxTopLevelWindow))))
        mTopParent = mTopParent->GetParent();

// no user data yet

    mUserData = 0;

// add this button to the master list

    sbgArray.Add((void *) this);

// draw it

    Refresh(false);

// done

    return true;
}