Пример #1
0
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
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);
    }
  }
}
Пример #3
0
wxThread::wxThread(wxThreadKind kind)
{
    g_numberOfThreads++;
    m_internal = new wxThreadInternal();

    m_isDetached = kind == wxTHREAD_DETACHED;
    s_threads.Add( (void*) this ) ;
}
Пример #4
0
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    
}
Пример #5
0
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 );
}
Пример #6
0
// -------------------------------------------------------------------------------- //
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 );
            }
        }
    }
}
Пример #7
0
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]);
}
Пример #8
0
	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);
		}
	}
Пример #9
0
 // 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);
       }
     }
   }
 }
Пример #10
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;
}