CqSolidModeBlock::CqSolidModeBlock( CqString& type, const boost::shared_ptr<CqModeBlock>& pconParent ) : CqModeBlock( pconParent, Solid ), m_strType( type ) { // Create new Attributes as they must be pushed/popped by the state change. m_pattrCurrent.reset(new CqAttributes( *pconParent->m_pattrCurrent )); m_ptransCurrent.reset( new CqTransform(*pconParent->m_ptransCurrent.get() ) ); m_poptCurrent.reset( new CqOptions(*pconParent->m_poptCurrent.get() ) ); // Create a new CSG tree node of the appropriate type. m_pCSGNode = CqCSGTreeNode::CreateNode( type ); if ( pconParent && pconParent->isSolid() ) { CqSolidModeBlock * pParentSolid = static_cast<CqSolidModeBlock*>( pconParent.get() ); // Check if we are linking under a Primitive node, if so warn, and link at the top. if ( pParentSolid->pCSGNode() ->NodeType() == CqCSGTreeNode::CSGNodeType_Primitive ) { CqString objname( "unnamed" ); const CqString* pattrName = m_pattrCurrent->GetStringAttribute( "identifier", "name" ); if ( pattrName != 0 ) objname = pattrName[ 0 ]; Aqsis::log() << warning << "Cannot add solid block under 'Primitive' \"" << objname.c_str() << "\" solid block" << std::endl; } else pParentSolid->pCSGNode() ->AddChild( m_pCSGNode ); } }
DPath SourceFileC::GetObjectPath(BuildInfo &info) { BString objname(GetPath().GetBaseName()); objname << ".o"; DPath objfolder(info.objectFolder); objfolder.Append(objname); return objfolder; }
DPath SourceFileRez::GetResourcePath(BuildInfo &info) { if (BString(GetPath().GetExtension()).ICompare("r") != 0) return GetPath(); BString objname(GetPath().GetBaseName()); objname << ".rsrc"; DPath objfolder(info.objectFolder); objfolder.Append(objname); return objfolder; }
bool SourceFileRez::CheckNeedsBuild(BuildInfo &info, bool check_deps) { if (!info.objectFolder.GetFullPath()) return false; if (BString(GetPath().GetExtension()).ICompare("r") != 0) return false; if (BuildFlag() == BUILD_YES) return true; BString objname(GetPath().GetBaseName()); objname << ".rsrc"; DPath objpath(info.objectFolder); objpath.Append(objname); if (!BEntry(objpath.GetFullPath()).Exists()) return true; BString tmpname(GetPath().GetBaseName()); tmpname << ".r.txt"; DPath tmppath(info.objectFolder); tmppath.Append(tmpname); if (!BEntry(tmppath.GetFullPath()).Exists()) return true; struct stat objstat; if (stat(objpath.GetFullPath(),&objstat) != 0) return false; // Fix mod times set into the future time_t now = real_time_clock(); if (GetModTime() > now) { BNode node(GetPath().GetFullPath()); node.SetModificationTime(now); } if (GetModTime() > objstat.st_mtime) return true; return false; }
void debug_head(int i) { int v, w, a; v=verb_code(command[i].verbcmd); if (v>=BASE_VERB && v<BASE_VERB+DUMB_VERB && syntbl[synlist[v]]!=0) w=syntbl[synlist[v]]; else w=command[i].verbcmd; if (command[i].actor>0) { dbgprintf("CMD %d: ",i); a=command[i].actor; } else { dbgprintf("REDIR: "); a=-command[i].actor; } if (a==2) dbgprintf("anybody, "); else if (a>2) { char *name; name=objname(a); name[0]=toupper(name[0]); dbgprintf("%s, ",name); rfree(name); } dbgprintf("%s ", w==0 ? "any" : dict[w]); if (command[i].noun_adj!=0) dbgprintf("%s ",gdict(command[i].noun_adj) ); dbgprintf("%s %s ",gdict(command[i].nouncmd), (ver==3)? gdict(command[i].prep) : "->"); if (command[i].obj_adj!=0) dbgprintf("%s ",gdict(command[i].obj_adj) ); dbgprintf("%s\n",gdict(command[i].objcmd) ); }
static char *getname(int inum) /* Name should be 20 chars or less */ { if (inum==0) return rstrdup("* 0 *"); return objname(inum); }
//! ofObject = true => returns list of objects this object depends on //! ofObject = false => returns list of objects that depend on this object void MetadataItem::getDependencies(std::vector<Dependency>& list, bool ofObject) { DatabasePtr d = getDatabase(); int mytype = -1; // map DBH type to RDB$DEPENDENT TYPE NodeType dep_types[] = { ntTable, ntView, ntTrigger, ntUnknown, ntUnknown, ntProcedure,ntUnknown, ntException,ntUnknown, ntUnknown, ntUnknown, ntUnknown, ntUnknown, ntUnknown, ntGenerator, ntFunction }; int type_count = sizeof(dep_types)/sizeof(NodeType); for (int i = 0; i < type_count; i++) if (typeM == dep_types[i]) mytype = i; // system tables should be treated as tables if (typeM == ntSysTable) mytype = 0; int mytype2 = mytype; // views count as relations(tables) when other object refer to them if (mytype == 1 && !ofObject) mytype2 = 0; if (typeM == ntUnknown || mytype == -1) throw FRError(_("Unsupported type")); IBPP::Database& db = d->getIBPPDatabase(); IBPP::Transaction tr1 = IBPP::TransactionFactory(db, IBPP::amRead); tr1->Start(); IBPP::Statement st1 = IBPP::StatementFactory(db, tr1); wxString o1 = (ofObject ? "DEPENDENT" : "DEPENDED_ON"); wxString o2 = (ofObject ? "DEPENDED_ON" : "DEPENDENT"); wxString sql = "select RDB$" + o2 + "_TYPE, RDB$" + o2 + "_NAME, RDB$FIELD_NAME \n " " from RDB$DEPENDENCIES \n " " where RDB$" + o1 + "_TYPE in (?,?) and RDB$" + o1 + "_NAME = ? \n "; int params = 1; if ((typeM == ntTable || typeM == ntSysTable || typeM == ntView) && ofObject) // get deps for computed columns { // view needed to bind with generators sql += " union \n" " SELECT DISTINCT d.rdb$depended_on_type, d.rdb$depended_on_name, d.rdb$field_name \n" " FROM rdb$relation_fields f \n" " LEFT JOIN rdb$dependencies d ON d.rdb$dependent_name = f.rdb$field_source \n" " WHERE d.rdb$dependent_type = 3 AND f.rdb$relation_name = ? \n"; params++; } if (!ofObject) // find tables that have calculated columns based on "this" object { sql += "union \n" " SELECT distinct cast(0 as smallint), f.rdb$relation_name, f.rdb$field_name \n" " from rdb$relation_fields f \n" " left join rdb$dependencies d on d.rdb$dependent_name = f.rdb$field_source \n" " where d.rdb$dependent_type = 3 and d.rdb$depended_on_name = ? "; params++; } // get the exact table and fields for views // rdb$dependencies covers deps. for WHERE clauses in SELECTs in VIEW body // but we also need mapping for column list in SELECT. These 2 queries cover it: if (ofObject && typeM == ntView) { sql += " union \n" " select distinct cast(0 as smallint), vr.RDB$RELATION_NAME, f.RDB$BASE_FIELD \n" " from RDB$RELATION_FIELDS f \n" " join RDB$VIEW_RELATIONS vr on f.RDB$VIEW_CONTEXT = vr.RDB$VIEW_CONTEXT \n" " and f.RDB$RELATION_NAME = vr.RDB$VIEW_NAME \n" " where f.rdb$relation_name = ? \n"; params++; } // views can depend on other views as well // we might need to add procedures here one day when Firebird gains support for it if (!ofObject && (typeM == ntView || typeM == ntTable || typeM == ntSysTable)) { sql += " union \n" " select distinct cast(0 as smallint), f.RDB$RELATION_NAME, f.RDB$BASE_FIELD \n" " from RDB$RELATION_FIELDS f \n" " join RDB$VIEW_RELATIONS vr on f.RDB$VIEW_CONTEXT = vr.RDB$VIEW_CONTEXT \n" " and f.RDB$RELATION_NAME = vr.RDB$VIEW_NAME \n" " where vr.rdb$relation_name = ? \n"; params++; } sql += " order by 1, 2, 3"; st1->Prepare(wx2std(sql, d->getCharsetConverter())); st1->Set(1, mytype); st1->Set(2, mytype2); for (int i = 0; i < params; i++) st1->Set(3 + i, wx2std(getName_(), d->getCharsetConverter())); st1->Execute(); MetadataItem* last = 0; Dependency* dep = 0; while (st1->Fetch()) { int object_type; st1->Get(1, &object_type); if (object_type > type_count) // some system object, not interesting for us continue; NodeType t = dep_types[object_type]; if (t == ntUnknown) // ditto continue; std::string objname_std; st1->Get(2, objname_std); wxString objname(std2wxIdentifier(objname_std, d->getCharsetConverter())); MetadataItem* current = d->findByNameAndType(t, objname); if (!current) { if (t == ntTable) { // maybe it's a view masked as table current = d->findByNameAndType(ntView, objname); // or possibly a system table if (!current) current = d->findByNameAndType(ntSysTable, objname); } if (!ofObject && t == ntTrigger) { // system trigger dependent of this object indicates possible check constraint on a table // that references this object. So, let's check if this trigger is used for check constraint // and get that table's name IBPP::Statement st2 = IBPP::StatementFactory(db, tr1); st2->Prepare( "select r.rdb$relation_name from rdb$relation_constraints r " " join rdb$check_constraints c on r.rdb$constraint_name=c.rdb$constraint_name " " and r.rdb$constraint_type = 'CHECK' where c.rdb$trigger_name = ? " ); st2->Set(1, objname_std); st2->Execute(); if (st2->Fetch()) // table using that trigger found { std::string s; st2->Get(1, s); wxString tablecheck(std2wxIdentifier(s, d->getCharsetConverter())); if (getName_() != tablecheck) // avoid self-reference current = d->findByNameAndType(ntTable, tablecheck); } } if (!current) continue; } if (current != last) // new object { Dependency de(current); list.push_back(de); dep = &list.back(); last = current; } if (!st1->IsNull(3)) { std::string s; st1->Get(3, s); dep->addField(std2wxIdentifier(s, d->getCharsetConverter())); } } // TODO: perhaps this could be moved to Table? // call MetadataItem::getDependencies() and then add this if ((typeM == ntTable || typeM == ntSysTable) && ofObject) // foreign keys of this table + computed columns { Table *t = dynamic_cast<Table *>(this); std::vector<ForeignKey> *f = t->getForeignKeys(); for (std::vector<ForeignKey>::const_iterator it = f->begin(); it != f->end(); ++it) { MetadataItem *table = d->findByNameAndType(ntTable, (*it).getReferencedTable()); if (!table) { throw FRError(wxString::Format(_("Table %s not found."), (*it).getReferencedTable().c_str())); } Dependency de(table); de.setFields((*it).getReferencedColumns()); list.push_back(de); } // Add check constraints here (CHECKS are checked via system triggers), example: // table1::check( table1.field1 > select max(field2) from table2 ) // So, table vs any object from this ^^^ select // Algorithm: 1.find all system triggers bound to that CHECK constraint // 2.find dependencies for those system triggers // 3.display those dependencies as deps. of this table st1->Prepare("select distinct c.rdb$trigger_name from rdb$relation_constraints r " " join rdb$check_constraints c on r.rdb$constraint_name=c.rdb$constraint_name " " and r.rdb$constraint_type = 'CHECK' where r.rdb$relation_name= ? " ); st1->Set(1, wx2std(getName_(), d->getCharsetConverter())); st1->Execute(); std::vector<Dependency> tempdep; while (st1->Fetch()) { std::string s; st1->Get(1, s); Trigger t(d->shared_from_this(), std2wxIdentifier(s, d->getCharsetConverter())); t.getDependencies(tempdep, true); } // remove duplicates, and self-references from "tempdep" while (true) { std::vector<Dependency>::iterator to_remove = tempdep.end(); for (std::vector<Dependency>::iterator it = tempdep.begin(); it != tempdep.end(); ++it) { if ((*it).getDependentObject() == this) { to_remove = it; break; } to_remove = std::find(it + 1, tempdep.end(), (*it)); if (to_remove != tempdep.end()) break; } if (to_remove == tempdep.end()) break; else tempdep.erase(to_remove); } list.insert(list.end(), tempdep.begin(), tempdep.end()); } // TODO: perhaps this could be moved to Table? if ((typeM == ntTable || typeM == ntSysTable) && !ofObject) // foreign keys of other tables { st1->Prepare( "select r1.rdb$relation_name, i.rdb$field_name " " from rdb$relation_constraints r1 " " join rdb$ref_constraints c on r1.rdb$constraint_name = c.rdb$constraint_name " " join rdb$relation_constraints r2 on c.RDB$CONST_NAME_UQ = r2.rdb$constraint_name " " join rdb$index_segments i on r1.rdb$index_name=i.rdb$index_name " " where r2.rdb$relation_name=? " " and r1.rdb$constraint_type='FOREIGN KEY' " ); st1->Set(1, wx2std(getName_(), d->getCharsetConverter())); st1->Execute(); wxString lasttable; Dependency* dep = 0; while (st1->Fetch()) { std::string s; st1->Get(1, s); wxString table_name(std2wxIdentifier(s, d->getCharsetConverter())); st1->Get(2, s); wxString field_name(std2wxIdentifier(s, d->getCharsetConverter())); if (table_name != lasttable) // new { MetadataItem* table = d->findByNameAndType(ntTable, table_name); if (!table) continue; // dummy check Dependency de(table); list.push_back(de); dep = &list.back(); lasttable = table_name; } dep->addField(field_name); } } tr1->Commit(); }
bool SourceFileC::CheckNeedsBuild(BuildInfo &info, bool check_deps) { // The checks for a file needing to be built: // 1) Build flag != BUILD_MAYBE => return result // 2) Object file missing // 3) Source mod time > object mod time // 4) Dependency file needs build // The fast stuff if (!info.objectFolder.GetFullPath()) { STRACE(2,("CheckNeedsBuild: empty file path\n")); return false; } if (BuildFlag() == BUILD_YES) { STRACE(2,("%s::CheckNeedsBuild: build flag == YES\n",GetPath().GetFullPath())); return true; } // Object file existence BString objname(GetPath().GetBaseName()); objname << ".o"; DPath objpath(info.objectFolder); objpath.Append(objname); if (!BEntry(objpath.GetFullPath()).Exists()) { STRACE(2,("%s::CheckNeedsBuild: object doesn't exist\n",GetPath().GetFullPath())); return true; } // source vs object mod time struct stat objstat; if (GetStat(objpath.GetFullPath(),&objstat) != B_OK) { STRACE(2,("%s::CheckNeedsBuild: couldn't stat object\n",GetPath().GetFullPath())); return false; } // Fix mod times set into the future time_t now = real_time_clock(); if (GetModTime() > now) { BNode node(GetPath().GetFullPath()); node.SetModificationTime(now); } if (GetModTime() > objstat.st_mtime) { STRACE(2,("%s::CheckNeedsBuild: file time more recent than object time\n", GetPath().GetFullPath())); return true; } if (!check_deps) { STRACE(2,("%s::CheckNeedsBuild: dependency checking disabled for call\n", GetPath().GetFullPath())); return false; } // Dependency check BString str(GetDependencies()); if (str.CountChars() < 1) { STRACE(2,("%s::CheckNeedsBuild: initial dependency update\n", GetPath().GetFullPath())); UpdateDependencies(info); str = GetDependencies(); } if (str.CountChars() > 0) { char *pathstr; char depString[str.Length() + 1]; sprintf(depString,"%s",str.String()); pathstr = strtok(depString,"|"); while (pathstr) { BString filename(DPath(pathstr).GetFileName()); if (filename.Compare(GetPath().GetFileName()) != 0) { DPath depPath(FindDependency(info,filename.String())); if (!depPath.IsEmpty()) { struct stat depstat; if (GetStat(depPath.GetFullPath(),&depstat) == B_OK && depstat.st_mtime > objstat.st_mtime) { STRACE(2,("%s::CheckNeedsBuild: dependency %s was updated\n", GetPath().GetFullPath(),depPath.GetFullPath())); return true; } } } pathstr = strtok(NULL,"|"); } } return false; }
bool CqImageBuffer::CullSurface( CqBound& Bound, const boost::shared_ptr<CqSurface>& pSurface ) { // If the primitive is completely outside of the hither-yon z range, cull it. if ( Bound.vecMin().z() >= m_optCache.clipFar || Bound.vecMax().z() <= m_optCache.clipNear ) return true; // This needs to be re-enabled when the RiClippingPlane code is wired up. #if 0 if(QGetRenderContext()->clippingVolume().whereIs(Bound) == CqBound::Side_Outside) { return(true); } #endif // If the primitive spans the epsilon plane and the hither plane and can be split, if ( Bound.vecMin().z() <= FLT_EPSILON ) { // Mark the primitive as not dicable. pSurface->ForceUndiceable(); CqString objname( "unnamed" ); const CqString* pattrName = pSurface->pAttributes() ->GetStringAttribute( "identifier", "name" ); if ( pattrName != 0 ) objname = pattrName[ 0 ]; Aqsis::log() << info << "Object \"" << objname.c_str() << "\" spans the epsilon plane" << std::endl; if ( pSurface->SplitCount() > m_optCache.maxEyeSplits ) { Aqsis::log() << warning << "Max eyesplits for object \"" << objname.c_str() << "\" exceeded" << std::endl; return( true ); } return ( false ); } TqFloat minz = Bound.vecMin().z(); TqFloat maxz = Bound.vecMax().z(); // Convert the bounds to raster space. CqMatrix mat; QGetRenderContext() ->matSpaceToSpace( "camera", "raster", NULL, NULL, QGetRenderContext()->Time(), mat ); Bound.Transform( mat ); // Take into account depth-of-field if ( QGetRenderContext() ->UsingDepthOfField() ) { const CqVector2D minZCoc = QGetRenderContext()->GetCircleOfConfusion( minz ); const CqVector2D maxZCoc = QGetRenderContext()->GetCircleOfConfusion( maxz ); TqFloat cocX = max( minZCoc.x(), maxZCoc.x() ); TqFloat cocY = max( minZCoc.y(), maxZCoc.y() ); Bound.vecMin().x( Bound.vecMin().x() - cocX ); Bound.vecMin().y( Bound.vecMin().y() - cocY ); Bound.vecMax().x( Bound.vecMax().x() + cocX ); Bound.vecMax().y( Bound.vecMax().y() + cocY ); } // And expand to account for filter size. Bound.vecMin().x( Bound.vecMin().x() - m_optCache.xFiltSize / 2.0f ); Bound.vecMin().y( Bound.vecMin().y() - m_optCache.yFiltSize / 2.0f ); Bound.vecMax().x( Bound.vecMax().x() + m_optCache.xFiltSize / 2.0f ); Bound.vecMax().y( Bound.vecMax().y() + m_optCache.yFiltSize / 2.0f ); // If the bounds are completely outside the viewing frustum, cull the primitive. if( Bound.vecMin().x() > QGetRenderContext()->cropWindowXMax() || Bound.vecMin().y() > QGetRenderContext()->cropWindowYMax() || Bound.vecMax().x() < QGetRenderContext()->cropWindowXMin() || Bound.vecMax().y() < QGetRenderContext()->cropWindowYMin() ) return ( true ); // Restore Z-Values to camera space. Bound.vecMin().z( minz ); Bound.vecMax().z( maxz ); // Cache the Bound. pSurface->CacheRasterBound( Bound ); return ( false ); }