Example #1
0
void TheaRenderer::defineIBLNode(TheaSDK::XML::EnvironmentOptions::IBLMap& iblMap, const char *attName)
{
	MFnDependencyNode depFn(getRenderGlobalsNode());
	std::shared_ptr<RenderGlobals> renderGlobals = MayaTo::getWorldPtr()->worldRenderGlobalsPtr;
	std::shared_ptr<TheaRenderer> renderer = std::static_pointer_cast<TheaRenderer>(MayaTo::getWorldPtr()->worldRendererPtr);

	MObject fileNodeObject = getConnectedFileTextureObject(MString(attName), depFn);
	if(fileNodeObject != MObject::kNullObj)
	{
		MFnDependencyNode fileNode(fileNodeObject);
		MString fileName;
		getString(MString("fileTextureName"), fileNode, fileName); 
		if( fileName.length() > 1)
		{	
			iblMap.bitmapFilename = fileName.asChar();
			float intensity = 0.0f, rotation = 0.0f;
			getFloat("mtth_file_iblIntensity", fileNode, intensity);
			iblMap.intensity = intensity;
			getFloat("mtth_file_iblRotation", fileNode, rotation);
			iblMap.rotation = rotation;
			int wrapping = 0;
			getEnum(MString("mtth_file_iblWrapping"), fileNode, wrapping);
			iblMap.wrapping = (TheaSDK::IBLWrapping)wrapping;
			iblMap.enabled = true;
			return;
		}
	}
	iblMap.enabled = false;
}
Example #2
0
File: log.cpp Project: gityf/log
bool LogWriter::loginit(ELogLevel l, const string& logfile) {
    fd_ = ::open(logfile.c_str(), O_RDWR|O_APPEND|O_CREAT|O_LARGEFILE, 0644);
    if (0 > fd_) {
        //open failed
        return false;
    }
    level_ = l;
    logFile_ = logfile;
    inode_ = fileNode();
    return true;
}
void
TTracker::InstallDefaultTemplates()
{
	BNode node;
	BString query(kQueryTemplates);
	query += "/application_octet-stream";

	if (!BContainerWindow::DefaultStateSourceNode(query.String(), &node, false))
		if (BContainerWindow::DefaultStateSourceNode(query.String(), &node, true)) {
			AttributeStreamFileNode fileNode(&node);
			AttributeStreamTemplateNode tmp(kDefaultQueryTemplate, 3);
			fileNode << tmp;
		}

	(query = kQueryTemplates) += "/application_x-vnd.Be-bookmark";
	if (!BContainerWindow::DefaultStateSourceNode(query.String(), &node, false))
		if (BContainerWindow::DefaultStateSourceNode(query.String(), &node, true)) {
			AttributeStreamFileNode fileNode(&node);
			AttributeStreamTemplateNode tmp(kBookmarkQueryTemplate, 3);
			fileNode << tmp;
		}

	(query = kQueryTemplates) += "/application_x-person";
	if (!BContainerWindow::DefaultStateSourceNode(query.String(), &node, false))
		if (BContainerWindow::DefaultStateSourceNode(query.String(), &node, true)) {
			AttributeStreamFileNode fileNode(&node);
			AttributeStreamTemplateNode tmp(kPersonQueryTemplate, 3);
			fileNode << tmp;
		}

	(query = kQueryTemplates) += "/text_x-email";
	if (!BContainerWindow::DefaultStateSourceNode(query.String(), &node, false))
		if (BContainerWindow::DefaultStateSourceNode(query.String(), &node, true)) {
			AttributeStreamFileNode fileNode(&node);
			AttributeStreamTemplateNode tmp(kEmailQueryTemplate, 3);
			fileNode << tmp;
		}
}
Example #4
0
File: log.cpp Project: gityf/log
bool LogWriter::log(ELogLevel l, const char* format, ...) {
    if (l > level_) {
        return false;
    }
    char* bPtr;
    va_list ap;
    va_start(ap, format);
    int blen = ::vasprintf(&bPtr, format, ap);
    if (blen < 0) {
        va_end(ap);
        return false;
    }
    va_end(ap);
    char header[100] = { 0 };
    int hlen = 0;
    logHeader(header, hlen, l);
    INIT_IOV(2);
    SET_IOV_LEN(header, hlen);
    SET_IOV_LEN(bPtr, blen);
    if (inode_ != fileNode() || !inode_) {
        rwlock_.WLock();
        if (inode_ != fileNode() || !inode_) {
            logclose();
            loginit(level_, logFile_);
        }
        rwlock_.UnLock();
    }
    bool ret = true;
    rwlock_.RLock();
    if (::writev(fd_, iovs, 2) <= 0) {
        ret = false;
    }
    rwlock_.UnLock();
    free(bPtr);
    return ret;
}
Example #5
0
void LoadSave::saveToXML(const XmlNode& node, const std::string& dataFileName, const std::string& dataFileIdentifier) {
	//Misc::makeBackup(dataFileName); debug crashes...
	toDebugLog("Saving node " + dataFileIdentifier + " to " + dataFileName);
	// TODO: Create directory if it is missing!
	try {
		std::ofstream ofs(dataFileName.c_str());
		OutputArchive outputArchive(ofs);
		XmlNode fileNode(dataFileIdentifier);
		fileNode.addChild(node);
		outputArchive << fileNode;
		ofs.close();
	} catch(std::exception& e) {
		throw FileException("Could not save node " + dataFileIdentifier + " to XML " + dataFileName + ". (" + e.what() + ")");
	}
}
void 
BQueryContainerWindow::SetUpDefaultState()
{
	BNode defaultingNode;

	WindowStateNodeOpener opener(this, true);
		// this is our destination node, whatever it is for this window
	if (!opener.StreamNode())
		return;

	BString defaultStatePath(kQueryTemplates);
	BString sanitizedType(PoseView()->SearchForType());

	defaultStatePath += '/';
	int32 length = sanitizedType.Length();
	char *buf = sanitizedType.LockBuffer(length);
	for (int32 index = length - 1; index >= 0; index--)
		if (buf[index] == '/')
			buf[index] = '_';
	sanitizedType.UnlockBuffer(length);

	defaultStatePath += sanitizedType;

	PRINT(("looking for default query state at %s\n", defaultStatePath.String()));

	if (!DefaultStateSourceNode(defaultStatePath.String(), &defaultingNode, false)) {
		TRACE();
		return;
	}

	// copy over the attributes

	// set up a filter of the attributes we want copied
	const char *allowAttrs[] = {
		kAttrWindowFrame,
		kAttrViewState,
		kAttrViewStateForeign,
		kAttrColumns,
		kAttrColumnsForeign,
		0
	};

	// do it
	AttributeStreamMemoryNode memoryNode;
	NamesToAcceptAttrFilter filter(allowAttrs);
	AttributeStreamFileNode fileNode(&defaultingNode);
	*opener.StreamNode() << memoryNode << filter << fileNode;
}
Example #7
0
void PECOFFLinkingContext::createImplicitFiles(
    std::vector<std::unique_ptr<File>> &) {
  std::vector<std::unique_ptr<Node>> &members = getNodes();

  // Create a file for the entry point function.
  std::unique_ptr<FileNode> entry(new FileNode(
      llvm::make_unique<pecoff::EntryPointFile>(*this)));
  members.insert(members.begin() + getGroupStartPos(members), std::move(entry));

  // Create a file for __ImageBase.
  std::unique_ptr<FileNode> fileNode(new FileNode(
      llvm::make_unique<pecoff::LinkerGeneratedSymbolFile>(*this)));
  members.push_back(std::move(fileNode));

  // Create a file for _imp_ symbols.
  std::unique_ptr<FileNode> impFileNode(new FileNode(
      llvm::make_unique<pecoff::LocallyImportedSymbolFile>(*this)));
  members.push_back(std::move(impFileNode));

  // Create a file for dllexported symbols.
  std::unique_ptr<FileNode> exportNode(new FileNode(
      llvm::make_unique<pecoff::ExportedSymbolRenameFile>(*this)));
  addLibraryFile(std::move(exportNode));
}
Example #8
0
void
TTracker::InstallDefaultTemplates()
{
	// the following templates are in big endian and we rely on the Tracker
	// translation support to swap them on little endian machines
	//
	// in case there is an attribute (B_RECT_TYPE) that gets swapped by the media
	// (unzip, file system endianness swapping, etc., the correct endianness for
	// the correct machine has to be used here

	static AttributeTemplate sDefaultQueryTemplate[] =
		/* /boot/home/config/settings/Tracker/DefaultQueryTemplates/
		   application_octet-stream */
	{
		{
			// default frame
			kAttrWindowFrame,
			B_RECT_TYPE,
			16,
			(const char*)&kDefaultFrame
		},
		{
			// attr: _trk/viewstate
			kAttrViewState_be,
			B_RAW_TYPE,
			49,
			"o^\365R\000\000\000\012Tlst\000\000\000\000\000\000\000\000\000\000"
				"\000\000\000\000\000\000\000\000\000\000\357\323\335RCSTR\000\000"
				"\000\000\000\000\000\000\000"
		},
		{
			// attr: _trk/columns
			kAttrColumns_be,
			B_RAW_TYPE,
			0,
			NULL
		}
	};

#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "Default Query Columns"

	static const ColumnData defaultQueryColumns[] =
	{
		{ B_TRANSLATE_MARK("Name"), 40, 145, B_ALIGN_LEFT, "_stat/name",
			B_STRING_TYPE, true, true },
		{ B_TRANSLATE_MARK("Path"), 200, 225, B_ALIGN_LEFT, "_trk/path",
			B_STRING_TYPE, false, false },
		{ B_TRANSLATE_MARK("Size"), 440, 41, B_ALIGN_LEFT, "_stat/size",
			B_OFF_T_TYPE, true, false },
		{ B_TRANSLATE_MARK("Modified"), 496, 138, B_ALIGN_LEFT, "_stat/modified",
			B_TIME_TYPE, true, false }
	};


	static AttributeTemplate sBookmarkQueryTemplate[] =
		/* /boot/home/config/settings/Tracker/DefaultQueryTemplates/
		   application_x-vnd.Be-bookmark */
	{
		{
			// default frame
			kAttrWindowFrame,
			B_RECT_TYPE,
			16,
			(const char*)&kDefaultFrame
		},
		{
			// attr: _trk/viewstate
			kAttrViewState_be,
			B_RAW_TYPE,
			49,
			"o^\365R\000\000\000\012Tlst\000\000\000\000\000\000\000\000\000\000"
				"\000\000\000\000\000\000\000\000\000\000w\373\175RCSTR\000\000\000"
				"\000\000\000\000\000\000"
		},
		{
			// attr: _trk/columns
			kAttrColumns_be,
			B_RAW_TYPE,
			0,
			NULL
		}
	};


#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "Bookmark Query Columns"


	static const ColumnData bookmarkQueryColumns[] =
	{
		{ B_TRANSLATE_MARK("Title"), 40, 171, B_ALIGN_LEFT, "META:title",
			B_STRING_TYPE, false, true },
		{ B_TRANSLATE_MARK("URL"), 226, 287, B_ALIGN_LEFT, kAttrURL,
			B_STRING_TYPE, false, true },
		{ B_TRANSLATE_MARK("Keywords"), 528, 130, B_ALIGN_LEFT, "META:keyw",
			B_STRING_TYPE, false, true }
	};


	static AttributeTemplate sPersonQueryTemplate[] =
		/* /boot/home/config/settings/Tracker/DefaultQueryTemplates/
		   application_x-vnd.Be-bookmark */
	{
		{
			// default frame
			kAttrWindowFrame,
			B_RECT_TYPE,
			16,
			(const char*)&kDefaultFrame
		},
		{
			// attr: _trk/viewstate
			kAttrViewState_be,
			B_RAW_TYPE,
			49,
			"o^\365R\000\000\000\012Tlst\000\000\000\000\000\000\000\000\000\000"
				"\000\000\000\000\000\000\000\000\000\000\357\323\335RCSTR\000\000"
				"\000\000\000\000\000\000\000"
		},
		{
			// attr: _trk/columns
			kAttrColumns_be,
			B_RAW_TYPE,
			0,
			NULL
		},
	};


#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "Person Query Columns"


	static const ColumnData personQueryColumns[] =
	{
		{ B_TRANSLATE_MARK("Name"), 40, 115, B_ALIGN_LEFT, "_stat/name",
			B_STRING_TYPE, true, true },
		{ B_TRANSLATE_MARK("Work Phone"), 170, 90, B_ALIGN_LEFT, kAttrWorkPhone,
			B_STRING_TYPE, false, true },
		{ B_TRANSLATE_MARK("E-mail"), 275, 93, B_ALIGN_LEFT, kAttrEmail,
			B_STRING_TYPE, false, true },
		{ B_TRANSLATE_MARK("Company"), 383, 120, B_ALIGN_LEFT, kAttrCompany,
			B_STRING_TYPE, false, true }
	};


	static AttributeTemplate sEmailQueryTemplate[] =
		/* /boot/home/config/settings/Tracker/DefaultQueryTemplates/
		   text_x-email */
	{
		{
			// default frame
			kAttrWindowFrame,
			B_RECT_TYPE,
			16,
			(const char*)&kDefaultFrame
		},
		{
			// attr: _trk/viewstate
			kAttrViewState_be,
			B_RAW_TYPE,
			49,
			"o^\365R\000\000\000\012Tlst\000\000\000\000\000\000\000\000\000\000"
				"\000\000\000\000\000\000\000\000\000\000\366_\377ETIME\000\000\000"
				"\000\000\000\000\000\000"
		},
		{
			// attr: _trk/columns
			kAttrColumns_be,
			B_RAW_TYPE,
			0,
			NULL
		},
	};


#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "Email Query Columns"


	static const ColumnData emailQueryColumns[] =
	{
		{ B_TRANSLATE_MARK("Subject"), 40, 110, B_ALIGN_LEFT, "MAIL:subject",
			B_STRING_TYPE, false, false },
		{ B_TRANSLATE_MARK("From"), 165, 153, B_ALIGN_LEFT, "MAIL:from",
			B_STRING_TYPE, false, false },
		{ B_TRANSLATE_MARK("When"), 333, 120, B_ALIGN_LEFT, "MAIL:when",
			B_STRING_TYPE, false, false },
		{ B_TRANSLATE_MARK("Status"), 468, 50, B_ALIGN_RIGHT, "MAIL:status",
			B_STRING_TYPE, false, true }
	};


	BNode node;
	BString query(kQueryTemplates);
	query += "/application_octet-stream";

	if (!BContainerWindow::DefaultStateSourceNode(query.String(),
			&node, false)) {
		if (BContainerWindow::DefaultStateSourceNode(query.String(),
				&node, true)) {
			BMallocIO stream;
			size_t n = mkColumnsBits(stream,
					defaultQueryColumns, 4, "Default Query Columns");
			sDefaultQueryTemplate[2].fSize = n;
			sDefaultQueryTemplate[2].fBits = (const char*)stream.Buffer();

			AttributeStreamFileNode fileNode(&node);
			AttributeStreamTemplateNode tmp(sDefaultQueryTemplate, 3);
			fileNode << tmp;
		}
	}

	(query = kQueryTemplates) += "/application_x-vnd.Be-bookmark";
	if (!BContainerWindow::DefaultStateSourceNode(query.String(),
			&node, false)) {
		if (BContainerWindow::DefaultStateSourceNode(query.String(),
				&node, true)) {
			BMallocIO stream;
			size_t n = mkColumnsBits(stream,
				bookmarkQueryColumns, 3, "Bookmark Query Columns");
			sBookmarkQueryTemplate[2].fSize = n;
			sBookmarkQueryTemplate[2].fBits = (const char*)stream.Buffer();

			AttributeStreamFileNode fileNode(&node);
			AttributeStreamTemplateNode tmp(sBookmarkQueryTemplate, 3);
			fileNode << tmp;
		}
	}

	(query = kQueryTemplates) += "/application_x-person";
	if (!BContainerWindow::DefaultStateSourceNode(query.String(),
			&node, false)) {
		if (BContainerWindow::DefaultStateSourceNode(query.String(),
				&node, true)) {
			BMallocIO stream;
			size_t n = mkColumnsBits(stream,
				personQueryColumns, 4, "Person Query Columns");
			sPersonQueryTemplate[2].fSize = n;
			sPersonQueryTemplate[2].fBits = (const char*)stream.Buffer();

			AttributeStreamFileNode fileNode(&node);
			AttributeStreamTemplateNode tmp(sPersonQueryTemplate, 3);
			fileNode << tmp;
		}
	}

	(query = kQueryTemplates) += "/text_x-email";
	if (!BContainerWindow::DefaultStateSourceNode(query.String(),
			&node, false)) {
		if (BContainerWindow::DefaultStateSourceNode(query.String(),
				&node, true)) {
			BMallocIO stream;
			size_t n = mkColumnsBits(stream,
				emailQueryColumns, 4, "Email Query Columns");
			sEmailQueryTemplate[2].fSize = n;
			sEmailQueryTemplate[2].fBits = (const char*)stream.Buffer();

			AttributeStreamFileNode fileNode(&node);
			AttributeStreamTemplateNode tmp(sEmailQueryTemplate, 3);
			fileNode << tmp;
		}
	}
}