Beispiel #1
0
    bool VisitDecl(Decl* D) {
      if (!m_IsStoringState)
        return true;

      if (!D->hasAttr<AnnotateAttr>())
        return true;

      Annotations_t annotations;
      for(auto attr = D->specific_attr_begin<AnnotateAttr> (),
          end = D->specific_attr_end<AnnotateAttr> ();
          attr != end;
          ++attr)
      {
        if (!attr->isInherited()) {
          auto annot = attr->getAnnotation();
          if (annot.startswith(llvm::StringRef(annoTag, lenAnnoTag))) {
            if (annotations.first.empty()) {
              annotations.first = annot.drop_front(lenAnnoTag);
            } else {
              annotations.second = annot.drop_front(lenAnnoTag);
            }
          }
        }
      }
      InsertIntoAutoloadingState(D, annotations);

      return true;
    }
void AnnotationItem::updateGeometry()
{
    prepareGeometryChange();

    QSizeF geometry = calcMinimumGeometry();
    qreal width = geometry.width();
    qreal height = geometry.height();

    if (getAnnotation()->hasAutoSize()) {
        if (_text_item) {
            _text_item->setTextWidth(-1);
            QSizeF text_size = _text_item->document()->size();
            width = text_size.width() + 2 * CONTENTS_BORDER_HORIZONTAL;
            height = text_size.height() + 2 * CONTENTS_BORDER_VERTICAL;
        }
    } else {
        QRectF rect = getAnnotation()->getRect();
        width = rect.width();
        if (_text_item) {
            _text_item->setTextWidth(width - 2 * CONTENTS_BORDER_HORIZONTAL);
            height = _text_item->document()->size().height() + 2 * CONTENTS_BORDER_VERTICAL;
        }
    }

    // update sizes and positions
    double left = 0.0;
    double top = 0.0;

    setPos(getAnnotation()->getPos());

    QRectF rect(left, top, width, height);

    // the object is updated without calling DiagramController intentionally.
    // attribute rect is not a real attribute stored on DObject but
    // a backup for the graphics item used for manual resized and persistency.
    getAnnotation()->setRect(rect);

    if (_no_text_item) {
        _no_text_item->setRect(rect);
    }

    if (_text_item) {
        _text_item->setPos(left + CONTENTS_BORDER_HORIZONTAL, top + CONTENTS_BORDER_VERTICAL);
    }

    updateSelectionMarkerGeometry(rect);
}
Beispiel #3
0
void NativeResolverImpl::satisfyRelationExpression(const RelationExpression& re,
		bool invert, const string& proposedAnnotation, RequestImportance importance, bool asAutomatic)
{
	const string& annotation = !proposedAnnotation.empty() ? proposedAnnotation : getAnnotation(re, invert);
	p_userRelationExpressions.push_back({ re, invert, annotation, importance, asAutomatic });
	if (__config->getBool("debug::resolver"))
	{
		debug2("on request '%s' strictly %ssatisfying relation '%s'", annotation, (invert? "un" : ""), re.toString());
	}
}
bool isRanged( dp::util::PropertyId pid, const std::string & name, T & min, T & max )
{
  std::string range = getAnnotation( pid, name );
  if ( ! range.empty() )
  {
    std::istringstream iss( range );
    char comma;
    iss >> min >> comma >> max;
    return( true );
  }
bool Generator::isGameRecord() const
{
    if (context().self.kind != CXCursor_StructDecl)
        return false;
    if (getFile() != m_unitFile)
        return false;
    if (getAnnotation(context().self) == "cocos2d-x: do not serialize")
        return false;
    return true;
}
Beispiel #6
0
AIDA::Dev::IDevCloud1D * iAIDA::AIDA_XMLStore::Cloud1DTranslator::createFromXML(AIDA::Dev::IDevHistogramFactory& factory)
{ 
  // read header 
  std::string title,options = emptyString;
  getObjectHeader(m_element,m_name,title,m_path,options); 
  int nMax = -1; 
  toValue(m_element.getAttributeValue("maxEntries"), nMax);


  // read annotation
  AnnotationData annoData; 
  getAnnotation(m_element,annoData); 

  // Now I can create the cloud 

  AIDA::Dev::IDevCloud1D * cloud  = 
    factory.createCloud1D( title, nMax,options );

  if (!cloud) { 
    std::cerr << " AIDA_XMLStore::Cloud1DTranslator - Cannot create Cloud1D " << std::endl; 
    return 0; 
  }

  //no need to  get statistics since for AIDA 

  // set annotation
  AIDA::IAnnotation & anno = cloud->annotation(); 
  setAnnotation(&anno,annoData); 

  // get the data 
 
  const DataXML::DataObject * dataElement = m_element.getChild("entries1d");
  if (!dataElement) return cloud; 
  //int i = 0; 
  //cout << " Number of elements " << dataElement->children().size() << endl; 
  for (std::vector<DataXML::DataObject>::const_iterator entryElement = dataElement->children().begin(); entryElement != dataElement->children().end(); ++entryElement) {  
    // need to check on the name to eliminate white spaces
    if (entryElement->name() == "entry1d") { 
      double xval,yval,zval = 0;    
      double weight = 1; 
      getCloudEntryData(*entryElement,1,xval,yval,zval,weight);
      // fill the cloud with the contents 
      //cout << " entry " << entryElement->name() << " " << i << " x " << xval << " w " << weight << endl; 
      cloud->fill(xval,weight); 
      //i++;
    }
  }

  //  std::cout << " cloud entries = " << cloud->entries() << endl; 

  return cloud; 
}
QSizeF AnnotationItem::calcMinimumGeometry() const
{
    qreal width = MINIMUM_TEXT_WIDTH + 2 * CONTENTS_BORDER_HORIZONTAL;
    qreal height = 0.0; // irrelevant; cannot be modified by user and will always be overwritten

    if (getAnnotation()->hasAutoSize()) {
        if (_text_item) {
            _text_item->setTextWidth(-1);
            QSizeF text_size = _text_item->document()->size();
            width = text_size.width() + 2 * CONTENTS_BORDER_HORIZONTAL;
        }
    }
    return QSizeF(width, height);
}
/*
	This function tests for any annotation that can be used to
	control the visibility of a parameter:
*/
void CUniformParameterBuilder::updateUIVisibilityFromAnnotation()
{
	BOOL visible = TRUE;
	if( getBOOLAnnotation( dx11ShaderAnnotation::kSasUiVisible, visible))
	{
		mParam.setUIHidden(!visible);
	}
	else
	{
		LPCSTR uiTypeValue = NULL;
		bool  foundUIType = getAnnotation( dx11ShaderAnnotation::kUIType,uiTypeValue);
		if (foundUIType && !_stricmp(uiTypeValue, dx11ShaderAnnotationValue::kNone))
		{
			mParam.setUIHidden(true);
		}
		// As per NVidia SAS docs v1.0.3:
		foundUIType = getAnnotation( dx11ShaderAnnotation::kUIWidget,uiTypeValue);
		if (foundUIType && !_stricmp(uiTypeValue, dx11ShaderAnnotationValue::kNone))
		{
			mParam.setUIHidden(true);
		}
	}
}
Beispiel #9
0
bool UniPAX::SBase::getAttribute(std::vector<std::pair<std::string,std::string> >& value, PersistenceManager& manager) {

	if (!UniPAX::UIBase::getAttribute(value, manager))
		return false;
	{
		if (! getMetaId().empty())
			value.push_back(std::pair<std::string,std::string>("metaId", getMetaId()));
	}
	{
		if (!getSboTerm().empty())
			value.push_back(std::pair<std::string,std::string>("sboTerm", getSboTerm()));
	}
	{
		if (!getNotes().empty())
			value.push_back(std::pair<std::string,std::string>("notes", getNotes()));
	}
	{
		if (!getAnnotation().empty())
			value.push_back(std::pair<std::string,std::string>("annotation", getAnnotation()));
	}
	return true;

}
Beispiel #10
0
bool PlanEntryModel::operator ==(PlanEntryModel &tem)
{
	bool b = true;
	if(compareTo(&tem) != 0)b = false;
	else if(tem.getTaskID() != getTaskID())b = false;
	else if(tem.getTaskStart() != getTaskStart())b = false;
	else if(tem.getTaskStop() != getTaskStop())b = false;
	else if(tem.getPercentComplete() != getPercentComplete())b = false;
	else if(_tcscmp(tem.GetOwner(), GetOwner()) != 0)b = false;
	else if(_tcscmp(tem.getTaskName(), getTaskName()) != 0)b = false;
	else if(_tcscmp(tem.getAnnotation(), getAnnotation()) != 0)b = false;
	else if(GetEntryType() != tem.GetEntryType())b = false;
	return b;
}
Beispiel #11
0
 bool IsAutoloadEntry(Decl *D) {
   for(auto attr = D->specific_attr_begin<AnnotateAttr>(),
            end = D->specific_attr_end<AnnotateAttr> ();
       attr != end;
       ++attr)
   {
     //        cling::errs() << "Annotation: " << c->getAnnotation() << "\n";
     if (!attr->isInherited()) {
       llvm::StringRef annotation = attr->getAnnotation();
       assert(!annotation.empty() && "Empty annotation!");
       if (annotation.startswith(llvm::StringRef(annoTag, lenAnnoTag))) {
         // autoload annotation.
         return true;
       }
     }
   }
   return false;
 }
void AnnotationItem::update()
{
    QMT_CHECK(!_on_update);
    _on_update = true;

    prepareGeometryChange();

    const Style *style = getAdaptedStyle();

    // text
    if (!_text_item) {
        _text_item = new AnnotationTextItem(this);
        _text_item->setTextInteractionFlags(Qt::TextEditorInteraction);
        _text_item->installSceneEventFilter(this);
        QObject::connect(_text_item->document(), &QTextDocument::contentsChanged, _text_item,
                         [=]() { this->onContentsChanged(); } );
    }
    _text_item->setFont(style->getNormalFont());
    _text_item->setDefaultTextColor(style->getTextBrush().color());
    if (!_on_changed) {
        _text_item->setPlainText(getAnnotation()->getText());
    }

    // item shown if annotation has no text and is not selected
    if (!_no_text_item) {
        _no_text_item = new QGraphicsRectItem(this);
    }
    _no_text_item->setPen(QPen(QBrush(QColor(192, 192, 192)), 1, Qt::DashDotLine));
    _no_text_item->setVisible(!isSelected() && _text_item->document()->isEmpty());

    updateSelectionMarker();

    updateGeometry();

    setZValue(ANNOTATION_ITEMS_ZVALUE);

    _on_update = false;
}
//
// Convert a DX space into a Maya space
//
MUniformParameter::DataSemantic CUniformParameterBuilder::convertSpace( MUniformParameter::DataSemantic defaultSpace)
{
	MUniformParameter::DataSemantic space = MUniformParameter::kSemanticUnknown;

	LPCSTR ann;
	if( getAnnotation( dx11ShaderAnnotation::kSpace, ann) && ann)
	{
		if( !_stricmp( ann, dx11ShaderAnnotationValue::kObject))		space = defaultSpace >= MUniformParameter::kSemanticObjectPos ? MUniformParameter::kSemanticObjectPos	: MUniformParameter::kSemanticObjectDir;
		else if( !_stricmp( ann, dx11ShaderAnnotationValue::kWorld))	space = defaultSpace >= MUniformParameter::kSemanticObjectPos ? MUniformParameter::kSemanticWorldPos	: MUniformParameter::kSemanticWorldDir;
		else if( !_stricmp( ann, dx11ShaderAnnotationValue::kView))		space = defaultSpace >= MUniformParameter::kSemanticObjectPos ? MUniformParameter::kSemanticViewPos		: MUniformParameter::kSemanticViewDir;
		else if( !_stricmp( ann, dx11ShaderAnnotationValue::kCamera))	space = defaultSpace >= MUniformParameter::kSemanticObjectPos ? MUniformParameter::kSemanticViewPos		: MUniformParameter::kSemanticViewDir;
		else
		{
			MStringArray args;
			args.append(ann);
			args.append(mDesc.Name);

			mWarnings += dx11ShaderStrings::getString( dx11ShaderStrings::kUnknowSpace, args );
		}
	}

	return space;
}
std::string getDisplayName( dp::util::PropertyId pid, const std::string & propertyName )
{
  std::string displayName = getAnnotation( pid, "_anno_displayName" );
  return( displayName.empty() ? propertyName : displayName );
}
Beispiel #15
0
AIDA::Dev::IDevHistogram1D * iAIDA::AIDA_XMLStore::Histo1DTranslator::createFromXML(AIDA::Dev::IDevHistogramFactory& factory)
{ 
  // read header 
  std::string title, options;
  getObjectHeader(m_element,m_name,title,m_path,options); 

  // read annotation
  AnnotationData annoData; 
  getAnnotation(m_element,annoData); 

  // read axis
  int numberOfBins = 0;
  double lowerEdge = 0;
  double upperEdge = 0;
  std::vector<double> edges; 
  getAxis(m_element,"x",numberOfBins,lowerEdge,upperEdge,edges); 


  // Now I can create the histogram 

  AIDA::Dev::IDevHistogram1D * h = 0; 
  if (edges.empty()) 
    // equal bins histograms
    h = factory.createHistogram1D( title, numberOfBins, lowerEdge, upperEdge );
  else   
    // variable bins histograms 
    h = factory.createHistogram1D( title, edges, emptyString );

  //read statistics (rms is needed since no binRMs is stored) 
  double mean,rms,skew = 0; 
  const DataXML::DataObject * statElement = m_element.getChild("statistics");
  if (statElement)
    getStatistics(*statElement,"x",mean,rms,skew); 
  

  // set annotation
  AIDA::IAnnotation & anno = h->annotation(); 
  setAnnotation(&anno,annoData); 

  // get the data 
 
  const DataXML::DataObject * dataElement = m_element.getChild("data1d");
  if (dataElement) { 
    for (std::vector<DataXML::DataObject>::const_iterator binElement = dataElement->children().begin(); binElement != dataElement->children().end(); ++binElement) {  
      if (binElement->name() == "bin1d") { 
	int xbin = -999;    // just a number which is not used 
	int entries = 0;
	// get info (not all is used..) 
	double height, error, wRms, wMean, error2, rms = 0; 
	getHisto1DBinData(*binElement,xbin,entries,height,error,wMean,wRms,error2, rms); 
	// fill the histogram with the bin contents 
	// (if binMean(centre) is not defined calculate from binWidth 
	if (wMean == 0 && xbin >=0 ) { 
	  wMean = h->binMean(xbin);  // if histo is empty should return 1/2 value
	}
	h->setBinContents(xbin,entries, height, error, wMean); 
      }
    }
  }

  h->setRms(rms); 

  return h; 
}
MUniformParameter::DataType CUniformParameterBuilder::convertType()
{
	MUniformParameter::DataType		paramType = MUniformParameter::kTypeUnknown;

	switch( mDescType.Type) {

	case D3D10_SVT_BOOL:			paramType = MUniformParameter::kTypeBool;	break;
	case D3D10_SVT_INT:				paramType = MUniformParameter::kTypeInt;	break;
	case D3D10_SVT_FLOAT:			paramType = MUniformParameter::kTypeFloat;	break;
	case D3D10_SVT_STRING:			paramType = MUniformParameter::kTypeString;	break;
	case D3D10_SVT_UINT:			paramType = MUniformParameter::kTypeInt;	break;

	case D3D10_SVT_UINT8:
		logUnsupportedTypeWarning(dx11ShaderStrings::kTypeIntUInt8);
		break;
	case D3D11_SVT_DOUBLE:
		logUnsupportedTypeWarning(dx11ShaderStrings::kTypeDouble);
		break;

	case D3D11_SVT_RWTEXTURE1D:
	case D3D10_SVT_TEXTURE1D:			paramType = MUniformParameter::kType1DTexture;		break;
	case D3D11_SVT_RWTEXTURE2D:
	case D3D10_SVT_TEXTURE2D:			paramType = MUniformParameter::kType2DTexture;		break;
	case D3D11_SVT_RWTEXTURE3D:
	case D3D10_SVT_TEXTURE3D:			paramType = MUniformParameter::kType3DTexture;		break;
	case D3D10_SVT_TEXTURECUBE:			paramType = MUniformParameter::kTypeCubeTexture;	break;
	case D3D10_SVT_TEXTURE:
		{
			// The shader hasn't used a typed texture, so first see if there's an annotation
			// that tells us which type to use.
			// -------------------------------------
			LPCSTR	textureType;
			if( ( getAnnotation( dx11ShaderAnnotation::kTextureType, textureType) || getAnnotation( dx11ShaderAnnotation::kResourceType, textureType)) && textureType) {
				// Grab the type off from the annotation
				// -------------------------------------
				if( !_stricmp( textureType, dx11ShaderAnnotationValue::k1D)) paramType = MUniformParameter::kType1DTexture;
				else if( !_stricmp( textureType, dx11ShaderAnnotationValue::k2D)) paramType = MUniformParameter::kType2DTexture;
				else if( !_stricmp( textureType, dx11ShaderAnnotationValue::k3D)) paramType = MUniformParameter::kType3DTexture;
				else if( !_stricmp( textureType, dx11ShaderAnnotationValue::kCube)) paramType = MUniformParameter::kTypeCubeTexture;
				else {
					MStringArray args;
					args.append(textureType);
					args.append(mDesc.Name);

					mWarnings += dx11ShaderStrings::getString( dx11ShaderStrings::kUnknownTextureSemantic, args );
				}
			}

			if( paramType == MUniformParameter::kTypeUnknown) {
				// No explicit type. At this stage, it would be nice to take a look at the
				// sampler which uses the texture and grab the type of that, but I can't see
				// any way to query for the sampler -> texture bindings through the effect
				// API.
				//
				paramType = MUniformParameter::kType2DTexture;
				mWarnings += dx11ShaderStrings::getString( dx11ShaderStrings::kNoTextureType, mDesc.Name );
			}

			break;

		}
	case D3D10_SVT_TEXTURE1DARRAY:
	case D3D10_SVT_TEXTURE2DARRAY:
	case D3D10_SVT_TEXTURE2DMS:
	case D3D10_SVT_TEXTURE2DMSARRAY:
	case D3D10_SVT_TEXTURECUBEARRAY:
	case D3D11_SVT_RWTEXTURE1DARRAY:
	case D3D11_SVT_RWTEXTURE2DARRAY:
		logUnsupportedTypeWarning(dx11ShaderStrings::kTypeTextureArray);
		break;

	case D3D10_SVT_VOID:
	case D3D10_SVT_SAMPLER:
	case D3D10_SVT_PIXELSHADER:
	case D3D10_SVT_VERTEXSHADER:
	case D3D10_SVT_GEOMETRYSHADER:
	case D3D10_SVT_RASTERIZER:
	case D3D10_SVT_DEPTHSTENCIL:
	case D3D10_SVT_BLEND:
	case D3D10_SVT_BUFFER:
	case D3D10_SVT_CBUFFER:
	case D3D10_SVT_TBUFFER:
	case D3D11_SVT_HULLSHADER:
	case D3D11_SVT_DOMAINSHADER:
	case D3D11_SVT_INTERFACE_POINTER:
	case D3D11_SVT_COMPUTESHADER:
	case D3D11_SVT_BYTEADDRESS_BUFFER:
	case D3D11_SVT_RWBYTEADDRESS_BUFFER:
	case D3D11_SVT_STRUCTURED_BUFFER:
	case D3D11_SVT_RWSTRUCTURED_BUFFER:
	case D3D11_SVT_APPEND_STRUCTURED_BUFFER:
	case D3D11_SVT_CONSUME_STRUCTURED_BUFFER:
	case D3D10_SVT_RENDERTARGETVIEW:
	case D3D10_SVT_DEPTHSTENCILVIEW:
	case D3D11_SVT_RWBUFFER:
		// ignored variable definitions
		// ------------------------------
		break;

	default:
		break;
	}
	return paramType;
}
Beispiel #17
0
bool Object::appearsInFrame(const shared_ptr<Frame> frame) const {
  return getAnnotation(frame) != nullptr;
}
bool CUniformParameterBuilder::build()
{
	//assert(mEffectVariable);

	// building the uniform based on the type
	// ---------------------------------------
	MUniformParameter::DataType		type		= convertType    ();
	MUniformParameter::DataSemantic semantic	= convertSemantic();

	updateLightInfoFromSemantic();

	// If we don't know what this parameter is, and we've been told to hide it, do so
	// NOTE that for now, we only hide simple constants as hiding everything we're
	// told to hide actually starts hiding textures and things the artist wants to see.
	// ----------------------------------------------------------------------------------
	if (semantic == MUniformParameter::kSemanticUnknown && (type == MUniformParameter::kTypeFloat || type == MUniformParameter::kTypeString))
	{

		if (mDesc.Semantic && _stricmp(mDesc.Semantic, dx11ShaderSemantic::kSTANDARDSGLOBAL)==0)
		{
			return false;
		}
	}

	/*
		The UIGroup annotation is used to groups multiple parameters in a single
		collapsible panel in the attribute editor. This helps organize related
		parameters.

		- All parameters sharing the same UIGroup annotation string will group together
		- The name of the group, as shown as the header of the collapsible panel, will
		   be the value of the annotation
		- The order of the panels in the attribute editor will be sorted according to
			the parameter with the lowest UIOrder in that group
		- UIGroups win over UIOrder, this means all parameters will be grouped in a
			single panel even if there are non grouped parameters that have a UIOrder
			that falls within the range of UIOrders for parameters in that group
		- This commands lists all UIGroups: dx11Shader -listUIGroupInformation
		- This command lists all parameters for a group: dx11Shader -listUIGroupParameters <group>
	*/
	if (mUIGroupIndex == -1)
	{
		LPCSTR pszUIGroupName;
		if( getAnnotation( dx11ShaderAnnotation::kUIGroup, pszUIGroupName) && *pszUIGroupName)
		{
			MString uiGroupName(pszUIGroupName);
			mUIGroupIndex = mShader->getIndexForUIGroupName(uiGroupName, true);
		}
	}

	/*
		The name of the parameter in the attribute editor defaults to
		the name of the variable associated with the parameter. If there
		is a UIName attribute on the parameter, and the 'kVariableNameAsAttributeName'
		semantic is not set, this name will be used to
		define all three of the parameter short/long/nice name. If the
		UIName contains spaces or other script unfriendly characters,
		those will be replaced by underscores in the short and long names
		used in scripting.

		Using UIName as attribute name can lead to ambiguity since UIName annotations 
		are not required to be unique by the compiler. The MPxHardwareShader class
		will add numbers at the end of the short/long names as required to
		make them unique.
	*/
	LPCSTR paramName = NULL;

	bool varAsAttr = false;
	if (mShader)
		varAsAttr = mShader->getVariableNameAsAttributeName();

	LPCSTR uiName = NULL ;
	bool hasUIName = getAnnotation( dx11ShaderAnnotation::kUIName, uiName);

	if( varAsAttr || !hasUIName )
		paramName = mDesc.Name;
	else
		paramName = uiName;

	/*
		If an integer parameter has a UIFieldNames annotation, then the
		annotation contents will be used to populate a dropdown menu when the
		parameter is shown in the attribute editor. The parameter type is
		changed from integer to enum.
	*/
	LPCSTR uiFieldNames = NULL ;
	MString fieldNames;
	if(type == MUniformParameter::kTypeInt && getAnnotation(dx11ShaderAnnotation::kUIFieldNames,uiFieldNames) && uiFieldNames)
	{
		fieldNames = uiFieldNames;
		type = MUniformParameter::kTypeEnum;
	}

	MUniformParameter uniform( paramName, type, semantic, mDescType.Rows, mDescType.Columns, (void*)mEffectVariable);
	mParam = uniform;

	// If shader author has specified to use var as attribute name and provided a UIName, then
	// tell Maya to use the UIName for the attribute's 'Nice Name':
	if (varAsAttr && hasUIName)
		mParam.setUINiceName( uiName );

	updateRangeFromAnnotation();
	updateUIVisibilityFromAnnotation();
	if (fieldNames.length())
	{
		mParam.setEnumFieldNames(fieldNames);
	}

	/*
		The UIOrder annotation can be used to make sure all parameters
		appear in a predictable sequence in the attribute editors even
		if the compiler decides to reorder them is the input block.

		- The content of the annotation is an integer
		- Parameters will be sorted according to increasing values of
		  UIOrder annotation
		- The sort is stable, so parameters with identical UIOrder will
		  appear in the order the compiler outputs them (which is not as
		  stable as the sort)
	*/
	getAnnotation(dx11ShaderAnnotation::kUIOrder, mUIOrder);

	// set keyable for visible attributes other than textures
	mParam.setKeyable(!mParam.UIHidden() && !mParam.isATexture());

	bool result = setParameterValueFromEffect();
	if(result)
	{
		mValidUniformParameter = true;
	}

	return result;
}
/*
	Here we find light specific semantics on parameters. This will be used
	to properly transfer values from a Maya light to the effect. Parameters
	that have semantics that are not light-like will get the light type
	eNotALight and will not participate in light related code paths.

	We also try to detect the light type that best match this parameter based
	on a substring match for point/spot/directional/ambient strings. We can also
	deduce the light type from extremely specialized semantics like cone angle and
	falloff for a spot light or LP0 for an area light.

	We finally try to group light parameters together into a single logical light
	group using either an "Object" annotation or a substring of the parameter name.

	The light group name is one of:
		- The string value of the "Object" annotation
		- The prefix part of a parameter name that contains either "Light", "light",
		   or a number:
				DirectionalLightColor  ->   DirectionalLight
				scene_light_position   ->   scene_light
				Lamp0Color             ->   Lamp0

	- All light parameters that share a common light group name will be grouped together
		into a single logical light
	- When a logical light is bound to a scene light, all parameter values will be
		transferred in block from the scene light to the logical light
	- The Attribute Editor will show one extra control per logical light that will allow
		to quickly specify how this logical light should be handled by Maya. Options are
		to explicitely bind a scene light, allow automatic binding to any compatible scene
		light, or ignore scene lights and use values stored in the effect parameters.
	- The Attribute Editor will also group all light parameters in separate panels as if
		they were grouped using the UIGroup annotation. See comments on UIGroup annotation
		for more details.
*/
void CUniformParameterBuilder::updateLightInfoFromSemantic()
{
	//Check for light type from object type
	LPCSTR objectType;
	if( getAnnotation( dx11ShaderAnnotation::kObject, objectType) && *objectType)
	{
		MString objectAnnotation(objectType);
		mLightIndex = mShader->getIndexForLightName(objectAnnotation, true);
		mUIGroupIndex = mShader->getIndexForUIGroupName(objectAnnotation, true);
		if(objectAnnotation.rindexW(dx11ShaderAnnotationValue::kLight) >= 0 || objectAnnotation.rindexW(dx11ShaderAnnotationValue::kLamp) >= 0)
		{
			mLightType = eUndefinedLight;
			if(objectAnnotation.rindexW(dx11ShaderAnnotationValue::kPoint) >= 0)
			{
				mLightType = ePointLight;
			}
			else if(objectAnnotation.rindexW(dx11ShaderAnnotationValue::kSpot) >= 0)
			{
				mLightType = eSpotLight;
			}
			else if(objectAnnotation.rindexW(dx11ShaderAnnotationValue::kDirectional) >= 0)
			{
				mLightType = eDirectionalLight;
			}
			else if(objectAnnotation.rindexW(dx11ShaderAnnotationValue::kAmbient) >= 0)
			{
				mLightType = eAmbientLight;
			}
		}
	}

	if( mDesc.Semantic)
	{
		MString name( mDesc.Name);

		if( !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kLightColor))
		{
			mParamType = eLightColor;
		}
		if( !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kLightEnable))
		{
			mParamType = eLightEnable;
		}
		else if( !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kLightIntensity))
		{
			mParamType = eLightIntensity;
		}
		else if( !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kLightFalloff) ||
			     !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kFalloff))
		{
			mLightType = eSpotLight;
			mParamType = eLightFalloff;
		}
		else if (!_stricmp( mDesc.Semantic, dx11ShaderSemantic::kLightDiffuseColor))
		{
			mParamType = eLightDiffuseColor;
		}
		else if (!_stricmp( mDesc.Semantic, dx11ShaderSemantic::kLightAmbientColor))
		{
			mParamType = eLightAmbientColor;
			mLightType = eAmbientLight;
		}
		else if (!_stricmp( mDesc.Semantic, dx11ShaderSemantic::kLightSpecularColor))
		{
			mParamType = eLightSpecularColor;
		}
		else if (!_stricmp( mDesc.Semantic, dx11ShaderSemantic::kShadowMap))
		{
			mParamType = eLightShadowMap;
		}
		else if (!_stricmp( mDesc.Semantic, dx11ShaderSemantic::kShadowMapBias))
		{
			mParamType = eLightShadowMapBias;
		}
		else if (!_stricmp( mDesc.Semantic, dx11ShaderSemantic::kShadowFlag))
		{
			mParamType = eLightShadowOn;
		}
		else if (!_stricmp( mDesc.Semantic, dx11ShaderSemantic::kShadowMapMatrix) ||
			     !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kShadowMapXForm))
		{
			//View transformation matrix of the light
			mParamType = eLightShadowViewProj;
		}
		else if (!_stricmp( mDesc.Semantic, dx11ShaderSemantic::kShadowColor))
		{
			mParamType = eLightShadowColor;
		}
		else if (!_stricmp( mDesc.Semantic, dx11ShaderSemantic::kHotspot))
		{
			mParamType = eLightHotspot;
			mLightType = eSpotLight;
		}
		else if (!_stricmp( mDesc.Semantic, dx11ShaderSemantic::kLightType))
		{
			mParamType = eLightType;
		}
		else if (!_stricmp( mDesc.Semantic, dx11ShaderSemantic::kDecayRate))
		{
			mParamType = eDecayRate;
		}
		else
		{
			bool isLight = (mLightType != eNotLight || findSubstring(name, MString(dx11ShaderAnnotationValue::kLight)) >= 0);
			if(isLight)
			{
				if( !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kPosition))
				{
					mParamType = eLightPosition;
				}
				else if( !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kAreaPosition0))
				{
					mParamType = eLightAreaPosition0;
					mLightType = eAreaLight;
				}
				else if( !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kAreaPosition1))
				{
					mParamType = eLightAreaPosition1;
					mLightType = eAreaLight;
				}
				else if( !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kAreaPosition2))
				{
					mParamType = eLightAreaPosition2;
					mLightType = eAreaLight;
				}
				else if( !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kAreaPosition3))
				{
					mParamType = eLightAreaPosition3;
					mLightType = eAreaLight;
				}
				else if( !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kDirection))
				{
					mParamType = eLightDirection;
				}
				else if( !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kColor))
				{
					//
					mParamType = eLightColor;
				}
				else if( !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kAmbient))
				{
					mParamType = eLightAmbientColor;
					mLightType = eAmbientLight;
				}
				else if( !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kDiffuse))
				{
					mParamType = eLightDiffuseColor;
				}
				else if( !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kSpecular))
				{
					mParamType = eLightSpecularColor;
				}
			}
		}

		//Compute light index
		if(mParamType != eUndefined && mLightIndex ==  -1)
		{
			//Check object semantic for index
			//Check name for index
			if(mLightType == eNotLight)
			{
				mLightType = eUndefinedLight;
			}

			const char* objectName = name.asChar();
			int truncationPos = -1;

			int lightPos = findSubstring(name, MString(dx11ShaderAnnotationValue::kLight));
			if (lightPos >= 0)
				truncationPos = lightPos + 5;

			if(truncationPos < 0)
			{
				// last effort, see if there is any digit in the parameter name:
				unsigned int digitPos = 0;
				for ( ; digitPos < name.numChars(); ++digitPos)
					if ( isdigit(objectName[digitPos]) )
						break;
				if ( digitPos < name.numChars() )
					truncationPos = digitPos;
			}
			if (truncationPos >= 0)
			{
				// Need to also skip any digits found after the "light"
				int maxChars = int(name.numChars());
				while (truncationPos < maxChars && isdigit(objectName[truncationPos]))
					truncationPos++;

				mLightIndex = mShader->getIndexForLightName(name.substring(0,truncationPos-1), true);
				mUIGroupIndex = mShader->getIndexForUIGroupName(name.substring(0,truncationPos-1), true);
			}
		}

	}
}
//
// Convert a DX semantic into a Maya semantic
//
MUniformParameter::DataSemantic CUniformParameterBuilder::convertSemantic( )
{
	MUniformParameter::DataSemantic paramSemantic = MUniformParameter::kSemanticUnknown;


	// @@@@ maybe useful to validate
	// MHWRender::MShaderManager::isSupportedShaderSemantic( semantic );
	// Convert all semantics to lower case for faster
	// mtype = MHWRender::MFrameContext::semanticToMatrixType( semantic, &status );

	// First try the explicit semantic
	if( mDesc.Semantic)
	{
		if(	     !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kWorld))								paramSemantic = MUniformParameter::kSemanticWorldMatrix;
		else if( !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kWorldTranspose))						paramSemantic = MUniformParameter::kSemanticWorldTransposeMatrix;
		else if( !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kWorldInverse))							paramSemantic = MUniformParameter::kSemanticWorldInverseMatrix;
		else if( !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kWorldInverseTranspose))				paramSemantic = MUniformParameter::kSemanticWorldInverseTransposeMatrix;

		else if( !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kView))									paramSemantic = MUniformParameter::kSemanticViewMatrix;
		else if( !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kViewTranspose))						paramSemantic = MUniformParameter::kSemanticViewTransposeMatrix;
		else if( !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kViewInverse))							paramSemantic = MUniformParameter::kSemanticViewInverseMatrix;
		else if( !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kViewInverseTranspose))					paramSemantic = MUniformParameter::kSemanticViewInverseTransposeMatrix;

		else if( !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kProjection))							paramSemantic = MUniformParameter::kSemanticProjectionMatrix;
		else if( !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kProjectionTranspose))					paramSemantic = MUniformParameter::kSemanticProjectionTransposeMatrix;
		else if( !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kProjectionInverse))					paramSemantic = MUniformParameter::kSemanticProjectionInverseMatrix;
		else if( !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kProjectionInverseTranspose))			paramSemantic = MUniformParameter::kSemanticProjectionInverseTransposeMatrix;

		else if( !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kWorldView))							paramSemantic = MUniformParameter::kSemanticWorldViewMatrix;
		else if( !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kWorldViewTranspose))					paramSemantic = MUniformParameter::kSemanticWorldViewTransposeMatrix;
		else if( !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kWorldViewInverse))						paramSemantic = MUniformParameter::kSemanticWorldViewInverseMatrix;
		else if( !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kWorldViewInverseTranspose))			paramSemantic = MUniformParameter::kSemanticWorldViewInverseTransposeMatrix;

		else if( !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kViewProjection))						paramSemantic = MUniformParameter::kSemanticViewProjectionMatrix;
		else if( !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kViewProjectionTranspose))				paramSemantic = MUniformParameter::kSemanticViewProjectionTransposeMatrix;
		else if( !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kViewProjectionInverse))				paramSemantic = MUniformParameter::kSemanticViewProjectionInverseMatrix;
		else if( !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kViewProjectionInverseTranspose))		paramSemantic = MUniformParameter::kSemanticViewProjectionInverseTransposeMatrix;

		else if( !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kWorldViewProjection))					paramSemantic = MUniformParameter::kSemanticWorldViewProjectionMatrix;
		else if( !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kWorldViewProjectionTranspose))			paramSemantic = MUniformParameter::kSemanticWorldViewProjectionTransposeMatrix;
		else if( !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kWorldViewProjectionInverse))			paramSemantic = MUniformParameter::kSemanticWorldViewProjectionInverseMatrix;
		else if( !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kWorldViewProjectionInverseTranspose))	paramSemantic = MUniformParameter::kSemanticWorldViewProjectionInverseTransposeMatrix;

		else if( !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kViewDirection))						paramSemantic = MUniformParameter::kSemanticViewDir;
		else if( !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kViewPosition))							paramSemantic = MUniformParameter::kSemanticViewPos;
		else if( !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kLocalViewer))							paramSemantic = MUniformParameter::kSemanticLocalViewer;

		else if( !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kViewportPixelSize))					paramSemantic = MUniformParameter::kSemanticViewportPixelSize;
		else if( !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kBackgroundColor))						paramSemantic = MUniformParameter::kSemanticBackgroundColor;

		else if( !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kFrame))								paramSemantic = MUniformParameter::kSemanticFrameNumber;
		else if( !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kFrameNumber))							paramSemantic = MUniformParameter::kSemanticFrameNumber;
		else if( !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kAnimationTime))						paramSemantic = MUniformParameter::kSemanticTime;
		else if( !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kTime))									paramSemantic = MUniformParameter::kSemanticTime;

		else if( !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kColor))								paramSemantic = MUniformParameter::kSemanticColor;
		else if( !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kLightColor))							paramSemantic = MUniformParameter::kSemanticColor;
		else if( !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kAmbient))								paramSemantic = MUniformParameter::kSemanticColor;
		else if( !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kLightAmbientColor))					paramSemantic = MUniformParameter::kSemanticColor;
		else if( !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kSpecular))								paramSemantic = MUniformParameter::kSemanticColor;
		else if( !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kLightSpecularColor))					paramSemantic = MUniformParameter::kSemanticColor;
		else if( !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kDiffuse))								paramSemantic = MUniformParameter::kSemanticColor;
		else if( !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kNormal))								paramSemantic = MUniformParameter::kSemanticNormal;
		else if( !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kBump))									paramSemantic = MUniformParameter::kSemanticBump;
		else if( !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kEnvironment))							paramSemantic = MUniformParameter::kSemanticEnvironment;

		else if( !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kPosition))								paramSemantic = convertSpace( MUniformParameter::kSemanticWorldPos);
		else if( !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kAreaPosition0))						paramSemantic = convertSpace( MUniformParameter::kSemanticWorldPos);
		else if( !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kAreaPosition1))						paramSemantic = convertSpace( MUniformParameter::kSemanticWorldPos);
		else if( !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kAreaPosition2))						paramSemantic = convertSpace( MUniformParameter::kSemanticWorldPos);
		else if( !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kAreaPosition3))						paramSemantic = convertSpace( MUniformParameter::kSemanticWorldPos);
		else if( !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kDirection))							paramSemantic = convertSpace( MUniformParameter::kSemanticViewDir);

		else if( !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kShadowMap))							paramSemantic = MUniformParameter::kSemanticColorTexture;
		else if( !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kShadowColor))							paramSemantic = MUniformParameter::kSemanticColor;
		else if( !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kShadowFlag))							paramSemantic = MUniformParameter::kSemanticUnknown;
		else if( !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kShadowMapBias))						paramSemantic = MUniformParameter::kSemanticUnknown;
		else if( !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kShadowMapMatrix))						paramSemantic = MUniformParameter::kSemanticUnknown;
		else if( !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kShadowMapXForm))						paramSemantic = MUniformParameter::kSemanticUnknown;
		else if( !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kStandardsGlobal))						paramSemantic = MUniformParameter::kSemanticUnknown;

		else if( !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kTranspDepthTexture))					paramSemantic = MUniformParameter::kSemanticTranspDepthTexture;
		else if( !_stricmp( mDesc.Semantic, dx11ShaderSemantic::kOpaqueDepthTexture))					paramSemantic = MUniformParameter::kSemanticOpaqueDepthTexture;

		else
		{
			logUnrecognisedSemantic(mDesc.Semantic);
		}
	}

	// Next, try annotation semantic
	if( paramSemantic == MUniformParameter::kSemanticUnknown)
	{
		LPCSTR sasSemantic;
		if( getAnnotation( dx11ShaderAnnotation::kSasBindAddress, sasSemantic) && sasSemantic && *sasSemantic)
		{
			MString str( sasSemantic);
			if(      !_stricmp( sasSemantic, dx11ShaderAnnotationValue::kSas_Skeleton_MeshToJointToWorld_0_))	paramSemantic = MUniformParameter::kSemanticWorldMatrix;
			else if( !_stricmp( sasSemantic, dx11ShaderAnnotationValue::kSas_Camera_WorldToView))				paramSemantic = MUniformParameter::kSemanticViewMatrix;
			else if( !_stricmp( sasSemantic, dx11ShaderAnnotationValue::kSas_Camera_Projection))				paramSemantic = MUniformParameter::kSemanticProjectionMatrix;
			else if( !_stricmp( sasSemantic, dx11ShaderAnnotationValue::kSas_Time_Now))							paramSemantic = MUniformParameter::kSemanticTime;
			else if( str.rindexW( dx11ShaderAnnotationValue::k_Position) >= 0)									paramSemantic = convertSpace( MUniformParameter::kSemanticWorldPos);
			else if( str.rindexW( dx11ShaderAnnotationValue::k_Direction) >= 0 &&
					 str.rindexW( dx11ShaderAnnotationValue::k_Direction) != str.rindexW( dx11ShaderAnnotationValue::k_Directional))	paramSemantic = convertSpace( MUniformParameter::kSemanticViewDir);
			else
			{
				logUnrecognisedSemantic(sasSemantic);
			}
		}
	}

	// Next try control type
	if( paramSemantic == MUniformParameter::kSemanticUnknown)
	{
		LPCSTR sasSemantic;
		if( (getAnnotation( dx11ShaderAnnotation::kSasUiControl, sasSemantic) || getAnnotation( dx11ShaderAnnotation::kUIWidget, sasSemantic)) && *sasSemantic)
		{
			if( !_stricmp( sasSemantic, dx11ShaderAnnotationValue::kColorPicker))							paramSemantic = MUniformParameter::kSemanticColor;
		}
	}

	// As a last ditch effort, look for an obvious parameter name
	if( paramSemantic == MUniformParameter::kSemanticUnknown && !mDesc.Semantic &&
		mDescType.Class == D3D_SVC_VECTOR && (mDescType.Type == D3D_SVT_FLOAT || mDescType.Type == D3D_SVT_DOUBLE) &&
		mDescType.Rows == 1 && mDescType.Columns >= 3 && mDescType.Columns <= 4 )
	{
		MString name( mDesc.Name);
		if(      name.rindexW( dx11ShaderAnnotationValue::kPosition) >= 0)								paramSemantic = convertSpace( MUniformParameter::kSemanticWorldPos);
		else if( name.rindexW( dx11ShaderAnnotationValue::kDirection) >= 0 &&
				 name.rindexW( dx11ShaderAnnotationValue::kDirection) != name.rindexW( dx11ShaderAnnotationValue::kDirectional))	paramSemantic = convertSpace(  MUniformParameter::kSemanticWorldDir);
		else if( name.rindexW( dx11ShaderAnnotationValue::kColor) >= 0 ||
				 name.rindexW( dx11ShaderAnnotationValue::kColour) >= 0 ||
				 name.rindexW( dx11ShaderAnnotationValue::kDiffuse) >= 0 ||
				 name.rindexW( dx11ShaderAnnotationValue::kSpecular) >= 0 ||
				 name.rindexW( dx11ShaderAnnotationValue::kAmbient) >= 0)								paramSemantic = MUniformParameter::kSemanticColor;
	}

	return paramSemantic;
}
Beispiel #21
0
QByteArray LovdUploadFile::create(QString sample, QString gender, QString gene, const Phenotype& pheno, const VariantList& vl, const Variant& variant)
{
    QByteArray output;
    QTextStream stream(&output);

    //create header part
    QString lab = getSettings("lovd_lab");
    QString user_name = getSettings("lovd_user_name");
    QString user_email = getSettings("lovd_user_email");
    QString user_id = getSettings("lovd_user_id");
    QString user_auth_token = getSettings("lovd_user_auth_token");

    stream << "{\n";
    stream << "    \"lsdb\": {\n";
    stream << "        \"@id\": \"53786324d4c6cf1d33a3e594a92591aa\",\n";
    stream << "        \"@uri\": \"http://databases.lovd.nl/shared/\",\n";
    stream << "        \"source\": {\n";
    stream << "            \"name\": \"" << lab << "\",\n";
    stream << "            \"contact\": {\n";
    stream << "                \"name\": \"" << user_name << "\",\n";
    stream << "                \"email\": \"" << user_email << "\",\n";
    stream << "                \"db_xref\": [\n";
    stream << "                    {\n";
    stream << "                        \"@source\": \"lovd\",\n";
    stream << "                        \"@accession\": \"" << user_id << "\"\n";
    stream << "                    },\n";
    stream << "                    {\n";
    stream << "                        \"@source\": \"lovd_auth_token\",\n";
    stream << "                        \"@accession\": \"" << user_auth_token << "\"\n";
    stream << "                    }\n";
    stream << "                ]\n";
    stream << "            }\n";
    stream << "        },\n";

    //create patient part
    stream << "        \"individual\": [\n";
    stream << "            {\n";
    stream << "                \"@id\": \"" << sample << "\",\n";
    stream << "                \"gender\": {\n";
    stream << "                    \"@code\": \"" << convertGender(gender) <<"\"\n";
    stream << "                },\n";
    stream << "                \"phenotype\": [\n"; //TODO support several phenotypes?
    stream << "                    {\n";
    stream << "                        \"@term\": \"" << pheno.name() << "\",\n";
    stream << "                        \"@source\": \"HPO\",\n";
    stream << "                        \"@accession\": \"" << pheno.accession().mid(3) << "\"\n";
    stream << "                    }\n";
    stream << "                ],\n";

    //general variant info
    QString genotype = getAnnotation(vl, variant, "genotype");
    QString classification = getAnnotation(vl, variant, "classification");
    stream << "                \"variant\": [\n";
    stream << "                    {\n";
    stream << "                        \"@copy_count\": \"" << convertGenotype(genotype) << "\",\n";
    stream << "                        \"@type\": \"DNA\",\n";
    stream << "                        \"ref_seq\": {\n";
    stream << "                            \"@source\": \"genbank\",\n";
    stream << "                            \"@accession\": \"" << chromosomeToAccession(variant.chr()) << "\"\n"; //official identifier for hg19
    stream << "                        },\n";
    stream << "                        \"name\": {\n";
    stream << "                            \"@scheme\": \"HGVS\",\n";
    FastaFileIndex idx(Settings::string("reference_genome"));
    stream << "                            \"#text\": \"" << variant.toHGVS(idx) << "\"\n";
    stream << "                        },\n";
    stream << "                        \"pathogenicity\": {\n";
    stream << "                            \"@scope\": \"individual\",\n";
    stream << "                            \"@term\": \"" << convertClassification(classification) << "\"\n";
    stream << "                        },\n";
    stream << "                        \"variant_detection\": [\n";
    stream << "                            {\n";
    stream << "                                \"@template\": \"DNA\",\n";
    stream << "                                \"@technique\": \"SEQ\"\n";
    stream << "                            }\n";
    stream << "                        ],\n";
    stream << "                        \"seq_changes\": {\n";
    stream << "                            \"variant\": [\n";

    QStringList transcripts = getAnnotation(vl, variant, "coding_and_splicing").split(',');
    foreach(QString transcript, transcripts)
    {
        if (!transcript.startsWith(gene + ":")) continue;
        QStringList parts = transcript.split(":");
        if (parts.count()<7)
        {
            THROW(ProgrammingException, "SnpEff ANN transcript has less than 7 parts: " + transcript);
        }
        QString nm_number = parts[1];
        QString hgvs_c = parts[5];
        QString hgvs_r = "r.(?)";
        QString hgvs_p = parts[6];
        stream << "                                {\n";
        stream << "                                    \"@type\": \"cDNA\",\n";
        stream << "                                    \"gene\": {\n";
        stream << "                                        \"@source\": \"HGNC\",\n";
        stream << "                                        \"@accession\": \"" << gene << "\"\n";
        stream << "                                    },\n";
        stream << "                                    \"ref_seq\": {\n";
        stream << "                                        \"@source\": \"genbank\",\n";
        stream << "                                        \"@accession\": \"" << nm_number << "\"\n";
        stream << "                                    },\n";
        stream << "                                    \"name\": {\n";
        stream << "                                        \"@scheme\": \"HGVS\",\n";
        stream << "                                        \"#text\": \"" << hgvs_c << "\"\n";
        stream << "                                    },\n";
        stream << "                                    \"seq_changes\": {\n";
        stream << "                                        \"variant\": [\n";
        stream << "                                            {\n";
        stream << "                                                \"@type\": \"RNA\",\n";
        stream << "                                                \"name\": {\n";
        stream << "                                                    \"@scheme\": \"HGVS\",\n";
        stream << "                                                    \"#text\": \"" << hgvs_r << "\"\n";
        stream << "                                                }";
        if (hgvs_p=="")
        {
            stream << "\n";
        }
        else
        {
            stream << ",\n";
            stream << "                                                \"seq_changes\": {\n";
            stream << "                                                    \"variant\": [\n";
            stream << "                                                        {\n";
            stream << "                                                            \"@type\": \"AA\",\n";
            stream << "                                                            \"name\": {\n";
            stream << "                                                                \"@scheme\": \"HGVS\",\n";
            stream << "                                                                \"#text\": \"" << hgvs_p << "\"\n";
            stream << "                                                            }\n";
            stream << "                                                        }\n";
            stream << "                                                    ]\n";
            stream << "                                                }\n";
        }
        stream << "                                            }\n";
        stream << "                                        ]\n";
        stream << "                                    }\n";
        stream << "                                }";
        if (transcript!=transcripts.last())
        {
            stream << ",";
        }
        stream << "\n";
    }

    //close all brackets
    stream << "                            ]\n";
    stream << "                        }\n";
    stream << "                    }\n";
    stream << "                ]\n";
    stream << "            }\n";
    stream << "        ]\n";
    stream << "    }\n";
    stream << "}\n";
    stream << "\n";

    return output;
}
Beispiel #22
0
shared_ptr<Annotation> Object::getAnnotation(shared_ptr<Frame> frame) const {
  return getAnnotation(frame->getFrameNumber());
}
/*
	These annotations can be used to control the numeric range of
	a slider. The hard min/max are defined as per documented standards,
	and we introduced the soft min/max notion to match the normal
	behavior of Maya attributes. A slider range will be limited to
	values between min and max, but the initial slider displayed in the
	UI will go from soft min to soft max.
*/
void CUniformParameterBuilder::updateRangeFromAnnotation()
{
	switch(mParam.type())
	{
	case MUniformParameter::kTypeFloat:
	case MUniformParameter::kTypeInt:
		{
			float uiMinFloat = NULL;
			if(getAnnotation( dx11ShaderAnnotation::kSasUiMin,uiMinFloat) ||
			   getAnnotation( dx11ShaderAnnotation::kUIMin,uiMinFloat) ||
			   getAnnotation( dx11ShaderAnnotation::kuimin,uiMinFloat) )
			{
				mParam.setRangeMin(uiMinFloat);
			}

			float uiMaxFloat = NULL;
			if(getAnnotation( dx11ShaderAnnotation::kSasUiMax,uiMaxFloat) ||
			   getAnnotation( dx11ShaderAnnotation::kUIMax,uiMaxFloat) ||
			   getAnnotation( dx11ShaderAnnotation::kuimax,uiMaxFloat) )
			{
				mParam.setRangeMax(uiMaxFloat);
			}

			float uiSoftMinFloat = NULL;
			if(getAnnotation( dx11ShaderAnnotation::kSasUiSoftMin,uiSoftMinFloat) ||
			   getAnnotation( dx11ShaderAnnotation::kUISoftMin,uiSoftMinFloat) ||
			   getAnnotation( dx11ShaderAnnotation::kuisoftmin,uiSoftMinFloat) )
			{
				mParam.setSoftRangeMin(uiSoftMinFloat);
			}

			float uiSoftMaxFloat = NULL;
			if(getAnnotation( dx11ShaderAnnotation::kSasUiSoftMax,uiSoftMaxFloat) ||
			   getAnnotation( dx11ShaderAnnotation::kUISoftMax,uiSoftMaxFloat) ||
			   getAnnotation( dx11ShaderAnnotation::kuisoftmax,uiSoftMaxFloat) )
			{
				mParam.setSoftRangeMax(uiSoftMaxFloat);
			}
		}
		break;
	default:
		break;
	};

}
std::string Generator::getAnnotation() const
{
    return getAnnotation(context().self);
}
Beispiel #25
0
static void GUINewMode(void)
{
  int Max, Sel, Dis;
  char* buffer;
  char* arg1 = getRecord();
  char* arg2 = getAuthor();
  char* arg3 = getCopyright();
  char* arg4 = getDriver();
  char* arg5 = getVersion();
  char* arg6 = getAnnotation();

  buffer = AllocVec( strlen( arg1 ) +
                     strlen( arg2 ) +
                     strlen( arg3 ) +
                     strlen( arg4 ) +
                     strlen( arg5 ) +
                     strlen( arg6 ) +
                     128,
                     MEMF_ANY);

  if( buffer != NULL )
  {
    sprintf( buffer,"0x%08lx\n%s\n%s\n%s\nDevs:AHI/%s.audio\n%s\n%s",
      getAudioMode(),
      arg1,
      arg2,
      arg3,
      arg4,
      arg5,
      arg6 );

    set(MUIInfos, MUIA_Text_Contents, (ULONG) buffer);

    FreeVec(buffer);
  }

  Max = max(state.Frequencies -1, 0);
  Sel = min(Max, state.FreqSelected);
  Dis = Max==0;
  set(MUIFreq, MUIA_Disabled, Dis);
  if( !Dis )
  {
    set(MUIFreq, MUIA_Numeric_Max, Max);
    set(MUIFreq, MUIA_Numeric_Value, Sel);
  }
  set(MUILFreq, MUIA_Text_Contents, (ULONG) getFreq());

  Max = max(state.Channels, 0);
  Sel = min(Max, state.ChannelsSelected);
  Dis = (Max == 0 || Max == 1) || state.ChannelsDisabled;
  set(MUIChannels, MUIA_Disabled, Dis);
  if( !Dis )
  {
    set(MUIChannels, MUIA_Numeric_Max, Max);
    set(MUIChannels, MUIA_Numeric_Value, Sel);
  }
  set(MUILChannels, MUIA_Text_Contents, (ULONG) getChannels());

  Max = max(state.OutVols -1, 0);
  Sel = min(Max, state.OutVolSelected);
  Dis = Max==0;
  set(MUIOutvol, MUIA_Disabled, Dis);
  if( !Dis )
  {
    set(MUIOutvol, MUIA_Numeric_Max, Max);
    set(MUIOutvol, MUIA_Numeric_Value, Sel);
  }
  set(MUILOutvol, MUIA_Text_Contents, (ULONG) getOutVol());

  Max = max(state.MonVols -1, 0);
  Sel = min(Max, state.MonVolSelected);
  Dis = Max==0;
  set(MUIMonvol, MUIA_Disabled, Dis);
  if( !Dis )
  {
    set(MUIMonvol, MUIA_Numeric_Max, Max);
    set(MUIMonvol, MUIA_Numeric_Value, Sel);
  }
  set(MUILMonvol, MUIA_Text_Contents, (ULONG) getMonVol());

  Max = max(state.Gains -1, 0);
  Sel = min(Max, state.GainSelected);
  Dis = Max==0;
  set(MUIGain, MUIA_Disabled, Dis);
  if( !Dis )
  {
    set(MUIGain, MUIA_Numeric_Max, Max);
    set(MUIGain, MUIA_Numeric_Value, Sel);
  }
  set(MUILGain, MUIA_Text_Contents, (ULONG) getGain());

  Max = max(state.Inputs -1, 0);
  Sel = min(Max, state.InputSelected);
  Dis = Max==0;
  set(MUIInput, MUIA_Disabled, Dis);
  if( !Dis )
  {
    set(MUIInput, MUIA_Numeric_Max, Max);
    set(MUIInput, MUIA_Numeric_Value, Sel);
  }
  set(MUILInput, MUIA_Text_Contents, (ULONG) getInput());

  Max = max(state.Outputs -1, 0);
  Sel = min(Max, state.OutputSelected);
  Dis = Max==0;
  set(MUIOutput, MUIA_Disabled, Dis);
  if( !Dis )
  {
    set(MUIOutput, MUIA_Numeric_Max, Max);
    set(MUIOutput, MUIA_Numeric_Value, Sel);
  }
  set(MUILOutput, MUIA_Text_Contents, (ULONG) getOutput());


  set(MUIPlay, MUIA_Disabled, getAudioMode() == AHI_INVALID_ID);
}
Beispiel #26
0
JObject JClass::getAnnotation(QString className)
{
	JClass ann(className);
	return getAnnotation(ann);
}
/*
	Here we retrieve the initial value for an effect parameter.
	This value will be set as the default value of the corresponding
	uniform parameter attribute and can be used to test if the
	current value of a parameter is different from the default or
	not.
*/
bool CUniformParameterBuilder::setParameterValueFromEffect()
{
	int length = getLength();
	MUniformParameter::DataType type = mParam.type();
	switch( type )
	{
	case MUniformParameter::kTypeFloat:
		{
			std::vector<FLOAT> values;
			values.resize(length);
			FLOAT* Value = &values[0];
			switch(mDescType.Class)
			{
			case D3D10_SVC_SCALAR:
				mEffectVariable->AsScalar()->GetFloat( Value );
				break;
			case D3D10_SVC_VECTOR:
				mEffectVariable->AsVector()->GetFloatVector( Value );
				break;
			case D3D10_SVC_MATRIX_COLUMNS:
				mEffectVariable->AsMatrix()->GetMatrix( Value );
				break;
			case D3D10_SVC_MATRIX_ROWS:
				mEffectVariable->AsMatrix()->GetMatrixTranspose( Value );
				break;
			default:
				return false;
			};

			mParam.setAsFloatArray( Value, length);
		}
		break;
	case MUniformParameter::kTypeString:
		{
			if (length==1)
			{
				LPCSTR Value;
				if( mEffectVariable->AsString()->GetString( &Value) == S_OK)
				{
					mParam.setAsString( MString( Value));
				}
			}
			else
			{
				logUnsupportedTypeWarning(dx11ShaderStrings::kTypeStringVector);
				return false;
			}
		}
		break;
	case MUniformParameter::kTypeBool:
		{
			if (length==1)
			{
#if _MSC_VER < 1700
				BOOL Value;
#else
				bool Value;
#endif
				if( mEffectVariable->AsScalar()->GetBool( &Value) == S_OK)
				{
					mParam.setAsBool( Value ? true : false);
				}
			}
			else
			{
				logUnsupportedTypeWarning(dx11ShaderStrings::kTypeBoolVector);
				return false;
			}
		}
		break;
	case MUniformParameter::kTypeInt:
	case MUniformParameter::kTypeEnum:
		{
			if (length==1)
			{
				INT Value;
				if( mEffectVariable->AsScalar()->GetInt( &Value) == S_OK)
				{
					mParam.setAsInt( Value);
				}
			}
			else
			{
				logUnsupportedTypeWarning(dx11ShaderStrings::kTypeIntVector);
				return false;
			}
		}
		break;
	default:
		if( type >= MUniformParameter::kType1DTexture && type <= MUniformParameter::kTypeEnvTexture)
		{
			// We have a texture name but no resource view. Try and load in
			// a new texture and get a new resource view.
			MString textureFile;
			LPCSTR resource;
			MString paramName = mParam.name();
			if( mShader->getTextureFile( paramName, textureFile ) )
			{
				mParam.setAsString( textureFile );
			}
			else if( getAnnotation( dx11ShaderAnnotation::kResourceName, resource) && *resource)
			{
				mParam.setAsString( mShader->findResource( MString( resource), CDX11EffectCompileHelper::resolveShaderFileName(mShader->effectName()) ));
			}
			else if( getAnnotation( dx11ShaderAnnotation::kSasResourceAddress, resource) && *resource)
			{
				mParam.setAsString( mShader->findResource( MString( resource), CDX11EffectCompileHelper::resolveShaderFileName(mShader->effectName()) ));
			}
		}
		else
		{
			return false;
		}
	}

	return true;
}