void FaceInstance::update_move_planepts_vertex2(std::size_t index, std::size_t other) { ASSERT_MESSAGE(index < m_face->getWinding().size(), "select_vertex: invalid index"); const std::size_t opposite = m_face->getWinding().opposite(index, other); if (triangle_reversed(index, other, opposite)) { std::swap(index, other); } ASSERT_MESSAGE( triangles_same_winding( m_face->getWinding()[opposite].vertex, m_face->getWinding()[index].vertex, m_face->getWinding()[other].vertex, m_face->getWinding()[0].vertex, m_face->getWinding()[1].vertex, m_face->getWinding()[2].vertex ), "update_move_planepts_vertex2: error" ) m_face->m_move_planepts[0] = m_face->getWinding()[opposite].vertex; m_face->m_move_planepts[1] = m_face->getWinding()[index].vertex; m_face->m_move_planepts[2] = m_face->getWinding()[other].vertex; planepts_quantise(m_face->m_move_planepts, GRID_MIN); // winding points are very inaccurate }
bool Buttons_release(ButtonMask& buttons, guint button, guint state) { if(buttons != 0 && bitfield_disable(buttons, ButtonMask_for_event_button(button)) == 0) { ASSERT_MESSAGE(!g_accel_enabled, "Buttons_release: accelerators are enabled"); g_accel_enabled = true; for(WindowSet::iterator i = g_accel_windows.begin(); i != g_accel_windows.end(); ++i) { GtkWindow* toplevel = *i; ASSERT_MESSAGE(!window_has_accel(toplevel), "ERROR"); ASSERT_MESSAGE(GTK_WIDGET_TOPLEVEL(toplevel), "enabling accel for non-toplevel window"); gtk_window_add_accel_group(toplevel, global_accel); #if 0 globalOutputStream() << reinterpret_cast<unsigned int>(toplevel) << ": enabled global accelerators\n"; #endif #if 0 accel_group_test(toplevel, global_accel); #endif } GlobalQueuedAccelerators_commit(); } buttons = bitfield_disable(buttons, ButtonMask_for_event_button(button)); #if 0 globalOutputStream() << "Buttons_release: "; print_buttons(buttons); #endif return false; }
bool Buttons_press(ButtonMask& buttons, guint button, guint state) { if(buttons == 0 && bitfield_enable(buttons, ButtonMask_for_event_button(button)) != 0) { ASSERT_MESSAGE(g_accel_enabled, "Buttons_press: accelerators not enabled"); g_accel_enabled = false; for(WindowSet::iterator i = g_accel_windows.begin(); i != g_accel_windows.end(); ++i) { GtkWindow* toplevel = *i; ASSERT_MESSAGE(window_has_accel(toplevel), "ERROR"); ASSERT_MESSAGE(GTK_WIDGET_TOPLEVEL(toplevel), "disabling accel for non-toplevel window"); gtk_window_remove_accel_group(toplevel, global_accel); #if 0 globalOutputStream() << reinterpret_cast<unsigned int>(toplevel) << ": disabled global accelerators\n"; #endif #if 0 accel_group_test(toplevel, global_accel); #endif } } buttons = bitfield_enable(buttons, ButtonMask_for_event_button(button)); #if 0 globalOutputStream() << "Buttons_press: "; print_buttons(buttons); #endif return false; }
void CCBinaryFile::setPosition(const uint pos) { ASSERT_MESSAGE( m_File != NULL, "File::Position(...) : ERROR! File not open" ); ASSERT_MESSAGE( pos < m_Size, "File::Position(...) : ERROR! Invalid file position" ); fseek( m_File, pos, SEEK_SET ); m_Position = pos; }
void example_test_class::test_assert_message() { logMsg("ASSERT_MESSAGE example"); /* Wrapper of void assertTrue(const char * msg, bool expression , const char* file, int line); */ ASSERT_MESSAGE(1 < 2, "ASSERT_MESSAGE example (true)"); ASSERT_MESSAGE(1 > 2, "ASSERT_MESSAGE example (fail) - EXPECTED failure"); }
bool Cx_CfgRecord::AddFieldValue(const std::wstring& wstrField, const std::wstring& wstrValue) { ASSERT(IsValid() && !wstrValue.empty()); ASSERT_MESSAGE(DbFunc::IsDBName(wstrField.c_str()), "Invalid field name."); ASSERT_MESSAGE(!HasFieldValue(wstrField), "The field has already set value."); m_arrValue.push_back(FieldValue(wstrField, wstrValue)); return true; }
void CCBinaryFile::seek(const uint size) { ASSERT_MESSAGE( m_File != NULL, "File::Position(...) : ERROR! File not open" ); fseek( m_File, size, SEEK_CUR ); m_Position += size; }
void ApplicationContextImpl::initialise(int argc, char* argv[]) { // Give away unnecessary root privileges. // Important: must be done before calling gtk_init(). char *loginname; struct passwd *pw; seteuid(getuid()); if (geteuid() == 0 && (loginname = getlogin()) != 0 && (pw = getpwnam(loginname)) != 0) { setuid(pw->pw_uid); } initArgs(argc, argv); // Initialise the home directory path std::string home = os::standardPathWithSlash(g_get_home_dir()) + ".darkradiant/"; os::makeDirectory(home); _homePath = home; { char real[PATH_MAX]; _appPath = getexename(real, argv); ASSERT_MESSAGE(!_appPath.empty(), "failed to deduce app path"); } // Initialise the relative paths initPaths(); }
void Dialog::Destroy() { ASSERT_MESSAGE(m_window != 0, "dialog cannot be destroyed"); gtk_widget_destroy(GTK_WIDGET(m_window)); m_window = 0; }
void Dialog::Create() { ASSERT_MESSAGE(m_window == 0, "dialog cannot be constructed"); m_window = BuildDialog(); g_signal_connect(G_OBJECT(m_window), "delete_event", G_CALLBACK(delete_event_callback), this); }
~ModelResource () { if (realised()) { unrealise(); } ASSERT_MESSAGE(!realised(), "ModelResource::~ModelResource: resource reference still realised: " << m_name); }
std::size_t Winding_Opposite(const Winding& winding, const std::size_t index, const std::size_t other) { ASSERT_MESSAGE(index < winding.numpoints && other < winding.numpoints, "Winding_Opposite: index out of range"); double dist_best = 0; std::size_t index_best = c_brush_maxFaces; Ray edge(ray_for_points(winding[index].vertex, winding[other].vertex)); for(std::size_t i=0; i<winding.numpoints; ++i) { if(i == index || i == other) { continue; } double dist_squared = ray_squared_distance_to_point(edge, winding[i].vertex); if(dist_squared > dist_best) { dist_best = dist_squared; index_best = i; } } return index_best; }
void CCJNI::BillingRequestPurchase(const char *productID, CCLambdaCallback *callback) { if( billingCallback != NULL ) { delete billingCallback; } billingCallback = callback; CCText androidProductID = productID; androidProductID.toLowercase(); // JNI Java call JNIEnv *jEnv = gView->jniEnv; jclass jniClass = jEnv->FindClass( "com/android2c/CCJNI" ); ASSERT_MESSAGE( jniClass != 0, "Could not find Java class." ); // Get the method ID of our method "startVideoView", which takes one parameter of type string, and returns void static jmethodID mid = jEnv->GetStaticMethodID( jniClass, "BillingRequestPurchase", "(Ljava/lang/String;)V" ); ASSERT( mid != 0 ); // Call the function jstring javaURL = jEnv->NewStringUTF( androidProductID.buffer ); jEnv->CallStaticVoidMethod( jniClass, mid, javaURL ); //jEnv->DeleteLocalRef( javaURL ); }
std::size_t Winding::opposite(const std::size_t index, const std::size_t other) const { ASSERT_MESSAGE(index < size() && other < size(), "Winding::opposite: index out of range"); double dist_best = 0; std::size_t index_best = c_brush_maxFaces; Ray edge(ray_for_points((*this)[index].vertex, (*this)[other].vertex)); for (std::size_t i=0; i < size(); ++i) { if (i == index || i == other) { continue; } double dist_squared = ray_squared_distance_to_point(edge, (*this)[i].vertex); if (dist_squared > dist_best) { dist_best = dist_squared; index_best = i; } } return index_best; }
void mergeSelectedBrushes(const cmd::ArgumentList& args) { // Get the current selection BrushPtrVector brushes = selection::algorithm::getSelectedBrushes(); if (brushes.empty()) { rMessage() << _("CSG Merge: No brushes selected.") << std::endl; wxutil::Messagebox::ShowError(_("CSG Merge: No brushes selected.")); return; } if (brushes.size() < 2) { rMessage() << "CSG Merge: At least two brushes have to be selected.\n"; wxutil::Messagebox::ShowError("CSG Merge: At least two brushes have to be selected."); return; } rMessage() << "CSG Merge: Merging " << brushes.size() << " brushes." << std::endl; UndoableCommand undo("mergeSelectedBrushes"); // Take the last selected node as reference for layers and parent scene::INodePtr merged = GlobalSelectionSystem().ultimateSelected(); scene::INodePtr parent = merged->getParent(); assert(parent != NULL); // Create a new BrushNode scene::INodePtr node = GlobalBrushCreator().createBrush(); // Insert the newly created brush into the (same) parent entity parent->addChildNode(node); // Move the new brush to the same layers as the merged one node->assignToLayers(merged->getLayers()); // Get the contained brush Brush* brush = Node_getBrush(node); // Attempt to merge the selected brushes into the new one if (!Brush_merge(*brush, brushes, true)) { rWarning() << "CSG Merge: Failed - result would not be convex." << std::endl; return; } ASSERT_MESSAGE(!brush->empty(), "brush left with no faces after merge"); // Remove the original brushes for (BrushPtrVector::iterator i = brushes.begin(); i != brushes.end(); ++i) { scene::removeNodeFromParent(*i); } // Select the new brush Node_setSelected(node, true); rMessage() << "CSG Merge: Succeeded." << std::endl; SceneChangeNotify(); }
void GroupDlg::Create(GtkWindow* parent) { ASSERT_MESSAGE(m_window == 0, "dialog already created"); GtkWindow* window = create_persistent_floating_window("Entities", parent); global_accel_connect_window(window); window_connect_focus_in_clear_focus_widget(window); m_window = window; #ifdef WIN32 if( g_multimon_globals.m_bStartOnPrimMon ) { WindowPosition pos(m_position_tracker.getPosition()); PositionWindowOnPrimaryScreen(pos); m_position_tracker.setPosition(pos); } #endif m_position_tracker.connect(window); { GtkWidget* notebook = gtk_notebook_new(); gtk_widget_show(notebook); gtk_container_add (GTK_CONTAINER (window), notebook); gtk_notebook_set_tab_pos (GTK_NOTEBOOK (notebook), GTK_POS_BOTTOM); m_pNotebook = notebook; g_signal_connect(G_OBJECT(notebook), "switch_page", G_CALLBACK(switch_page), window); } }
void Clipper::getPlanePoints(Vector3 planepts[3], const AABB& bounds) const { ASSERT_MESSAGE(valid(), "clipper points not initialised"); planepts[0] = _clipPoints[0]._coords; planepts[1] = _clipPoints[1]._coords; planepts[2] = _clipPoints[2]._coords; Vector3 maxs(bounds.origin + bounds.extents); Vector3 mins(bounds.origin - bounds.extents); if (!_clipPoints[2].isSet()) { int n = (_viewType == XY) ? 2 : (_viewType == YZ) ? 0 : 1; int x = (n == 0) ? 1 : 0; int y = (n == 2) ? 1 : 2; if (n == 1) // on viewtype XZ, flip clip points { planepts[0][n] = maxs[n]; planepts[1][n] = maxs[n]; planepts[2][x] = _clipPoints[0]._coords[x]; planepts[2][y] = _clipPoints[0]._coords[y]; planepts[2][n] = mins[n]; } else { planepts[0][n] = mins[n]; planepts[1][n] = mins[n]; planepts[2][x] = _clipPoints[0]._coords[x]; planepts[2][y] = _clipPoints[0]._coords[y]; planepts[2][n] = maxs[n]; } } }
static GSList* GetListInternal (const char *refdir, const char *ext, bool directories, std::size_t depth) { GSList* files = 0; ASSERT_MESSAGE(refdir[strlen(refdir) - 1] == '/', "search path does not end in '/'"); if(directories) { for(archives_t::iterator i = g_archives.begin(); i != g_archives.end(); ++i) { DirectoryListVisitor visitor(files, refdir); (*i).archive->forEachFile(Archive::VisitorFunc(visitor, Archive::eDirectories, depth), refdir); } } else { for(archives_t::iterator i = g_archives.begin(); i != g_archives.end(); ++i) { FileListVisitor visitor(files, refdir, ext); (*i).archive->forEachFile(Archive::VisitorFunc(visitor, Archive::eFiles, depth), refdir); } } files = g_slist_reverse(files); return files; }
// greebo: This should be called "onComponentSelectionChanged", as it is a similar function of the above one // Updates the internal list of component nodes if the component selection gets changed void RadiantSelectionSystem::onComponentSelection(const scene::INodePtr& node, const Selectable& selectable) { int delta = selectable.isSelected() ? +1 : -1; _countComponent += delta; _sigSelectionChanged(selectable); _selectionInfo.totalCount += delta; _selectionInfo.componentCount += delta; // If the instance got selected, add it to the list, otherwise remove it if (selectable.isSelected()) { _componentSelection.append(node); } else { _componentSelection.erase(node); } // Notify observers, TRUE => this is a component selection change notifyObservers(node, true); // Check if the number of selected components in the list matches the value of the selection counter ASSERT_MESSAGE(_componentSelection.size() == _countComponent, "component selection-tracking error"); // Schedule an idle callback requestIdleCallback(); _requestWorkZoneRecalculation = true; _requestSceneGraphChange = true; }
const detail::DeviceBuffer& Vector<Index>::deviceBuffer(const detail::Device& /*device*/) const { ASSERT_MESSAGE(false, "This function should never be called!"); static detail::DeviceBuffer db; return db; }
std::size_t Winding::opposite(const std::size_t index, const std::size_t other) const { ASSERT_MESSAGE(index < size() && other < size(), "Winding::opposite: index out of range"); float dist_best = 0; std::size_t index_best = c_brush_maxFaces; Ray edge = Ray::createForPoints((*this)[index].vertex, (*this)[other].vertex); for (std::size_t i=0; i < size(); ++i) { if (i == index || i == other) { continue; } float dist_squared = edge.getSquaredDistance((*this)[i].vertex); if (dist_squared > dist_best) { dist_best = dist_squared; index_best = i; } } return index_best; }
// This is called if the selection changes, so that the local list of selected instances can be updated void RadiantSelectionSystem::onSelectedChanged(scene::Instance& instance, const Selectable& selectable) { // Cache the selection state bool isSelected = selectable.isSelected(); _countPrimitive += (isSelected) ? +1 : -1; _selectionChangedCallbacks(selectable); // legacy _selectionInfo.totalCount += (isSelected) ? +1 : -1; if (Instance_getBrush(instance) != NULL) { _selectionInfo.brushCount += (isSelected) ? +1 : -1; } else { _selectionInfo.entityCount += (isSelected) ? +1 : -1; } // If the selectable is selected, add it to the local selection list, otherwise remove it if (isSelected) { _selection.append(instance); } else { _selection.erase(instance); } // Notify observers, FALSE = primitive selection change notifyObservers(instance, false); // Check if the number of selected primitives in the list matches the value of the selection counter ASSERT_MESSAGE(_selection.size() == _countPrimitive, "selection-tracking error"); // Schedule an idle callback requestIdleCallback(); _requestWorkZoneRecalculation = true; }
bool Cx_CfgRecord::GetDateTime(const wchar_t* pszEntry, int& year, int& month, int& day, int& hour, int& minute, int& second) { ASSERT_MESSAGE(m_pRs != NULL, "The record is write-only."); if (m_pRs != NULL) { try { _variant_t var(m_pRs->GetFields()->GetItem(pszEntry)->GetValue()); COleDateTime dt; if (DbFunc::GetDateTime(dt, var)) { year = dt.GetYear(); month = dt.GetMonth(); day = dt.GetDay(); hour = dt.GetHour(); minute = dt.GetMinute(); second = dt.GetSecond(); return true; } } CATCH_DB_STR_ERROR } return false; }
void Node::evaluateBounds() const { if (_boundsChanged) { ASSERT_MESSAGE(!_boundsMutex, "re-entering bounds evaluation"); _boundsMutex = true; _bounds = childBounds(); _bounds.includeAABB( AABB::createFromOrientedAABBSafe(localAABB(), localToWorld()) ); _boundsMutex = false; _boundsChanged = false; // Now that our bounds are re-calculated, notify the scenegraph GraphPtr sceneGraph = _sceneGraph.lock(); if (sceneGraph) { sceneGraph->nodeBoundsChanged(const_cast<Node*>(this)->shared_from_this()); } } }
void window_get_position(ui::Window window, WindowPosition &position) { ASSERT_MESSAGE( window , "error saving window position" ); gtk_window_get_position( window, &position.x, &position.y ); gtk_window_get_size( window, &position.w, &position.h ); }
void bitmap_init(Bitmap *bitmap, i32 width, i32 height, void *pixels, int bpp) { Palette *palette = &CORE->palette; u32 size = width * height; bitmap->width = width; bitmap->height = height; bitmap->pixels = (u8 *)bank_push(CORE->storage, size); if (pixels) { if (bpp == BITMAP_32) { Color pixel; Color *pixels_end = ((Color *)pixels) + size; Color *pixels_it = (Color *)pixels; u8 *it = bitmap->pixels; u8 ix; for (; pixels_it != pixels_end; ++pixels_it) { if (pixels_it->a < 0x7F) { ix = COLOR_TRANSPARENT; // pixels_it->a = 0; goto next; } pixel = *pixels_it; // TODO: This is just for Windows, need to be done a bit better. pixel.b = pixels_it->r; pixel.r = pixels_it->b; pixel.a = 0xFF; for (ix = 1; ix < palette->colors_count; ix++) { if (palette->colors[ix].rgba == pixel.rgba) goto next; } // Add the color. ASSERT(palette->colors_count != 0xFF); if (palette->colors_count != 0xFF) { ix = palette->colors_count; palette->colors[ix] = pixel; palette->colors_count++; // printf("[palette] + #%0.2x %0.2x%0.2x%0.2x%0.2x\n", // ix, pixel.r, pixel.g, pixel.b, pixel.a); } next: // Write the indexed color. *it++ = ix; } } else if (bpp == BITMAP_8) { memcpy(bitmap->pixels, pixels, size); } else { ASSERT_MESSAGE(0, "bitmap_init: Invalid bpp specified."); } } // if pixels }
void OpenGLRenderSystem::forEachRenderable(const RenderableCallback& callback) const { ASSERT_MESSAGE(!m_traverseRenderablesMutex, "for-each during traversal"); m_traverseRenderablesMutex = true; for (Renderables::const_iterator i = m_renderables.begin(); i != m_renderables.end(); ++i) { callback(*(*i)); } m_traverseRenderablesMutex = false; }
const uint CCBinaryFile::read(void *dest, const uint size) { ASSERT_MESSAGE( m_File != NULL, "File::Read(...) : ERROR! File not open" ); // Regular file handle const uint sz = fread( dest, size, 1, m_File ); ASSERT( sz == 1 ); if( sz > 0 ) { m_Position += size; return size; } DEBUGLOG( "File::Read(...) : WARNING! Error reading. Code %i\n", sz ); ASSERT_MESSAGE( false, "File::Read(...) : ERROR! Error reading" ); return 0; }
bool CFrameWndFactory::CreateFrameWnd(LPCWSTR factoryFile) { CXTPWinDwmWrapper().SetProcessDPIAware(); // Support high DPI on Vista or above. std::wstring xtpfile(getTranslationsPath(L"ToolkitPro.Resource.xml")); if (PathFileExistsW(xtpfile.c_str())) XTPResourceManager()->SetResourceFile(xtpfile.c_str()); else TRACE1("Warning: no translation file '%s'\n", xtpfile.c_str()); Object<IConfigXml> xmlfile(x3::clsidXmlFile); ASSERT_MESSAGE(xmlfile, "Need the configxml plugin."); xmlfile->SetFileName((getConfigPath() + factoryFile).c_str()); ASSERT_MESSAGE(xmlfile->Reload(), "No xml file or need to setup MSXML4."); ConfigSection root(xmlfile->GetData()->GetSection(L"")); ConfigSection mainframe(root.GetSection(L"mainframe")); bool mdi = root->GetBool(L"mdi", false); g_factoryRoot = root; g_factoryRoot->SetString(L"_appid", m_appid.c_str()); Object<IUIOptionsInit> initOptions(clsidUIOptions); initOptions->setFileName((getConfigPath() + root->GetString(L"optionsFile", L"uioptions.xml")).c_str()); RegisterDocTemplate(mdi, mainframe, root.GetSection(L"views")); if (mdi) { CMainMDIFrame* pFrame = new CMainMDIFrame; if (!pFrame->LoadFrame(0)) return FALSE; std::vector<ViewItem>::const_iterator it = s_views.begin(); for (; it != s_views.end(); ++it) { if (!it->caption.empty()) { CDocument* pDoc = it->pTemplate->OpenDocumentFile(NULL); pDoc->SetTitle(it->caption.c_str()); } } } return ProcessShellCommand(); }
~ModelResource() { if(realised()) { unrealise(); } ASSERT_MESSAGE(!realised(), "ModelResource::~ModelResource: resource reference still realised: " << makeQuoted(m_name.c_str())); }