예제 #1
0
// -----------------------------------------------------------------------------
// CGuiEngineAppView::Draw()
// Draws the display
// -----------------------------------------------------------------------------
//
void CGuiEngineAppView::Draw( const TRect& /*aRect*/ ) const
    {

    CWindowGc& graphicsContext = SystemGc();

    // Clear the application view
    graphicsContext.Clear();

	// Gets the control's extent
	TRect rect( Rect() );
	graphicsContext.DrawRect( rect );

    // Draw the 'cursor' crosshair, size 10 pixels by 10 pixels
    graphicsContext.SetPenSize( TSize( 1,1 ) );

    //graphicsContext.SetPenColor( RgbBlack );
    graphicsContext.DrawLine ( TPoint( iPosition.iX - 10, iPosition.iY ),
                               TPoint( iPosition.iX + 10, iPosition.iY ) );

    graphicsContext.DrawLine ( TPoint( iPosition.iX, iPosition.iY - 10 ),
                               TPoint( iPosition.iX, iPosition.iY + 10 ) );


    // Draw all the current shapes
    TShape* shape = iDocument->Model()->GetNextShape();
    while ( shape )
    {
        shape->Draw( graphicsContext );
        shape = iDocument->Model()->GetNextShape();
        }
    }
예제 #2
0
// -----------------------------------------------------------------------------
// CShapeListManager::InternalizeL()
// Restore the instance from the specified stream
// -----------------------------------------------------------------------------
//
EXPORT_C void CShapeListManager::InternalizeL( RReadStream& aStream )
    {

    TInt count = aStream.ReadInt16L();
    for ( TInt index = 0; index < count; ++index )
        {

        TShape* shape = NULL;
        switch ( TShape::ReadShapeTypeL( aStream ) )
            {
            case KRectangle:
                shape = new ( ELeave ) TRectangle();
                break;

            case KCircle:
                shape = new ( ELeave ) TCircle();
                break;

            default:
                User::Leave( KErrCorrupt );
            }


        CleanupStack::PushL( shape );
        shape->InternalizeL( aStream );
        User::LeaveIfError( iShapeList.Append( shape ) );

        CleanupStack::Pop( shape ); //  Now owned by iShapeList
        }
    }
예제 #3
0
/*!
 * Returns true if the \a m_nodetypeList contains the type of the element defined with \a sourceRow and \a sourceParent
 */
bool NodesFilterModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
{

	SceneModel* sceneModel = dynamic_cast< SceneModel* > ( sourceModel() );
	QModelIndex index = sceneModel->index(sourceRow, 0, sourceParent);

	InstanceNode* nodeInstance = sceneModel->NodeFromIndex( index );
	if( !nodeInstance )		return false;

	SoNode* node = nodeInstance->GetNode();
	if( !node )		return false;


	if( node->getTypeId().isDerivedFrom( TSeparatorKit::getClassTypeId() ) )	return ( true );
	if( node->getTypeId().isDerivedFrom( TShapeKit::getClassTypeId() ) )
	{
		if( m_shapeTypeList.count() < 1 )	return ( true );

		TShapeKit* shapeKit = static_cast< TShapeKit* >( node );
		if(!shapeKit)	return ( false );
		TShape* shape = static_cast< TShape* >( shapeKit->getPart( "shape", false ) );

		if( shape  &&  m_shapeTypeList.contains( shape->getTypeId().getName().getString() ) )
			return ( true );
	}


	return ( false );
}
예제 #4
0
void QComponent::draw()
{
	TShape shp (r, shpUpBox, 3, EGA_DARKGRAY);
	shp.Draw ();
	int tx, ty;
	tx = r.a.x+(r.b.x-r.a.x)/2;
	ty = r.a.y+(r.b.y-r.a.y)/2;
	gui_outtextxy( tx, ty, name, 1, EGA_BLUE, -1);
	QPin *p;
	for (p=pins; p; p=p->next)
	   p->draw();
}
예제 #5
0
파일: r2iv_1.C 프로젝트: star-bnl/star-soft
//_______________________________________________________________________________________________________
void TR2iv::Draw(char *filename) {

   Open(filename);	
   Header();
   fprintf(TIVFile::File, "Separator {\n"); 	

   TVolumeView *vv = Geom;


   for(int i = 0; i < 10000; i++) {

      TIVShape *ivs = 0;
      TVolume *v = vv->GetNode();
      TShape  *s = v->GetShape();

//      if(v->IsMarked() && !v->GetVisibility()) {
      if(!v->GetVisibility()) {

         // cout << "sdepth=" << Sdepth << " : " <<  GeomIter->GetDepth() << "   " <<  i << "  " << s->ClassName() << "   " << s->GetName() << endl;
         if(GeomIter->GetDepth() >= Sdepth)
            if( 
               !strcmp(s->IsA()->GetName(), "TTUBE") ||
               //		    !strcmp(s->IsA()->GetName(), "TTUBS") || 
               !strcmp(s->IsA()->GetName(), "TCONE") ||
               !strcmp(s->IsA()->GetName(), "TPCON") ||
               !strcmp(s->IsA()->GetName(), "TBRIK") ||
               !strcmp(s->IsA()->GetName(), "TTRD1") ||
               !strcmp(s->IsA()->GetName(), "TCTUB")
               ) { 

                  // cout << "\t\t" << GeomIter->GetDepth() << "   " <<  i << "  " << s->IsA()->GetName() << "   " << s->GetName() << endl;
                  if(!strcmp(s->IsA()->GetName(), "TCONE")) ivs = new TIVCone(vv);
                  if(!strcmp(s->IsA()->GetName(), "TTUBE")) ivs = new TIVTube(vv);
                  if(!strcmp(s->IsA()->GetName(), "TTUBS")) ivs = new TIVTubs(vv);
                  if(!strcmp(s->IsA()->GetName(), "TPCON")) ivs = new TIVPcon(vv);
                  if(!strcmp(s->IsA()->GetName(), "TBRIK")) ivs = new TIVBrik(vv);
                  if(!strcmp(s->IsA()->GetName(), "TTRD1")) ivs = new TIVTrd1(vv);
                  if(!strcmp(s->IsA()->GetName(), "TCTUB")) ivs = new TIVCtub(vv);
                  fprintf(TIVFile::File, "\tSeparator {\n");

                  ivs->Draw();

                  fprintf(TIVFile::File, "\t}\n");
               }

      }

      vv = (TVolumeView *)GeomIter->Next();
      if(!vv) break;	
      if(ivs) delete ivs;		    
   }
   fprintf(TIVFile::File, "}\n");	
   Close();

}
예제 #6
0
/*
 * Returns the type of the surface
 */
QString FluxAnalysis::GetSurfaceType( QString nodeURL )
{
	QModelIndex nodeIndex = m_pCurrentSceneModel->IndexFromNodeUrl( nodeURL );
	if( !nodeIndex.isValid()  )		return QLatin1String( "" );

	InstanceNode* instanceNode = m_pCurrentSceneModel->NodeFromIndex( nodeIndex );
	if( !instanceNode || instanceNode == 0 )	return QLatin1String( "" );

	TShapeKit* shapeKit = static_cast< TShapeKit* > ( instanceNode->GetNode() );
	if( !shapeKit || shapeKit == 0 )	return QLatin1String( "" );

	TShape* shape = static_cast< TShape* >( shapeKit->getPart( "shape", false ) );
	if( !shape || shape == 0 )	return QLatin1String( "" );

	return ( shape->getTypeId().getName().getString() );
}
예제 #7
0
파일: rpn.cpp 프로젝트: aliushn/Tengine
bool RPN::InferShape(const std::vector<TEngine::TShape>& ishape, 
                               std::vector<TEngine::TShape>& oshape)
{
    generate_anchors(param_.basesize,
                     param_.ratios,
                     param_.anchor_scales,
                     param_.anchors_);
    const TShape& input=ishape[0];
    const std::vector<int>& feat_dim=input.GetDim();
 

    TShape shape;
    std::vector<int> dim={feat_dim[0],param_.post_nms_topn+1,4,1};
    shape.SetDim(dim);
    shape.SetDataLayout("NCHW");
    oshape[0]=shape;
    return true;    

}
예제 #8
0
/*
 * Flux Analysis for flat rectangle surfaces.
 */
void FluxAnalysis::FluxAnalysisFlatRectangle( InstanceNode* node )
{
	if( !node )	return;

	TShapeKit* surfaceNode = static_cast< TShapeKit* > ( node->GetNode() );
	if( !surfaceNode )	return;

	TShape* shape = static_cast< TShape* >( surfaceNode->getPart( "shape", false ) );
	if( !shape || shape == 0 )	return;

	trt::TONATIUH_REAL* widthField = static_cast< trt::TONATIUH_REAL* > ( shape->getField( "width" ) );
	double surfaceWidth = widthField->getValue();

	trt::TONATIUH_REAL* heightField = static_cast< trt::TONATIUH_REAL* > ( shape->getField( "height" ) );
	double surfaceHeight= heightField->getValue();

	int widthDivisionsError = m_widthDivisions-1;
	int heightDivisionsError = m_heightDivisions-1;

	int** photonCountsError = new int*[heightDivisionsError];
	for(int i = 0; i < heightDivisionsError; ++i)
	{
		photonCountsError[i] = new int[widthDivisionsError];
		for( int w = 0; w < widthDivisionsError; w++ )
			photonCountsError[i][w] = 0;
	}

	int activeSideID = 1;
	if( m_surfaceSide == "BACK" )
		activeSideID = 0;

	Transform worldToObject = node->GetIntersectionTransform();

	m_xmin = -0.5 * surfaceHeight;
	m_ymin = -0.5 * surfaceWidth;
	m_xmax = 0.5 * surfaceHeight;
	m_ymax = 0.5 * surfaceWidth;

	std::vector< Photon* > photonList = m_pPhotonMap->GetAllPhotons();
	int totalPhotons = 0;
	for( unsigned int p = 0; p < photonList.size(); p++ )
	{
		Photon* photon = photonList[p];
		if( photon->side == activeSideID )
		{
			totalPhotons++;
			Point3D photonLocalCoord = worldToObject( photon->pos );
			int xbin = floor( ( photonLocalCoord.x - m_xmin )/( m_xmax - m_xmin ) * m_widthDivisions ) ;
			int ybin = floor( ( photonLocalCoord.z - m_ymin )/( m_ymax - m_ymin ) * m_heightDivisions );

			m_photonCounts[ybin][xbin] += 1;
			if( m_maximumPhotons < m_photonCounts[ybin][xbin] )
			{
				m_maximumPhotons = m_photonCounts[ybin][xbin];
				m_maximumPhotonsXCoord = xbin;
				m_maximumPhotonsYCoord = ybin;
			}

			int xbinE = floor( ( photonLocalCoord.x - m_xmin )/( m_xmax-m_xmin ) * widthDivisionsError ) ;
			int ybinE = floor( ( photonLocalCoord.z - m_ymin )/( m_ymax-m_ymin ) * heightDivisionsError );
			photonCountsError[ybinE][xbinE] += 1;
			if( m_maximumPhotonsError < photonCountsError[ybinE][xbinE] )
			{
				m_maximumPhotonsError = photonCountsError[ybinE][xbinE];
			}
		}
	}

	m_totalPower = totalPhotons * m_wPhoton;

	if( photonCountsError )
	{
		for( int h = 0; h < heightDivisionsError; h++ )
		{
			delete[] photonCountsError[h];
		}

		delete[] photonCountsError;
	}
}
예제 #9
0
/*
 * Flux Analysis for cylinder surfaces.
 */
void FluxAnalysis::FluxAnalysisCylinder( InstanceNode* node )
{
	if( !node )	return;
	TShapeKit* surfaceNode = static_cast< TShapeKit* > ( node->GetNode() );
	if( !surfaceNode )	return;

	TShape* shape = static_cast< TShape* >( surfaceNode->getPart( "shape", false ) );
	if( !shape || shape == 0 )	return;

	trt::TONATIUH_REAL* radiusField = static_cast< trt::TONATIUH_REAL* > ( shape->getField( "radius" ) );
	double radius = radiusField->getValue();

	trt::TONATIUH_REAL* lengthField = static_cast< trt::TONATIUH_REAL* > ( shape->getField( "length" ) );
	double length = lengthField->getValue();

	trt::TONATIUH_REAL* phiMaxField = static_cast< trt::TONATIUH_REAL* > ( shape->getField( "phiMax" ) );
	double phiMax = phiMaxField->getValue();

	int widthDivisionsError = m_widthDivisions-1;
	int heightDivisionsError = m_heightDivisions-1;

	int** photonCountsError = new int*[heightDivisionsError];
	for(int i = 0; i < heightDivisionsError; ++i)
	{
		photonCountsError[i] = new int[widthDivisionsError];
		for( int w = 0; w < widthDivisionsError; w++ )
			photonCountsError[i][w] = 0;
	}

	int activeSideID = 1;
	if( m_surfaceSide == "INSIDE" )
		activeSideID = 0;

	Transform worldToObject = node->GetIntersectionTransform();

	m_xmin = 0.0;
	m_ymin = 0.0;
	m_xmax = phiMax  * radius;
	m_ymax = length;

	std::vector< Photon* > photonList = m_pPhotonMap->GetAllPhotons();
	int totalPhotons = 0;
	for( unsigned int p = 0; p < photonList.size(); p++ )
	{
		Photon* photon = photonList[p];
		if( photon->side == activeSideID )
		{
			totalPhotons++;
			Point3D photonLocalCoord = worldToObject( photon->pos );
			double phi  = atan2( photonLocalCoord.y, photonLocalCoord.x );
			if( phi < 0.0 ) phi += 2* gc::Pi;
			double arcLength = phi * radius;

			int xbin = floor( ( arcLength - m_xmin )/( m_xmax - m_xmin ) * m_widthDivisions ) ;
			int ybin = floor( ( photonLocalCoord.z - m_ymin )/( m_ymax - m_ymin ) * m_heightDivisions );
			m_photonCounts[ybin][xbin] += 1;
			if( m_maximumPhotons < m_photonCounts[ybin][xbin] )
			{
				m_maximumPhotons = m_photonCounts[ybin][xbin];
				m_maximumPhotonsXCoord = xbin;
				m_maximumPhotonsYCoord = ybin;
			}

			int xbinE = floor( ( arcLength - m_xmin )/( m_xmax - m_xmin ) * widthDivisionsError ) ;
			int ybinE = floor( ( photonLocalCoord.z - m_ymin )/( m_ymax - m_ymin ) * heightDivisionsError );
			photonCountsError[ybinE][xbinE] += 1;
			if( m_maximumPhotonsError < photonCountsError[ybinE][xbinE] )
			{
				m_maximumPhotonsError = photonCountsError[ybinE][xbinE];
			}
		}
	}

	m_totalPower = totalPhotons * m_wPhoton;

	if( photonCountsError )
	{
		for( int h = 0; h < heightDivisionsError; h++ )
		{
			delete[] photonCountsError[h];
		}

		delete[] photonCountsError;
	}
}