question

Visakh Sakulan avatar image
0 Likes"
Visakh Sakulan asked Visakh Sakulan commented

Stop Waiting Room drawing floor when its ports are closed

closeport.fsmcloseport.png

In the model when the input port of the waiting room is closed the floor area and a red box appears. how to remove that?

FlexSim 16.1.0
FlexSim HC 5.0.12
flexsim hc 5.0waiting roominput portdrawfloor
closeport.png (147.7 KiB)
closeport.fsm (61.6 KiB)
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

Matthew Gillespie avatar image
0 Likes"
Matthew Gillespie answered Visakh Sakulan commented

The draw code of the waiting room draws the floor and red box whenever the input ports are closed. There's not an easy way to tell it not to draw the floor without writing custom draw code.

I would recommend you not even use this method of closing and opening ports to perform batching and instead use the method in this answer.

If you really want to override the draw code here's the draw code from the object without the drawfloor part, you should be able to paste this into the object's draw trigger:

//////////////////////////////////// CODE HEADER //////////////////////////////////////////////////////////////////////
treenode current = ownerobject(c);
treenode view = parnode(1);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


fglPushMatrix();
drawtomodelscale(current);
fglDisable(GL_TEXTURE_2D);
double r = get(rank(color(current),1));
double g = get(rank(color(current),2));
double b = get(rank(color(current),3));
double rotation = 0;
int nrofbays = content(getvarnode(current, "contenttable"));

//size of chair graphic
double chairWidth = 0.713;
double chairDepth = 0.645;
double chairHeight = 1.07;

for(int bay = 1; bay <= nrofbays; bay++)
{
	double bayloc = get(rank(getvarnode(current, "locationtable"), bay));
	treenode curBayNode = rank(getvarnode(current, "sizetable"), bay);
	double baysize = get(curBayNode);
	int nroflevels = content(rank(getvarnode(current, "contenttable"), bay));
	double deltax = 0;
	double deltay = 0;
	
	for(int level = 1; level <= nroflevels; level++)
	{
		// Each row in the sizetable is a bay and is a head node of yet another table with a row
		// for each level of the bay, and two column. In the first column is the height of the
		// level (i.e. length of the bay's "Position") and the second column contains the orientation
		// of the graphic at that position.
		double levelsize = gettablenum(curBayNode, level, 1);
		int orientation = gettablenum(curBayNode, level, 2);
		double levelloc = gettablenum(getvarnode(current, "locationtable"), bay, level);
		// Subtract leveloc from ysize to correct for opposite y direction in object's coordinate system,
		// and subtract levelsize to correct for level size.
		levelloc = (ysize(current) - levelloc) - levelsize;


		// Determine the deltax,deltay vectors from the origin of each cell (i.e. position) to the
		// front-left corner of the graphic (i.e. chair). The origin of the cell is the top-left
		// corner of the cell when viewed from a model top view where model positive x is to the right
		// and positive y is up. However the deltay vector's positive direction would be down.
		// The 0.04 and 0.02 adjustments to deltax/deltay that are used below are necessary because
		// the chair shape in the 3DS file is shifted 0.02 meters to the right size of the chair,
		// and 0.04 meters to the front of the chair.
		switch(orientation)
		{
			case ORIENTATION_RIGHT: // 3 1
			{
				deltax = chairDepth - 0.04; 
				deltay = (levelsize-chairWidth) - 0.02;
				rotation = -90;
				break;
			}
			case ORIENTATION_FORWARD: // 1 2
			{
				deltax = 0 - 0.02;
				deltay = (levelsize-chairDepth) + 0.04;
				rotation = 0;
				break;
			}
			case ORIENTATION_LEFT: // 2 3
			{
				deltax = 0 + 0.04;
				deltay = levelsize + 0.02;
				rotation = 90;
				break;
			}
			case ORIENTATION_BACKWARD: // 4
			{
				deltax = chairWidth + 0.02;
				deltay = levelsize - 0.04;
				rotation = 180;
				break;
			}
		}


		fglPushMatrix();
		fglTranslate(bayloc + deltax, 0, levelloc + deltay); // flexsim x, -z, y
		fglRotate(rotation, 0,1,0);
		// I don't know the origin of the following x,z,y scale factors. They're a little off from the sx,sy,sz
		// of the actual graphic in the model (as used above), but thought I ought to keep the scale of
		// the graphic in the model unchanged because it fits the patients fairly well.
		fglScale(0.75, 0.97, 0.68); 
		fglColor(r,g,b);
		drawobject(view, getvarnum(current, "CurShapeIndex"), 0);
		fglPopMatrix();
	}
}


fglPopMatrix();
fglEnable(GL_TEXTURE_2D);


return 1;
· 4
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Cliff King avatar image Cliff King commented ·

@Visakh Sakulan It's an oversight on our part to not let the user easily turn off the red band around the perimeter of the floor display on locations that have closed inputs. I don't know if you know or not, but we provide switches in File > Global Preferences > Environment to turn on/off this sort of display for Off Schedule and Kept resources. We just need to include locations as well as resources. We will do this in the next release of the software!

1 Like 1 ·
Visakh Sakulan avatar image Visakh Sakulan Cliff King commented ·

@cliff.king Thank you for the information.

0 Likes 0 ·
Arun Kr avatar image Arun Kr commented ·

Hi Mathew,

Can we use drawobjectfloor() command?

Regards,

Arun KR

0 Likes 0 ·
Matthew Gillespie avatar image Matthew Gillespie ♦♦ Arun Kr commented ·

You could use it in an object's on draw trigger, but most objects on HC already have it in their draw code and have a Show Floor checkbox.

0 Likes 0 ·