예제 #1
0
파일: stb.c 프로젝트: mhelal/mmDST
long getTraceBackPartition (void * arg, long cellIndex, long * localCellIndex) {
	long partIndex, maxpartIndex, maxlocalCellIndex, locCellIndex;
	char msg[MID_MESSAGE_SIZE];
	Slave * slave;
	slave = (Slave *) arg;
	
	partIndex = getPartIndex (slave, cellIndex, &locCellIndex, 0);
	maxlocalCellIndex = locCellIndex;
	maxpartIndex = partIndex;
	sprintf(msg, "in getTraceBackPartition locCellIndex %ld partIndex %ld\n", locCellIndex, partIndex);  
	mprintf(20, msg, threadnum);
	while ((partIndex >= 0) && (partIndex < slave->partitionsCount-1)) {
		partIndex = getPartIndex (slave, cellIndex, &locCellIndex, partIndex + 1);
		sprintf(msg, "in getTraceBackPartition locCellIndex %ld partIndex %ld \n", locCellIndex, partIndex);  
		mprintf(20, msg, threadnum);
		if ((locCellIndex > maxlocalCellIndex) && (partIndex != -1) && (partIndex < slave->partitionsCount-1)) {
			maxlocalCellIndex = locCellIndex;
			maxpartIndex = partIndex;
		}
	}
	(*localCellIndex) = maxlocalCellIndex;
	sprintf(msg, "leaving getTraceBackPartition with (*localCellIndex) %ld maxpartIndex %ld\n", (*localCellIndex), maxpartIndex);  
	mprintf(20, msg, threadnum);
	return maxpartIndex;
}
예제 #2
0
void Animation::setRotation(BVHNode* node,double x,double y,double z)
{
  if (node)
  {
    //qDebug(QString("Animation::setRotation(")+jointName+")");

    for(int i=0;i<NUM_IK;i++)
    {
      if(ikOn[i])
      {
        solveIK();
        break;
      }
    }

    if(node->isKeyframe(frame))
      node->setKeyframeRotation(frame,Rotation(x,y,z));
    else
    {
      node->addKeyframe(frame,node->frameData(frame).position(),Rotation(x,y,z));
      setEaseIn(node,frame,Settings::easeIn());
      setEaseOut(node,frame,Settings::easeOut());
    }

    //      node->dumpKeyframes();
    BVHNode* mirrorNode=node->getMirror();
    if(mirrored && mirrorNode)
    {
      // new keyframe system
      if(mirrorNode->isKeyframe(frame))
        mirrorNode->setKeyframeRotation(frame,Rotation(x,-y,-z));
      else
      {
        mirrorNode->addKeyframe(frame,node->frameData(frame).position(),Rotation(x,-y,-z));
        setEaseIn(mirrorNode,frame,Settings::easeIn());
        setEaseOut(mirrorNode,frame,Settings::easeOut());
      }

      // tell timeline that this mirrored keyframe has changed (added or changed is the same here)
      emit redrawTrack(getPartIndex(mirrorNode));
    }
    setDirty(true);
    // tell timeline that this keyframe has changed (added or changed is the same here)
    emit redrawTrack(getPartIndex(node));
    emit frameChanged();
  }
  else
  {
    qDebug("Animaiton::setRotation(): node==0!");
  }
}
예제 #3
0
// virtual
UndoStep* SwitchPartUndoStep::undo()
{
	std::size_t begin = map->reassignObjectsToMapPart(modified_objects.begin(), modified_objects.end(), source_index, getPartIndex());
	
	ObjectList::iterator it = modified_objects.begin();
	SwitchPartUndoStep* undo = new SwitchPartUndoStep(map, getPartIndex(), source_index);
	for (std::size_t i = begin, end = map->getPart(getPartIndex())->getNumObjects(); i < end; ++i)
	{
		undo->addObject(i);
		// Save indices from target part (needed for getModifiedObjects())
		*it = i;
		++it;
	}
	return undo;
}
예제 #4
0
UndoStep* AddObjectsUndoStep::undo()
{
	int const part_index = getPartIndex();
	
	DeleteObjectsUndoStep* undo_step = new DeleteObjectsUndoStep(map);
	undo_step->setPartIndex(part_index);
	
	// Make sure to add the objects in the right order so the other objects' indices stay valid
	std::vector< std::pair<int, int> > order;	// index into affected_objects & objects, object index
	order.resize(modified_objects.size());
	for (int i = 0; i < (int)modified_objects.size(); ++i)
		order[i] = std::pair<int, int>(i, modified_objects[i]);
	std::sort(order.begin(), order.end(), sortOrder);
	
	MapPart* part = map->getPart(part_index);
	int size = (int)objects.size();
	for (int i = 0; i < size; ++i)
	{
		undo_step->addObject(modified_objects[order[i].first]);
		part->addObject(objects[order[i].first], order[i].second);
	}
	
	undone = true;
	return undo_step;
}
예제 #5
0
void Animation::applyIK(const QString& name)
{
  BVHNode* node=bvh->bvhFindNode(frames,name);

  Rotation rot=node->frameData(frame).rotation();

  if(node)
  {
//    for (int i=0; i<3; i++) {
    rot.x+=node->ikRot.x;
    rot.y+=node->ikRot.y;
    rot.z+=node->ikRot.z;


    node->ikRot.x=0;
    node->ikRot.y=0;
    node->ikRot.z=0;
/*
      node->frame[frame][i] += node->ikRot[i];
      node->ikRot[i] = 0;
*/
//      node->ikOn = false;

    setDirty(true);
    addKeyFrame(node);
    node->setKeyframeRotation(frame,rot);
    emit redrawTrack(getPartIndex(node));
//    }
  }
}
예제 #6
0
void ObjectTagsUndoStep::addObject(int index)
{
	ObjectModifyingUndoStep::addObject(index);
	
	MapPart* const map_part = map->getPart(getPartIndex());
	object_tags_map[index] = map_part->getObject(index)->tags();
}
예제 #7
0
// recursively remove frames from joint and all its children
void Animation::deleteFrameHelper(BVHNode* joint,int frame)
{
//  qDebug("Animation::deleteFrameHelper(joint %s,frame %d)",joint->name().toLatin1().constData(),frame);
  joint->deleteFrame(frame);
  for(int i=0;i<joint->numChildren();i++)
    deleteFrameHelper(joint->child(i),frame);
  emit redrawTrack(getPartIndex(joint));
}
예제 #8
0
void Animation::optimizeHelper(BVHNode* joint)
{
  if(joint->type!=BVH_END)
  {
    joint->optimize();
    emit redrawTrack(getPartIndex(joint));
  }

  for(int i=0;i<joint->numChildren();i++)
    optimizeHelper(joint->child(i));
}
예제 #9
0
void Animation::addKeyFrame(BVHNode* joint)
{
  joint->addKeyframe(frame,getPosition(),getRotation(joint));

  setEaseIn(joint,frame,Settings::easeIn());
  setEaseOut(joint,frame,Settings::easeOut());

  setDirty(true);

  emit redrawTrack(getPartIndex(joint));
  emit frameChanged();
}
예제 #10
0
void ObjectModifyingUndoStep::getModifiedObjects(int part_index, ObjectSet& out) const
{
	if (part_index == getPartIndex())
	{
		MapPart* const map_part = map->getPart(part_index);
		for (std::vector<int>::const_iterator it = modified_objects.begin(), end = modified_objects.end(); it != end; ++it)
		{
			Q_ASSERT(*it >= 0 && *it < map_part->getNumObjects());
			out.insert(map_part->getObject(*it));
		}
	}
}
예제 #11
0
void Animation::deleteKeyFrame(BVHNode* joint,int frameNum,bool silent)
{
  // never delete first keyframe
  if(frameNum)
  {
    joint->deleteKeyframe(frameNum);
    setDirty(true);
  }

  // if silent is true then only send a signal to the timeline but not to the animation view
  if(!silent) emit frameChanged();
  emit redrawTrack(getPartIndex(joint));
}
예제 #12
0
void Animation::mirrorHelper(BVHNode* joint)
{
  // make sure only to mirror one side of l/r joints, and joints that have no mirror node
  if(!joint->name().startsWith("l"))
  {
    joint->mirror();
    emit redrawTrack(getPartIndex(joint));
    if(joint->getMirror())
      emit redrawTrack(joint->getMirrorIndex());
  }

  for(int i=0;i<joint->numChildren();i++)
    mirrorHelper(joint->child(i));
}
예제 #13
0
UndoStep* ObjectTagsUndoStep::undo()
{
	int const part_index = getPartIndex();
	
	ObjectTagsUndoStep* redo_step = new ObjectTagsUndoStep(map);
	MapPart* const map_part = map->getPart(part_index);
	
	redo_step->setPartIndex(part_index);
	for (ObjectTagsMap::iterator it = object_tags_map.begin(), end = object_tags_map.end(); it != end; ++it)
	{
		redo_step->addObject(it->first);
		map_part->getObject(it->first)->setTags(it->second);
	}
	
	return redo_step;
}
예제 #14
0
void Animation::mirror(BVHNode* joint)
{
  if(!joint)
  {
    positionNode->mirror();
    mirrorHelper(frames);
  }
  else
  {
    joint->mirror();
    emit redrawTrack(getPartIndex(joint));
    if(joint->getMirror())
      emit redrawTrack(joint->getMirrorIndex());
  }
  setDirty(true);
}
예제 #15
0
void Animation::setEaseOut(BVHNode* node,int frameNum,bool state)
{
  if(!node)
  {
    qDebug("Animation::setEaseOut(): node==0!");
    return;
  }

  if(node->isKeyframe(frameNum))
  {
    setDirty(true);
    node->setEaseOut(frameNum,state);
    // tell main class that the keyframe has changed
    emit redrawTrack(getPartIndex(node));
  }
}
예제 #16
0
void AddObjectsUndoStep::removeContainedObjects(bool emit_selection_changed)
{
	MapPart* part = map->getPart(getPartIndex());
	int size = (int)objects.size();
	bool object_deselected = false;
	for (int i = 0; i < size; ++i)
	{
		if (map->isObjectSelected(objects[i]))
		{
			map->removeObjectFromSelection(objects[i], false);
			object_deselected = true;
		}
		part->deleteObject(objects[i], true);
		map->setObjectsDirty();
	}
	if (object_deselected && emit_selection_changed)
		map->emitSelectionChanged();
}
예제 #17
0
UndoStep* ReplaceObjectsUndoStep::undo()
{
	int const part_index = getPartIndex();
	
	ReplaceObjectsUndoStep* undo_step = new ReplaceObjectsUndoStep(map);
	undo_step->setPartIndex(part_index);
	
	MapPart* part = map->getPart(part_index);
	std::size_t size = objects.size();
	for (std::size_t i = 0; i < size; ++i)
	{
		undo_step->addObject(modified_objects[i], part->getObject(modified_objects[i]));
		part->setObject(objects[i], modified_objects[i], false);
	}
	
	undone = true;
	return undo_step;
}
예제 #18
0
UndoStep* SwitchDashesUndoStep::undo()
{
	int const part_index = getPartIndex();
	
	SwitchDashesUndoStep* undo_step = new SwitchDashesUndoStep(map);
	undo_step->setPartIndex(part_index);
	
	MapPart* part = map->getPart(part_index);
	for (ObjectList::iterator it = modified_objects.begin(), end = modified_objects.end(); it != end; ++it)
	{
		PathObject* object = reinterpret_cast<PathObject*>(part->getObject(*it));
		object->reverse();
		object->update();
		
		undo_step->addObject(*it);
	}
	
	return undo_step;
}
예제 #19
0
UndoStep* SwitchSymbolUndoStep::undo()
{
	int const part_index = getPartIndex();
	
	SwitchSymbolUndoStep* undo_step = new SwitchSymbolUndoStep(map);
	undo_step->setPartIndex(part_index);
	
	MapPart* part = map->getPart(part_index);
	int size = (int)modified_objects.size();
	for (int i = 0; i < size; ++i)
	{
		Object* object = part->getObject(modified_objects[i]);
		undo_step->addObject(modified_objects[i], object->getSymbol());
		bool ok = object->setSymbol(target_symbols[i], false);
		Q_ASSERT(ok);
		Q_UNUSED(ok);
	}
	
	return undo_step;
}
예제 #20
0
UndoStep* DeleteObjectsUndoStep::undo()
{
	int const part_index = getPartIndex();
	
	AddObjectsUndoStep* undo_step = new AddObjectsUndoStep(map);
	undo_step->setPartIndex(part_index);
	
	// Make sure to delete the objects in the right order so the other objects' indices stay valid
	std::sort(modified_objects.begin(), modified_objects.end(), std::greater<int>());
	
	MapPart* part = map->getPart(part_index);
	int size = (int)modified_objects.size();
	for (int i = 0; i < size; ++i)
	{
		undo_step->addObject(modified_objects[i], part->getObject(modified_objects[i]));
		part->deleteObject(modified_objects[i], true);
	}
	
	return undo_step;
}
예제 #21
0
void ObjectTagsUndoStep::saveImpl(QXmlStreamWriter &xml) const
{
	UndoStep::saveImpl(xml);
	
	// Note: For reducing file size, this implementation copies, not calls,
	// the parent's implementation.
	XmlElementWriter element(xml, QLatin1String("affected_objects"));
	element.writeAttribute(QLatin1String("part"), getPartIndex());
	std::size_t size = modified_objects.size();
	if (size > 8)
		element.writeAttribute(QLatin1String("count"), size);
	
	for (ObjectTagsMap::const_iterator it = object_tags_map.begin(), end = object_tags_map.end(); it != end; ++it)
	{
		namespace literal = XmlStreamLiteral;
		
		XmlElementWriter tags_element(xml, QLatin1String("ref"));
		tags_element.writeAttribute(literal::object, it->first);
		tags_element.write(it->second);
	}
}
예제 #22
0
void ObjectCreatingUndoStep::getModifiedObjects(int part_index, ObjectSet& out) const
{
	if (part_index == getPartIndex())
		out.insert(objects.begin(), objects.end());
}
예제 #23
0
bool ObjectModifyingUndoStep::getModifiedParts(PartSet& out) const
{
	out.insert(getPartIndex());
	return !modified_objects.empty();
}
static long flashlight_ioctl_core(struct file *file, unsigned int cmd, unsigned long arg)
{
	int partId;
	int sensorDevIndex;
	int strobeIndex;
	int partIndex;
    int i4RetValue = 0;
	kdStrobeDrvArg kdArg;
	unsigned long copyRet;
    copyRet = copy_from_user(&kdArg , (void *)arg , sizeof(kdStrobeDrvArg));
    logI("flashlight_ioctl cmd=0x%x(nr=%d), senorDev=0x%x ledId=0x%x arg=0x%lx",cmd, _IOC_NR(cmd), kdArg.sensorDev, kdArg.strobeId ,(unsigned long)kdArg.arg);
	sensorDevIndex = getSensorDevIndex(kdArg.sensorDev);
	strobeIndex = getStrobeIndex(kdArg.strobeId);
	if(sensorDevIndex<0 || strobeIndex<0 )
		return -1;
	partId = g_strobePartId[sensorDevIndex][strobeIndex];
	partIndex = getPartIndex(partId);
	if(partIndex<0)
		return -1;



    switch(cmd)
    {
        case FLASH_IOC_GET_PROTOCOL_VERSION:
            i4RetValue=1;
            break;
        case FLASH_IOC_IS_LOW_POWER:
            logI("FLASH_IOC_IS_LOW_POWER");
            {
                int isLow=0;
                if(gLowPowerPer!=BATTERY_PERCENT_LEVEL_0 || gLowPowerVbat!=LOW_BATTERY_LEVEL_0 )
                    isLow=1;
                logI("FLASH_IOC_IS_LOW_POWER %d %d %d",gLowPowerPer,gLowPowerVbat,isLow);
                kdArg.arg = isLow;
                if(copy_to_user((void __user *) arg , (void*)&kdArg , sizeof(kdStrobeDrvArg)))
    			{
    				logE("[FLASH_IOC_IS_LOW_POWER] ioctl copy to user failed ~");
    				return -EFAULT;
    			}
		    }
			break;

        case FLASH_IOC_LOW_POWER_DETECT_START:
	        logI("FLASH_IOC_LOW_POWER_DETECT_START");
            gLowBatDuty[sensorDevIndex][strobeIndex]=kdArg.arg;
            break;

        case FLASH_IOC_LOW_POWER_DETECT_END:
   	        logI("FLASH_IOC_LOW_POWER_DETECT_END");
   	        gLowBatDuty[sensorDevIndex][strobeIndex]=-1;
            break;
        case FLASHLIGHTIOC_X_SET_DRIVER:
            i4RetValue = setFlashDrv(kdArg.sensorDev,  kdArg.strobeId);
            break;
		case FLASH_IOC_GET_PART_ID:
       	case FLASH_IOC_GET_MAIN_PART_ID:
		case FLASH_IOC_GET_SUB_PART_ID:
		case FLASH_IOC_GET_MAIN2_PART_ID:
			{
				int partId;
				partId = strobe_getPartId(kdArg.sensorDev, kdArg.strobeId);
				g_strobePartId[sensorDevIndex][strobeIndex]=partId;
				kdArg.arg = partId;
				if(copy_to_user((void __user *) arg , (void*)&kdArg , sizeof(kdStrobeDrvArg)))
    			{
    				logE("[FLASH_IOC_GET_PART_ID] ioctl copy to user failed ~");
    				return -EFAULT;
    			}
				logI("FLASH_IOC_GET_PART_ID line=%d partId=%d",__LINE__,partId);
			}
          	break;
         case FLASH_IOC_SET_ONOFF:
            {
				FLASHLIGHT_FUNCTION_STRUCT *pF;
				pF = g_pFlashInitFunc[sensorDevIndex][strobeIndex][partIndex];
				if(pF!=0)
				{
					kicker_pbm_by_flash(kdArg.arg);
					i4RetValue = pF->flashlight_ioctl(cmd,kdArg.arg);

				}
				else
				{
					logE("[FLASH_IOC_SET_ONOFF] function pointer is wrong -");
				}
			}
            break;
		case FLASH_IOC_UNINIT:
			{
				FLASHLIGHT_FUNCTION_STRUCT *pF;
				pF = g_pFlashInitFunc[sensorDevIndex][strobeIndex][partIndex];
				if(pF!=0)
				{
					i4RetValue = pF->flashlight_release((void*)0);
					pF=0;

				}
				else
				{
					logE("[FLASH_IOC_UNINIT] function pointer is wrong ~");
				}
			}
    	default :
			{
				FLASHLIGHT_FUNCTION_STRUCT *pF;
				pF = g_pFlashInitFunc[sensorDevIndex][strobeIndex][partIndex];
				if(pF!=0)
				{
					i4RetValue = pF->flashlight_ioctl(cmd,kdArg.arg);
				}
				else
				{
					logE("[default] function pointer is wrong ~");
				}
			}
    		break;
    }
    return i4RetValue;
}
//========================================================================
static int setFlashDrv(int sensorDev, int strobeId)
{
	int partId;
	int sensorDevIndex;
    int strobeIndex;
	int partIndex;
	FLASHLIGHT_FUNCTION_STRUCT** ppF=0;
	sensorDevIndex = getSensorDevIndex(sensorDev);
	strobeIndex = getStrobeIndex(strobeId);
	if(sensorDevIndex<0 || strobeIndex<0 )
		return -1;
	partId = g_strobePartId[sensorDevIndex][strobeIndex];
	partIndex = getPartIndex(partId);
	if(partIndex<0)
		return -1;

	logI("setFlashDrv sensorDev=%d, strobeId=%d, partId=%d ~",sensorDev, strobeId, partId);

	ppF = &g_pFlashInitFunc[sensorDevIndex][strobeIndex][partIndex];
	if(sensorDev==e_CAMERA_MAIN_SENSOR)
	{
    	#if defined(DUMMY_FLASHLIGHT)
    	    strobeInit_dummy(ppF);
    	#else
        	if(strobeId==1)
        	{
                if(partId==1)
        			constantFlashlightInit(ppF);
        		else if(partId==2)
        			strobeInit_main_sid1_part2(ppF);
        	}
        	else if(strobeId==2)
        	{
        		if(partId==1)
        			strobeInit_main_sid2_part1(ppF);

        		else if(partId==2)
        			strobeInit_main_sid2_part2(ppF);
        	}
        #endif
	}
	else if(sensorDev==e_CAMERA_SUB_SENSOR)
	{
	    if(strobeId==1)
    	{
            if(partId==1)
    			subStrobeInit(ppF);
    		else if(partId==2)
    			strobeInit_sub_sid1_part2(ppF);
    	}
    	else if(strobeId==2)
    	{
    		if(partId==1)
    			strobeInit_sub_sid2_part1(ppF);
    		else if(partId==2)
    			strobeInit_sub_sid2_part2(ppF);
    	}
	}


	if((*ppF)!=0)
	{
		(*ppF)->flashlight_open(0);
		logI("setFlashDrv ok %d",__LINE__);
	}
	else
	{
		logE("set function pointer not found!!");
		return -1;
	}
	return 0;
}