Пример #1
0
bool Entity::IsVisible(void) {
    Group *g = SK.GetGroup(group);

    if(g->h.v == Group::HGROUP_REFERENCES.v && IsNormal()) {
        // The reference normals are always shown
        return true;
    }
    if(!(g->IsVisible())) return false;

    // Don't check if points are hidden; this gets called only for
    // selected or hovered points, and those should always be shown.
    if(IsNormal() && !SS.GW.showNormals) return false;

    if(!SS.GW.showWorkplanes) {
        if(IsWorkplane() && !h.isFromRequest()) {
            if(g->h.v != SS.GW.activeGroup.v) {
                // The group-associated workplanes are hidden outside
                // their group.
                return false;
            }
        }
    }

    if(style.v) {
        Style *s = Style::Get(style);
        if(!s->visible) return false;
    }

    if(forceHidden) return false;

    return true;
}
Пример #2
0
void Win2WS(UltimateContext *uc, short ws)
{
  if(uc->WorkSpace == ws) return;
  if(OnActiveWS(uc->WorkSpace) && (!OnActiveWS(ws))) UnmapWin(uc);
  uc->WorkSpace = ws;
  if(IsNormal(uc)) MapWin(uc, True);
}
Пример #3
0
void ChangeWS(short WS)
{
  Node *n;
  short oldws;

  if(OnActiveWS(WS) || (WS >= TheScreen.desktop.WorkSpaces)
     || (Handle == MoveHandle) || (Handle == ResizeHandle)) return;

  oldws=TheScreen.desktop.ActiveWorkSpace;
  TheScreen.desktop.ActiveWorkSpace=WS;

  UpdateDesktop();
  SetWSBackground();

  n=NULL;
  while((n= NodeNext(TheScreen.UltimateList, n))) {
    UltimateContext *uc;

    uc = n->data;
    if(IsNormal(uc)) {
      if(uc->WorkSpace == oldws) {
	UnmapWin(uc);
      } else if(uc->WorkSpace==WS) {
        MapWin(uc,True);
      } else if(uc->WorkSpace==-1) {
        DrawWinBorder(uc);
      }
    }
  }

  if(activemen) {
    Menu2ws(RootMenu(activemen),WS);
    RedrawMenuTree();
  }
}
Пример #4
0
/** Starts a nanokernel timer in zero-drift periodic mode with ISR or DFC callback.

	Queues the timer to expire in the specified number of nanokernel ticks,
	measured from the time at which it last expired. This allows exact periodic
	timers to be implemented with no drift caused by delays in requeueing the
	timer.

	The expiry handler will be called in the same context as the previous timer
	expiry. Generally the way this is used is that NTimer::OneShot() is used to start 
	the first time interval and this specifies whether the callback is in ISR context 
	or in the context of the nanokernel timer thread (DfcThread1) or other Dfc thread.
	The expiry handler then uses NTimer::Again() to requeue the timer.

	@param	aTime Timeout in nanokernel ticks

	@return	KErrNone if no error
	@return	KErrInUse if timer is already active;
	@return	KErrArgument if the requested expiry time is in the past.
	@return	KErrDied if tied thread/group has exited
	        
	@pre	Any context
 */
EXPORT_C TInt NTimer::Again(TInt aTime)
//
// Wait aTime from last trigger time - used for periodic timers
//
	{
	TInt irq = TheTimerQ.iTimerSpinLock.LockIrqSave();
	if (!IsValid())
		{
		TheTimerQ.iTimerSpinLock.UnlockIrqRestore(irq);
		return KErrDied;
		}
	TUint16 state = i8816.iHState16;
	if (IsNormal())
		state &= 0xFF;
	if (state!=EIdle)
		{
		TheTimerQ.iTimerSpinLock.UnlockIrqRestore(irq);
		return KErrInUse;
		}
	mb();	// ensure that if we observe an idle state all accesses to the NTimer have also been observed
	TUint32 nextTick=TheTimerQ.iMsCount;
	TUint32 trigger=iTriggerTime+(TUint32)aTime;
	TUint32 d=trigger-nextTick;
	if (d>=0x80000000)
		{
		TheTimerQ.iTimerSpinLock.UnlockIrqRestore(irq);
		return KErrArgument;		// requested time is in the past
		}
	iTriggerTime=trigger;
	TheTimerQ.Add(this);
	TheTimerQ.iTimerSpinLock.UnlockIrqRestore(irq);
	return KErrNone;
	}
Пример #5
0
/** Starts a nanokernel timer in one-shot mode with ISR or DFC callback.
	
	Queues the timer to expire in the specified number of nanokernel ticks. The
	actual wait time will be at least that much and may be up to one tick more.
	For normal timers (constructed with NTimerFn) the expiry handler will be
	called in either ISR context or in the context of the nanokernel timer
	thread (DfcThread1). For mutating timers (constructed with TDfcFn) the
	expiry handler is called in the context of the thread running the relevant
	TDfcQue.

    Note that NKern::TimerTicks() can be used to convert milliseconds to ticks.

	@param	aTime Timeout in nanokernel ticks
	@param	aDfc TRUE if DFC callback required, FALSE if ISR callback required.
			Note that this parameter is ignored for mutating timers.
	
	@return	KErrNone if no error
	@return	KErrInUse if timer is already active.
	@return	KErrDied if tied thread/group has exited
	
	@pre	Any context
	
	@see    NKern::TimerTicks()
 */
EXPORT_C TInt NTimer::OneShot(TInt aTime, TBool aDfc)
	{
	__NK_ASSERT_DEBUG(aTime>=0);
	/** iFn could be set to NULL after NTimer::OneShot(TInt, TDfc&) call.
	Call-back mechanism cannot be changed in the life time of a timer. */
	__NK_ASSERT_DEBUG(iFn!=NULL);

	TInt irq = TheTimerQ.iTimerSpinLock.LockIrqSave();
	if (!IsValid())
		{
		TheTimerQ.iTimerSpinLock.UnlockIrqRestore(irq);
		return KErrDied;
		}
	TUint16 state = i8816.iHState16;
	if (IsNormal())
		state &= 0xFF;
	else
		aDfc = FALSE;	// mutating timers start as ISR completion
	if (state!=EIdle)
		{
		TheTimerQ.iTimerSpinLock.UnlockIrqRestore(irq);
		return KErrInUse;
		}
	mb();	// ensure that if we observe an idle state all accesses to the NTimer have also been observed
	i_NTimer_iCompleteInDfc=TUint8(aDfc?1:0);
	iTriggerTime=TheTimerQ.iMsCount+(TUint32)aTime;
	TheTimerQ.Add(this);
	TheTimerQ.iTimerSpinLock.UnlockIrqRestore(irq);
	return KErrNone;
	}
Пример #6
0
std::map<std::string, ResModelLoader::ObjTankObject>
ResModelLoader::m_LoadObjTankObjects(
        const std::vector<std::string>::iterator first,
        const std::vector<std::string>::iterator last)
{
    std::map<std::string, ObjTankObject> result;

    VertexesBag v_bag;
    FacesBag f_bag;

    std::string previous_name;
    FLOATING x, y, z, s, t;
    unsigned v0, t0, n0, v1, t1, n1, v2, t2, n2;

    auto lineIt = first;
    while (lineIt != last) {

        std::string current_name;

        if (IsObject(*lineIt, current_name)) {
            if (!previous_name.empty()) {
                result[previous_name] = m_BuildObjTankObject(v_bag, f_bag);
                f_bag.Clear();
            }
            previous_name = current_name;

        } else if (IsVertex(*lineIt, x, y, z)) {
            v_bag.vertexes.emplace_back(x, y, z);

        } else if (IsNormal(*lineIt, x, y, z)) {
            v_bag.normals.emplace_back(x, y, z);

        } else if (IsTexCoord(*lineIt, s, t)) {
            v_bag.tex_coords.emplace_back(s, t);

        } else if (IsFace3(*lineIt, v0, t0, n0, v1, t1, n1, v2, t2, n2)) {
            f_bag.faces3.emplace_back(v0, t0, n0);
            f_bag.faces3.emplace_back(v1, t1, n1);
            f_bag.faces3.emplace_back(v2, t2, n2);

        } else if (IsFace2(*lineIt, v0, n0, v1, n1, v2, n2)) {
            f_bag.faces2.emplace_back(v0, n0);
            f_bag.faces2.emplace_back(v1, n1);
            f_bag.faces2.emplace_back(v2, n2);

        } else if (IsSmoothing(*lineIt) || IsComment(*lineIt)) {
            // NULL;
        }

        ++lineIt;
    }

    // Write last object.
    result[previous_name] = m_BuildObjTankObject(v_bag, f_bag);

    return result;
}
Пример #7
0
void Entity::CalculateNumerical(bool forExport) {
    if(IsPoint()) actPoint = PointGetNum();
    if(IsNormal()) actNormal = NormalGetNum();
    if(type == DISTANCE || type == DISTANCE_N_COPY) {
        actDistance = DistanceGetNum();
    }
    if(IsFace()) {
        actPoint  = FaceGetPointNum();
        Vector n = FaceGetNormalNum();
        actNormal = Quaternion::From(0, n.x, n.y, n.z);
    }
    if(forExport) {
        // Visibility in copied import entities follows source file
        actVisible = IsVisible();
    } else {
        // Copied entities within a file are always visible
        actVisible = true;
    }
}
Пример #8
0
bool Replace(Font fnt, int chr, Font& rfnt)
{
	static Vector<int> rface;
	static Vector<dword> l, h;
	ONCELOCK {
		for(int i = 0; i < __countof(sFontReplacements) && rface.GetCount() < 20; i++) {
			int q = Font::FindFaceNameIndex(sFontReplacements[i].name);
			if(q > 0) {
				rface.Add(q);
				l.Add(sFontReplacements[i].l);
				h.Add(sFontReplacements[i].h);
			}
		}
	}

	Font f = fnt;
//	dword tl = chr < 4096 ? 0x80000000 >> (chr >> 7) : 0;
//	dword th = 0x80000000 >> ((dword)chr >> 11);
	for(int i = 0; i < rface.GetCount(); i++) {
		if(/*((l[i] & tl) || (h[i] & th)) && */IsNormal(f.Face(rface[i]), chr)) {
			int a = fnt.GetAscent();
			int d = fnt.GetDescent();
			if(f.GetAscent() > a || f.GetDescent() > d) {
				static sFontMetricsReplacement cache[256];
				int q = CombineHash(fnt, f) & 255;
				if(cache[q].src != fnt || cache[q].dst != f) {
					cache[q].src = fnt;
					cache[q].dst = f;
					while((f.GetAscent() > a || f.GetDescent() > d) && f.GetHeight() > 1) {
						f.Height(max(1, min(f.GetHeight() - 1, f.GetHeight() * 9 / 10)));
					}
					cache[q].mdst = f;
				}
				else
					f = cache[q].mdst;
			}
			rfnt = f;
			return true;
		}
	}
	return false;
}
Пример #9
0
TUint NTimer::DoCancel(TUint aFlags)
	{
	NSchedulable* tied = 0;
	TInt irq = NKern::DisableAllInterrupts();
	TheTimerQ.iTimerSpinLock.LockOnly();
	TUint state = i_NTimer_iState;
	mb();
	if (IsNormal() && state>=EEventQ)
		{
		// It's on a CPU's event handler queue
		TInt cpu = state - EEventQ;
		if (cpu < TheScheduler.iNumCpus)
			{
			TSubScheduler* ss = TheSubSchedulers + cpu;
			ss->iEventHandlerLock.LockOnly();
			state = i_NTimer_iState;
			if (state != EIdle)
				{
				Deque();	// we got to it first
				tied = iTied;
				i_NTimer_iState = EIdle;
				}
			ss->iEventHandlerLock.UnlockOnly();
			goto end;
			}
		}
	DoCancel0(state);
	if (IsMutating())
		i8816.iHState16 = 0;
	else
		i_NTimer_iState=EIdle;
end:
	if (aFlags & ECancelDestroy)
		iHType = EEventHandlerDummy;
	TheTimerQ.iTimerSpinLock.UnlockOnly();
	if (tied)
		tied->EndTiedEvent();	// FIXME - Could be called in thread context
	NKern::RestoreInterrupts(irq);
	return state;
	}
Пример #10
0
BOOL CSetting::Load()
{
	CFile file;
	if(file.Open( "Setting.set",CFile::modeRead))
	{
		file.SeekToBegin();
		file.Read(this,sizeof(CSetting));
		file.Close();

		if(IsNormal())return TRUE;
		else
		{
			Reset();
			Save();
			return FALSE;
		}		
	}
	MessageBox(NULL, "没找到 Setting.set 文件\n\n这个文件并不是必需的,但它记录了你的设置内容,\n\n请不要删掉\n\n你现在可以通过菜单 \"文件\" -> \"设置\" 重新设定.","提醒",MB_OK|MB_ICONINFORMATION);
	Reset();
	Save();
	return FALSE;
}
Пример #11
0
void TraceManager::InstApply(IMG img)
{

	DBG_TRACE("before check");
	DBG_TRACE(IMG_Name(img));
	
	if(mySpec==NULL){
		cerr<<"Spec manager is Null"<<endl;		
		return;
	}

	string imgname=ImageTrim(IMG_Name(img));
	cerr<<imgname<<endl;
/*!!!
	if(imgname.compare(MPI_LIB)==0)
	{
		//if the module is mpi dll then 
		//MpiInst(img);
		return;
	}
*/
    
	//for rest of the modules it goes ahead here
	//checks if it's to be instrumented 
	//leaves if it's not suppose to be
	if(!mySpec->InstImage(imgname))
	{
		DBG_TRACE("Not to be instrumented");
		return;
	}
	//cerr<<"After approved for image inst"<<endl;	

	//Start enumarting all the routines in the image to be instrumented 
	SEC temp=IMG_SecHead(img);
	while(SEC_Valid(temp))
	{
		//we pick only executable code segment
		if(SEC_Type(temp)==SEC_TYPE_EXEC){
			RTN myrtn=SEC_RtnHead(temp);
			DBG_TRACE("RTNs to be instrumented");
			while(RTN_Valid(myrtn))
			{

				DBG_TRACE(RTN_Name(myrtn));
				//cerr<<RTN_Name(myrtn)<<endl;

				if(IsMpiRtn(RTN_Name(myrtn)))
				{
#ifndef NOMPI
					MpiInstRtn(myrtn);
#endif
					myrtn=RTN_Next(myrtn);
					continue;
				}

				if(RTN_Name(myrtn).length()==0 || !IsInstSafe(RTN_Name(myrtn)))
				{
					myrtn=RTN_Next(myrtn);
					continue;
				}
				
				if(mySpec->InstRtn(RTN_Name(myrtn),imgname))
				{
					//if the routine is to be instrumented 
					//apply the instrumentation here
					RTN_Open(myrtn);
					if(!IsNormal(myrtn))
					{
						RTN_Close(myrtn);
						myrtn=RTN_Next(myrtn);
						continue;
					}
					//DBG_TRACE(RTN_Name(myrtn));
					RtnTrack * brtntr = new RtnTrack;
					brtntr->img=imgname;
					brtntr->rtn=RTN_Name(myrtn);
					brtntr->stage=0;
					brtntr->flag=mySpec->GetProfileFlag(brtntr->rtn,brtntr->img);

					//insert the instrumentation at the exit point
					
					RTN_InsertCall(myrtn, IPOINT_AFTER, (AFUNPTR)HookHandleAfter, IARG_PTR ,brtntr, IARG_END);
					//RTN_InsertCallProbed(myrtn, IPOINT_AFTER, (AFUNPTR)HookHandleAfter, IARG_PTR ,brtntr, IARG_END);
					//insert the instrumentation at the entry point
					RTN_InsertCall(myrtn, IPOINT_BEFORE, (AFUNPTR)HookHandleBefore, IARG_PTR ,brtntr, IARG_END);
					//RTN_InsertCallProbed(myrtn, IPOINT_BEFORE, (AFUNPTR)HookHandleBefore, IARG_PTR ,brtntr, IARG_END);
					//cerr<<"Name::"<<RTN_Name(myrtn)<<" Start::"<<RTN_Address(myrtn)<<"  End::"<<RTN_Address(myrtn)+RTN_Size(myrtn)<<endl;	
					RTN_Close(myrtn);
				}
				myrtn=RTN_Next(myrtn);
			}
		}
		temp=SEC_Next(temp);		
	}	
}