Esempio n. 1
0
void InexorCefMouseManager::InitializeContext()
{
    CreateFunction("show", this);
    CreateFunction("hide", this);
    CreateFunction("setTexture", this);
    CreateVariable("visible", true);
    CreateVariable("x", true);
    CreateVariable("y", true);
}
Esempio n. 2
0
void BindStandardLibrary()
{
    VALUE duckStdLib = LinkNamespace("duck");

    VALUE print = CreateFunction(DuckPrint);
    AddParameter(print, "output");
    
    LinkFunction(duckStdLib, "print", print);
    LinkFunction(duckStdLib, "println", print);

    VALUE prompt = CreateFunction(DuckPrompt);
    LinkFunction(duckStdLib, "prompt", prompt);
}
Esempio n. 3
0
void CPhylogenView::OnLButtonDblClk(UINT nFlags, CPoint point)
{
    CScrollView::OnLButtonDblClk(nFlags, point);

    // TODO: Add your message handler code here and/or call default

    CPhyloGenBase * pPGB;

    int Flag = 0;

    POSITION Pos;
    CGenedocDoc* pDoc = GetDocument();
    ASSERT_VALID(pDoc);

    if ( pDoc->m_pPGBase != NULL ) {
        CPhyloNode *pPNDoc = pDoc->m_pPGBase;
        Pos = pPNDoc->m_PhyloList.GetHeadPosition();
        while ( Pos != NULL ) {
            pPGB = (CPhyloGenBase *)pPNDoc->m_PhyloList.GetNext(Pos);
            if ( pPGB->m_FirstSelection == 1 ) {
                Flag++;
            }
        }

        if ( Flag == 1) {
            DeleteFunction();
        } else if ( Flag == 2 ) {
            CreateFunction();
        } else {
            OnUpdate( NULL, 0, NULL );
        }
    }
}
Esempio n. 4
0
    inline void ESolver::RegisterType(const ESFixedTypeBase* Type)
    {
        // Create an equality operator
        vector<const ESFixedTypeBase*> ArgTypes;
        ArgTypes.push_back(Type);
        ArgTypes.push_back(Type);
        CreateFunction("=", ArgTypes, BoolType, new EQSymbolicFunctor(),
                       new EQConcreteFunctor(), true, true);

        // Create an ITE operator
        ArgTypes.clear();
        ArgTypes.push_back(BoolType);
        ArgTypes.push_back(Type);
        ArgTypes.push_back(Type);
        CreateFunction("ite", ArgTypes, Type, new ITESymbolicFunctor(), 
                       new ITEConcreteFunctor(), false, true);
    }
Esempio n. 5
0
void BindStringLibrary()
{
    VALUE stringLib = LinkNamespace("string");
    
    VALUE split = CreateFunction(StringSplit);
    AddParameter(split, "string");
    LinkFunction(stringLib, "split", split);
}
Esempio n. 6
0
TEST(StdDuck, print_value_function)
{
    CreateEnvironment();
    testing::internal::CaptureStdout();

    VALUE func = CreateFunction(TestStdDuck::DummyFunc);
    AddParameter(func, "arg0");

    PrintValue(func);
    ASSERT_STREQ("function(arg0)", testing::internal::GetCapturedStdout().c_str());

    FreeEnvironment();
}
Esempio n. 7
0
// Mesh the area into nodes and elements or return error message if fails
// assumes edges already oriented correctly
const char *Area::MeshElements(void)
{
	// exactly 2 paths will be for an interface
	if(numPaths==2)
		return MeshInterface();
		
	// Must be 4-sided area. In future should support more
	if(numPaths!=4)
		return "Code can only mesh quadrilateral areas (4 paths) or interfaces (2 paths).";
	
	// cannot be interface elements
	if(theElems->InterfaceElements())
		return "Areas cannot be meshed into interface elements.";
	
	// must be connected
	if(edges[numPaths-1]->LastKeypoint()!=edges[0]->FirstKeypoint())
		return "Area does not define enclosed area.";
	
	// is element provided
	if(theElems->CurrentElemID()<0)
		return "No element type defined for area.";
	
	// Check intervals
	if(!CheckIntervals())
		return "Number of intervals on sides of the area are not valid";
	
	// Check path usage
	if(!PathsAvailable())
		return "Paths cannot be meshed into more than 2 areas";
	
	// Check ccw
	if(SignedArea()<0.)
		return "The paths must circumnavigate the area in a counter-clockwise direction";
	
	// create function if being used
	if(angleExpr!=NULL)
	{	if(!CreateFunction(angleExpr))
			return "The expression for material angle is not a valid function";
	}
	
	// mesh the error
	return MeshArea();
}
Esempio n. 8
0
EvalAtom::EvalAtom(std::wstring& src, 
						 EvalAtomType atomType)
{
	AtomType = atomType;
	Value    = 0.0;
	Index    = -1;
	Function = NULL;
	Operator = NULL;

	switch (atomType)
	{
		case EvalAtomType::Operator:
			CreateOperator(src);
			break;

		case EvalAtomType::Function:
			CreateFunction(src);
			break;

		case EvalAtomType::Variable:
			/**
			 * If identifier of variable will be found in 
			 * internal constants table we will store this
			 * constant, not variable. 
			 */
			if (EvalTable::IsConstExists(src))
			{
				AtomType = EvalAtomType::Constant;
				CreateNamedConstant(src);
			}
			else
			{ CreateVariable(src); }
			break;

		case EvalAtomType::Constant:
			CreateConstant(src);
			break;
	}
}
Esempio n. 9
0
/* bind the duck standard library */
void BindStandardLibrary()
{
    VALUE duckStdLib = LinkNamespace("duck");

    VALUE print = CreateFunction(DuckPrint);
    AddParameter(print, "output");
    LinkFunction(duckStdLib, "print", print);

    VALUE println = CreateFunction(DuckPrintLn);
    AddParameter(println, "output");
    LinkFunction(duckStdLib, "println", println);

    VALUE prompt = CreateFunction(DuckPrompt);
    AddParameter(prompt, "message");
    LinkFunction(duckStdLib, "prompt", prompt);

    LinkConstString(duckStdLib, "newline", "\n");

    VALUE root;
    root.type = VAL_REFERENCE;
    root.data.reference = gGlobalContext;

    VALUE int_c = CreateFunction(DuckInt);
    AddParameter(int_c, "value");
    LinkFunction(root, "int", int_c);

    VALUE float_c = CreateFunction(DuckFloat);
    AddParameter(float_c, "value");
    LinkFunction(root, "float", float_c);

    VALUE length = CreateFunction(DuckLength);
    AddParameter(length, "array");
    LinkFunction(root, "len", length);

    VALUE type = CreateFunction(DuckType);
    AddParameter(type, "object");
    LinkFunction(root, "Type", type);

    VALUE evalFunc = CreateFunction(DuckEval);
    AddParameter(evalFunc, "source");
    LinkFunction(root, "eval", evalFunc);

    VALUE parsesFunc = CreateFunction(DuckParses);
    AddParameter(parsesFunc, "source");
    LinkFunction(duckStdLib, "parses", parsesFunc);

    VALUE duckQuit = CreateFunction(DuckQuit);
    LinkFunction(root, "quit", duckQuit);
    BindStringLibrary();

    VALUE time = CreateFunction(DuckTime);
    LinkFunction(root, "time", time);

#ifdef WIN32
    start_t = GetTickCount();
#endif
}
Esempio n. 10
0
void FbDatabase::InitFunctions()
{
	CreateFunction(wxT("LTTR"), 1, m_letter_func);
	CreateFunction(wxT("LOW"), 1, m_lower_func);
}
Esempio n. 11
0
//-----------------------------------------------------------
// Subroutine to translate BMP file into material point
//-----------------------------------------------------------
void MPMReadHandler::TranslateBMPFiles(void)
{
	unsigned char **rows,**angleRows;
	BMPInfoHeader info,angleInfo;
	bool setAngles=FALSE;
	int numRotations=strlen(rotationAxes);
	
	// read image file
	char *bmpFullPath=archiver->ExpandOutputPath(bmpFileName);
	ReadBMPFile(bmpFullPath,info,&rows);
	delete [] bmpFullPath;
	
	// angle file name (overrides other angle settings)
	if(bmpAngleFileName[0]>0)
	{	setAngles=TRUE;
		char *bmpFullAnglePath=archiver->ExpandOutputPath(bmpAngleFileName);
		ReadBMPFile(bmpFullAnglePath,angleInfo,&angleRows);
		if(info.height!=angleInfo.height || info.width!=angleInfo.width)
			throw SAXException(BMPError("The image file and angle file sizes do not match.",bmpFileName));
		delete [] bmpFullAnglePath;
	}
	else if(numRotations>0)
	{	int i;
		for(i=0;i<numRotations;i++)
		{	char *expr=new char[strlen(angleExpr[i])+1];
			strcpy(expr,angleExpr[i]);
			if(!CreateFunction(expr,i+1))
				throw SAXException("Invalid angle expression was provided in <RotateX(YZ)> command.");
			delete [] expr;
		}
	}
	
	// bheight and bwidth provided in bmp file
	// <-1.e8 means not provided
	// negative means provided mm per pixel
	// positive is a specified size
	double xpw=-1.,ypw=-1.;
	if(bwidth<-1.e8 && bheight<-1.e8)
	{	if(!info.knowsCellSize)
			throw SAXException(BMPError("<BMP> must specify width and/or height as size or pixels per mm.",bmpFileName));
		bwidth = info.width*info.xcell;
		bheight = info.height*info.ycell;
		xpw = info.xcell;
		ypw = info.ycell;
	}
	else
	{	// provided mm per pixel
		if(bheight<0. && bheight>-1.e8)
		{	ypw = -bheight;
			bheight = ypw*(double)info.height;
		}
		if(bwidth<0. && bwidth>-1.e8)
		{	xpw = -bwidth;
			bwidth = xpw*(double)info.width;
		}
	}
	
	// total dimensions (if only one is known, find the other, never have both unknown)
	if(bheight<0) bheight=bwidth*(double)info.height/(double)info.width;
	if(bwidth<0) bwidth=bheight*(double)info.width/(double)info.height;
	
	// final mm per pixel (if needed)
	if(xpw<0.) xpw=bwidth/(double)info.width;
	if(ypw<0.) ypw=bheight/(double)info.height;
	
	// variables for scanning BMP file
	int matID;
	MPMBase *newMpt;
	int ii,k;
	Vector mpos[MaxElParticles];
	int ptFlag;
	BMPLevel *nextLevel;
	double deltax,deltay,deltaz,semiscale;
	double rmin,rmax,wtr1,wtr2,rweight;
	double cmin,cmax,wtc1,wtc2,weight;
	int r1,r2,c1,c2;
	BMPLevel *maxLevel;
	int row,col;
	ElementBase *elem;
	
	// Length/semiscale is half particle with
	//	(semiscale=4 for 2D w 4 pts per element or 3D with 8 pts per element,
	//		or 2 if 1 particle in the element)
	if(fmobj->IsThreeD())
		semiscale=2.*pow((double)fmobj->ptsPerElement,1./3.);
	else
		semiscale=2.*sqrt((double)fmobj->ptsPerElement);
    
    /* Parallelizing the following loop will speed up check meshes on Mac
        1. Will need copy of levels for each block (or pass copy of weight to BMPLevel methods)
            see BMPLevel methods: ClearWeight(),Material(double,double), MaximumWeight(double)
        2. mpCtrl->AddMaterialPoint() will need critical block
        3. FunctionValue() when setting angles uses globals they are problem for parallel
    */
	
	// scan mesh and assign material points or angles
    try
    {   for(ii=1;ii<=nelems;ii++)
        {	// skip if image not in extent of element box
            elem=theElements[ii-1];
            if(!elem->IntersectsBox(xorig,yorig,bwidth,bheight,zslice))
                continue;
            
            // load point coordinates
            elem->MPMPoints(fmobj->ptsPerElement,mpos);
        
            // half the extent of the volume of a particle
            deltax=(elem->GetDeltaX())/semiscale;
            deltay=(elem->GetDeltaY())/semiscale;
            if(fmobj->IsThreeD())
                deltaz=elem->GetDeltaZ()/semiscale;
            else
                deltaz=1.;
            if(deltaz<0.) deltaz=1.;
            
            for(k=0;k<fmobj->ptsPerElement;k++)
            {	ptFlag=1<<k;
            
                // skip if already filled
                if(elem->filled&ptFlag) continue;
                
                // if point in the view area, then check it
                if((mpos[k].x>=xorig && mpos[k].x<xorig+bwidth)
                        && (mpos[k].y>=yorig && mpos[k].y<yorig+bheight)
                             && (mpos[k].z>=zslice-deltaz && mpos[k].z<zslice+deltaz))
                {	// find range of rows and cols for pixels over this material point
                    if(yflipped)
                    {   rmin=(yorig+bheight-mpos[k].y-deltay)/ypw;
                        rmax=(yorig+bheight-mpos[k].y-deltay)/ypw;
                    }
                    else
                    {   rmin=(mpos[k].y-deltay-yorig)/ypw;
                        rmax=(mpos[k].y+deltay-yorig)/ypw;
                    }
                    r1=BMPIndex(rmin,info.height);
                    r2=BMPIndex(rmax,info.height);
                    if(r2==r1)
                    {	wtr1=wtr2=1.;
                    }
                    else
                    {	// fractional weight for first and last row in case not all within the extent
                        wtr1=(double)(r1+1)-rmin;
                        wtr2=rmax-(double)r2;
                    }
                    cmin=(mpos[k].x-deltax-xorig)/xpw;
                    cmax=(mpos[k].x+deltax-xorig)/xpw;
                    c1=BMPIndex(cmin,info.width);
                    c2=BMPIndex(cmax,info.width);
                    if(c2==c1)
                    {	wtc1=wtc2=1.;
                    }
                    else
                    {	// fractional weight for first and last col in case not all within the extent
                        wtc1=(double)(c1+1)-cmin;
                        wtc2=cmax-(double)c2;
                    }
                    
                    // find material ID or none (a hole)
                    // clear material weights
                    nextLevel=firstLevel;
                    while(nextLevel!=NULL) nextLevel=nextLevel->ClearWeight();

                    // add weights
                    for(row=r1;row<=r2;row++)
                    {	if(row==r1)
                            rweight=wtr1;
                        else if(row==r2)
                            rweight=wtr2;
                        else
                            rweight=1.;
                        for(col=c1;col<=c2;col++)
                        {	if(col==c1)
                                weight=rweight*wtc1;
                            else if(col==c2)
                                weight=rweight*wtc2;
                            else
                                weight=rweight;
                            
                            // find material at this level
                            // (note: last level with matID=0 catches empty space)
                            nextLevel=firstLevel;
                            while(nextLevel!=NULL)
                            {	matID=nextLevel->Material(rows[row][col],weight);
                                if(matID>=0) break;
                                nextLevel=(BMPLevel *)nextLevel->GetNextObject();
                            }
                        }
                    }
                    
                    // find maximum weight (matID=0 means max is empty space)
                    weight=0.;
                    maxLevel=NULL;
                    nextLevel=firstLevel;
                    while(nextLevel!=NULL) nextLevel=nextLevel->MaximumWeight(weight,&maxLevel);
                    if(maxLevel!=NULL)
                    {	matID=maxLevel->mat;
                        nextLevel=maxLevel;
                    }
                    else
                        matID=-1;

                    // create a material point if one at this spot using matID and nextLevel
                    // Note that empty spaced is not marked as filled which allows superposition of
                    // images with different materials. If want to forcefully create a hole that
                    // cannot be filled by subsequent image, will need to define a new material
                    // type that can have matID for a hole. It will not create a point, but will mark
                    // the location as filled
                    if(matID>0)
                    {	if(fmobj->IsThreeD())
                            newMpt=new MatPoint3D(ii,matID,nextLevel->angle);
                        else if(fmobj->IsAxisymmetric())
                            newMpt=new MatPointAS(ii,matID,nextLevel->angle,mpos[k].x);
                        else
                            newMpt=new MatPoint2D(ii,matID,nextLevel->angle,nextLevel->thickness);
                        newMpt->SetPosition(&mpos[k]);
                        newMpt->SetOrigin(&mpos[k]);
                        newMpt->SetVelocity(&nextLevel->vel);
                        mpCtrl->AddMaterialPoint(newMpt,nextLevel->concentration,nextLevel->temperature);
                        
                        // is there an angle image?
                        if(setAngles)
                        {	// weight average of scanned pixels
                            double totalWeight=0.;
                            double totalIntensity=0.;
                            for(row=r1;row<=r2;row++)
                            {	if(row==r1)
                                    rweight=wtr1;
                                else if(row==r2)
                                    rweight=wtr2;
                                else
                                    rweight=1.;
                                for(col=c1;col<=c2;col++)
                                {	if(col==c1)
                                        weight=rweight*wtc1;
                                    else if(col==c2)
                                        weight=rweight*wtc2;
                                    else
                                        weight=rweight;
                                    
                                    totalIntensity+=weight*angleRows[row][col];
                                    totalWeight+=weight;
                                }
                            }
                            totalIntensity/=totalWeight;
                            double matAngle=minAngle+(totalIntensity-minIntensity)*angleScale;
                            newMpt->SetAnglez0InDegrees(matAngle);
                        }
                        else
                        {	// If had Rotate commands then use them
                            SetMptAnglesFromFunctions(numRotations,&mpos[k],newMpt);
                        }
                        elem->filled|=ptFlag;
                    }
                }
            }
        }
    }
    catch(const char *msg)
    {   throw SAXException(msg);
    }
	
	// clean up
	for(row=0;row<info.height;row++)
	{	delete [] rows[row];
		if(setAngles) delete [] angleRows[row];
	}
	delete [] rows;
	if(setAngles) delete [] angleRows;
	
	// angles if allocated
	for(ii=0;ii<numRotations;ii++)
	{	delete [] angleExpr[ii];
	}
	DeleteFunction(-1);
		
}
Esempio n. 12
0
void BindMathLibrary()
{
    VALUE math_lib = LinkNamespace("Math");

    //Trig and inverse trig functions.
    VALUE dcos = CreateFunction(MathCos);
    AddParameter(dcos, "angle");
    LinkFunction(math_lib, "cos", dcos);

    VALUE dsin = CreateFunction(MathSin);
    AddParameter(dsin, "angle");
    LinkFunction(math_lib, "sin", dsin);

    VALUE dtan = CreateFunction(MathTan);
    AddParameter(dtan, "angle");
    LinkFunction(math_lib, "tan", dtan);

    VALUE dasin = CreateFunction(MathAsin);
    AddParameter(dasin, "num");
    LinkFunction(math_lib, "asin", dasin);

    VALUE dacos = CreateFunction(MathAcos);
    AddParameter(dacos, "num");
    LinkFunction(math_lib, "acos", dacos);

    VALUE datan = CreateFunction(MathAtan);
    AddParameter(datan, "num");
    LinkFunction(math_lib, "atan", datan);


    LinkConstFloatp(math_lib, "pi", 3.14159);

    //Exponentials and logs
    VALUE dexp = CreateFunction(MathExp);
    AddParameter(dexp, "num");
    LinkFunction(math_lib, "exp", dexp);

    VALUE dlog = CreateFunction(MathLog);
    AddParameter(dlog, "num");
    LinkFunction(math_lib, "log", dlog);

    VALUE dlog10 = CreateFunction(MathLog10);
    AddParameter(dlog10, "num");
    LinkFunction(math_lib, "log10", dlog10);

    //Power functions
    VALUE dpow = CreateFunction(MathPow);
    AddParameter(dpow, "base");
    AddParameter(dpow, "exponent");
    LinkFunction(math_lib, "pow", dpow);

    VALUE dsqrt = CreateFunction(MathSqrt);
    AddParameter(dsqrt, "num");
    LinkFunction(math_lib, "sqrt", dsqrt);

    //Misc Functions
    VALUE dceil = CreateFunction(MathCeil);
    AddParameter(dceil, "num");
    LinkFunction(math_lib, "ceil", dceil);

    VALUE dfloor = CreateFunction(MathFloor);
    AddParameter(dfloor, "num");
    LinkFunction(math_lib, "floor", dfloor);

    VALUE dabs = CreateFunction(MathAbs);
    AddParameter(dabs, "num");
    LinkFunction(math_lib, "abs", dabs);
}
Esempio n. 13
0
void BindSDL()
{
    /* SDL NameSpace */
    VALUE duckSDL = LinkNamespace("SDL");
    VALUE makeWindow = CreateFunction(MakeWindow);
    AddParameter(makeWindow, "width");
    AddParameter(makeWindow, "height");
    AddParameter(makeWindow, "name");
    AddParameter(makeWindow, "fullscreen");

    VALUE clearScreen = CreateFunction(ClearScreen);
    VALUE pageFlip = CreateFunction(PageFlip);
    VALUE eventLoop = CreateFunction(EventLoop);
    VALUE isRunning = CreateFunction(StillRunning);
    VALUE waitKey = CreateFunction(WaitKey);
    VALUE quit = CreateFunction(Quit);

    LinkFunction(duckSDL, "MakeWindow", makeWindow);
    LinkFunction(duckSDL, "flip", pageFlip);
    LinkFunction(duckSDL, "event", eventLoop);
    LinkFunction(duckSDL, "clearScreen", clearScreen);
    LinkFunction(duckSDL, "running", isRunning);
    LinkFunction(duckSDL, "waitkey", waitKey);
    LinkFunction(duckSDL, "quit", quit);

    /* OpenGL functions */
    VALUE dglLoadIdentity = CreateFunction(GlLoadIdentity);
    VALUE dglTranslatef = CreateFunction(GlTranslatef);
    AddParameter(dglTranslatef, "x");
    AddParameter(dglTranslatef, "y");
    AddParameter(dglTranslatef, "z");

    VALUE dglRotatef = CreateFunction(GlRotatef);
    AddParameter(dglRotatef, "deg");
    AddParameter(dglRotatef, "x");
    AddParameter(dglRotatef, "y");
    AddParameter(dglRotatef, "z");

    VALUE dglScalef = CreateFunction(GlScalef);
    AddParameter(dglScalef, "x");
    AddParameter(dglScalef, "y");
    AddParameter(dglScalef, "z");

    VALUE dglBegin = CreateFunction(GlBegin);
    AddParameter(dglBegin, "primitive");

    VALUE dglEnd = CreateFunction(GlEnd);
    VALUE dglColor3f = CreateFunction(GlColor3f);
    AddParameter(dglColor3f, "r");
    AddParameter(dglColor3f, "g");
    AddParameter(dglColor3f, "b");

    VALUE dglVertex3f = CreateFunction(GlVertex3f);
    AddParameter(dglVertex3f, "x");
    AddParameter(dglVertex3f, "y");
    AddParameter(dglVertex3f, "z");

    VALUE dglNormal3f = CreateFunction(GlNormal3f);
    AddParameter(dglNormal3f, "x");
    AddParameter(dglNormal3f, "y");
    AddParameter(dglNormal3f, "z");

    LinkConstPrimitive(duckSDL, "GL_TRIANGLES", GL_TRIANGLES);

    LinkFunction(duckSDL, "glLoadIdentity", dglLoadIdentity);
    LinkFunction(duckSDL, "glTranslatef", dglTranslatef);
    LinkFunction(duckSDL, "glRotatef", dglRotatef);
    LinkFunction(duckSDL, "glScalef", dglScalef);
    LinkFunction(duckSDL, "glBegin", dglBegin);
    LinkFunction(duckSDL, "glColor3f", dglColor3f);
    LinkFunction(duckSDL, "glVertex3f", dglVertex3f);
    LinkFunction(duckSDL, "glNormal3f", dglNormal3f);
    LinkFunction(duckSDL, "glEnd", dglEnd);
    return;
}
Esempio n. 14
0
//------------------------------------------------------------------------------
GmatBase* GmatFunctionFactory::CreateObject(const std::string &ofType,
                                            const std::string &withName)
{
   return CreateFunction(ofType, withName);
}
Esempio n. 15
0
void CPhylogenView::OnPhylocreate()
{
    // TODO: Add your command handler code here
    CreateFunction();
}
Esempio n. 16
0
void CPhylogenView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
    // TODO: Add your message handler code here and/or call default

    CGenedocDoc* pDoc = GetDocument();
    ASSERT_VALID(pDoc);
    POSITION Pos;
    CPhyloGenBase *pPGB;

    CClientDC dc(this);
    OnPrepareDC(&dc);

    int Selection;

    switch ( nChar ) {
    case VK_DOWN:
        if ( !ClearSelected(&Selection) ) Selection = m_LastKeySelect;
        Selection += 1;
        if ( Selection >= pDoc->m_pPGBase->m_PhyloList.GetCount() ) Selection = 0;
        SetSelected(Selection, 1);
        break;
    case VK_UP:
        if ( !ClearSelected(&Selection) ) Selection = m_LastKeySelect;
        Selection -= 1;
        if ( Selection < 0 ) Selection = pDoc->m_pPGBase->m_PhyloList.GetCount() - 1;
        SetSelected(Selection, 1);
        break;
    case VK_NEXT:
        if ( !ClearSelected(&Selection) ) Selection = m_LastKeySelect;
        Selection += 5;
        if ( Selection >= pDoc->m_pPGBase->m_PhyloList.GetCount() ) Selection = 0;
        SetSelected(Selection, 1);
        break;
    case VK_PRIOR:
        if ( !ClearSelected(&Selection) ) Selection = m_LastKeySelect;
        Selection -= 5;
        if ( Selection < 0 ) Selection = pDoc->m_pPGBase->m_PhyloList.GetCount() - 1;
        SetSelected(Selection, 1);
        break;
    case VK_HOME:
        if ( !ClearSelected(&Selection) ) Selection = m_LastKeySelect;
        Selection = 0;
        SetSelected(Selection, 1);
        break;
    case VK_END:
        if ( !ClearSelected(&Selection) ) Selection = m_LastKeySelect;
        Selection = pDoc->m_pPGBase->m_PhyloList.GetCount() - 1;
        SetSelected(Selection, 1);
        break;
    case VK_RETURN:
        Selection = 0;
        Pos = pDoc->m_pPGBase->m_PhyloList.GetHeadPosition();
        while ( Pos != NULL ) {
            CPhyloGenBase * pPGB = (CPhyloGenBase *)pDoc->m_pPGBase->m_PhyloList.GetNext(Pos);
            if ( pPGB->m_Selected == 1 ) break;
            Selection++;
        }
        Pos = pDoc->m_pPGBase->m_PhyloList.GetHeadPosition();
        while ( Pos != NULL ) {
            pPGB = (CPhyloGenBase *)pDoc->m_pPGBase->m_PhyloList.GetNext(Pos);
            if ( pPGB->m_Selected ) {
                pPGB->m_FirstSelection = 1;
                break;
            }
        }
        CreateFunction();
        SetSelected(Selection, 0 );
        break;
    case VK_SHIFT:
    case VK_SPACE:
        SelectFunction();
        break;
    case VK_DELETE:
        Selection = 0;
        Pos = pDoc->m_pPGBase->m_PhyloList.GetHeadPosition();
        while ( Pos != NULL ) {
            CPhyloGenBase * pPGB = (CPhyloGenBase *)pDoc->m_pPGBase->m_PhyloList.GetNext(Pos);
            if ( pPGB->m_Selected == 1 ) break;
            Selection++;
        }
        DeleteFunction();
        SetSelected(Selection, 0 );
        break;
    case VK_ESCAPE:
        Pos = pDoc->m_pPGBase->m_PhyloList.GetHeadPosition();
        while ( Pos != NULL ) {
            pPGB = (CPhyloGenBase *)pDoc->m_pPGBase->m_PhyloList.GetNext(Pos);
            if ( pPGB->m_FirstSelection == 1 ) {
                pPGB->m_FirstSelection = 0;
                CRect tRect = pPGB->m_ClientRect;
                dc.LPtoDP( &tRect );
                InvalidateRect( tRect );
            }
        }
        break;
    }

    CScrollView::OnKeyDown(nChar, nRepCnt, nFlags);
}
Esempio n. 17
0
// finish start of FEA results file
void NairnFEA::MyStartResultsOutput(void)
{
    char hline[200];
    int i;
    
    //---------------------------------------------------
    // Temperature
    PrintSection("THERMAL LOAD");
	if(temperatureExpr!=NULL)
	{	if(!CreateFunction(temperatureExpr))
			throw CommonException("The temperature expression is not a valid function","NairnFEA::MyStartResultsOutput");
		for(i=1;i<=nnodes;i++)
		{	nd[i]->gTemperature = FunctionValue(1,nd[i]->x,nd[i]->y,0.,0.,0.,0.)-stressFreeTemperature;
		}
		DeleteFunction();
	}
	else
	{	// unknown, but may have been set in explicit node commands
		temperatureExpr=new char[2];
		strcpy(temperatureExpr,"?");
	}
	
	sprintf(hline,"T0: %.2lf C\nT: %s C",stressFreeTemperature,temperatureExpr);
	cout << hline << endl;
	if(stressFreeTemperature!=0)
	{	sprintf(hline,"T-T0: %s - %.2lf C",temperatureExpr,stressFreeTemperature);
		cout << hline << endl;
	}
	cout << endl;
    
    //---------------------------------------------------
    // Fixed Displacements
	if(firstDispBC!=NULL)
	{	PrintSection("NODAL POINTS WITH FIXED DISPLACEMENTS");
		cout << " Node  DOF  Displacement (mm)  Axis        Angle\n"
		<< "----------------------------------------------------\n";
		NodalDispBC *nextBC=firstDispBC;
		while(nextBC!=NULL)
			nextBC=nextBC->PrintBC(cout);
		cout << endl;
	}
    
    //---------------------------------------------------
    // Loaded Nodes
	if(firstLoadBC!=NULL)
	{	PrintSection("NODAL POINTS WITH APPLIED LOADS");
		cout << " Node  DOF       Load (N)\n"
			<< "------------------------------\n";
		NodalLoad *nextLoad=firstLoadBC;
		while(nextLoad!=NULL)
			nextLoad=nextLoad->PrintLoad();
		cout << endl;
	}

    //---------------------------------------------------
    // Stress element faces
	if(firstEdgeBC!=NULL)
	{	PrintSection("FACES WITH APPLIED STRESS (MPa)");
		cout << " Elem  Fc   Type      Nodal Stress     Nodal Stress     Nodal Stress\n"
			<< "----------------------------------------------------------------------\n";
		EdgeBC *nextEdge=firstEdgeBC;
		while(nextEdge!=NULL)
			nextEdge=nextEdge->PrintEdgeLoad();
		cout << endl;
	}
	
    //---------------------------------------------------
    // Periodic directions
	if(periodic.dof)
    {	PrintSection("PERIODIC DIRECTIONS");
		// x periodic, but y not (not allowed for axisymmetric)
		if(fmobj->periodic.dof==1)
		{	sprintf(hline,"x direction from %g to %g mm",periodic.xmin,periodic.xmax);
			cout << hline << endl;
			if(periodic.fixDu)
			{	sprintf(hline,"   Displacement jump fixed at %g mm for exx = %g",periodic.du,periodic.du/(periodic.xmax-periodic.xmin));
				cout << hline << endl;
			}
			if(periodic.fixDudy)
			{	sprintf(hline,"   Displacement jump slope fixed at %g",periodic.dudy);
				cout << hline << endl;
			}
		}
		
		// y periodic, but x not (only option for axisymmetrix - z periodic, but r not)
		else if(fmobj->periodic.dof==2)
		{	char pax = fmobj->IsAxisymmetric() ? 'z' : 'y' ;
			sprintf(hline,"%c direction from %g to %g mm",pax,periodic.ymin,periodic.ymax);
			cout << hline << endl;
			if(periodic.fixDv)
			{	sprintf(hline,"   Displacement jump fixed at %g mm for e%c%c = %g",periodic.dv,pax,pax,periodic.dv/(periodic.ymax-periodic.ymin));
				cout << hline << endl;
			}
			if(periodic.fixDvdx)
			{	sprintf(hline,"   Displacement jump slope fixed at %g",periodic.dvdx);
				cout << hline << endl;
			}
		}
		
		// x and y both periodic (not allowed for axisymmetric)
		else
		{	sprintf(hline,"x direction from %g to %g mm",periodic.xmin,periodic.xmax);
			cout << hline << endl;
			if(periodic.fixDu)
			{	sprintf(hline,"   Displacement jump fixed at %g mm for exx = %g",periodic.du,periodic.du/(periodic.xmax-periodic.xmin));
				cout << hline << endl;
			}
			if(periodic.fixDvdx)
			{	sprintf(hline,"   Displacement jump dv fixed at %g",periodic.dvdx);
				cout << hline << endl;
			}
			sprintf(hline,"y direction from %g to %g mm",periodic.ymin,periodic.ymax);
			cout << hline << endl;
			if(periodic.fixDv)
			{	sprintf(hline,"   Displacement jump fixed at %g mm for eyy = %g",periodic.dv,periodic.dv/(periodic.ymax-periodic.ymin));
				cout << hline << endl;
			}
			if(periodic.fixDudy)
			{	sprintf(hline,"   Displacement jump du fixed at %g",periodic.dudy);
				cout << hline << endl;
				
				// if both Dudy and Dvdx then global shear is specified
				if(periodic.fixDvdx)
				{	double b=periodic.dvdx/(periodic.xmax-periodic.xmin);
					double d=periodic.dudy/(periodic.ymax-periodic.ymin);
					sprintf(hline,"    for gxy = %g and rotation = %g",b+d,(d-b)/2);
					cout << hline << endl;
				}
			}
		}
		cout << endl;
	}
}